Module Name:    src
Committed By:   nat
Date:           Thu Mar  3 21:38:55 UTC 2016

Modified Files:
        src/games/tetris: screen.c tetris.c tetris.h

Log Message:
Center game board on screen.  OK from christos@.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/games/tetris/screen.c \
    src/games/tetris/tetris.c
cvs rdiff -u -r1.14 -r1.15 src/games/tetris/tetris.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/games/tetris/screen.c
diff -u src/games/tetris/screen.c:1.31 src/games/tetris/screen.c:1.32
--- src/games/tetris/screen.c:1.31	Fri Nov  6 19:53:37 2015
+++ src/games/tetris/screen.c	Thu Mar  3 21:38:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: screen.c,v 1.31 2015/11/06 19:53:37 christos Exp $	*/
+/*	$NetBSD: screen.c,v 1.32 2016/03/03 21:38:55 nat Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -197,6 +197,7 @@ scr_set(void)
 		    MINCOLS, MINROWS);
 		stop("");	/* stop() supplies \n */
 	}
+	Offset = (Rows - D_LAST + D_FIRST - 2) / 2;
 	if (tcgetattr(0, &oldtt) < 0)
 		stop("tcgetattr() fails");
 	newtt = oldtt;
@@ -360,7 +361,7 @@ scr_update(void)
 					putpad(exit_standout_mode);
 					cur_so = 0;
 				}
-				moveto(RTOD(j), CTOD(i));
+				moveto(RTOD(j + Offset), CTOD(i));
 			}
 			if (enter_standout_mode) {
 				if (so != cur_so) {
Index: src/games/tetris/tetris.c
diff -u src/games/tetris/tetris.c:1.31 src/games/tetris/tetris.c:1.32
--- src/games/tetris/tetris.c:1.31	Fri Nov  6 19:53:37 2015
+++ src/games/tetris/tetris.c	Thu Mar  3 21:38:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tetris.c,v 1.31 2015/11/06 19:53:37 christos Exp $	*/
+/*	$NetBSD: tetris.c,v 1.32 2016/03/03 21:38:55 nat Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -62,6 +62,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 cell	board[B_SIZE];		/* 1 => occupied, 0 => empty */
 
 int	Rows, Cols;		/* current screen size */
+int	Offset;			/* used to center board & shapes */
 
 static const struct shape *curshape;
 const struct shape *nextshape;

Index: src/games/tetris/tetris.h
diff -u src/games/tetris/tetris.h:1.14 src/games/tetris/tetris.h:1.15
--- src/games/tetris/tetris.h:1.14	Sun Jul 13 16:23:55 2014
+++ src/games/tetris/tetris.h	Thu Mar  3 21:38:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: tetris.h,v 1.14 2014/07/13 16:23:55 pgoyette Exp $	*/
+/*	$NetBSD: tetris.h,v 1.15 2016/03/03 21:38:55 nat Exp $	*/
 
 /*-
  * Copyright (c) 1992, 1993
@@ -73,6 +73,7 @@ extern cell	board[B_SIZE];	/* 1 => occup
 #define	MINCOLS	40
 
 extern int	Rows, Cols;	/* current screen size */
+extern int	Offset;		/* vert. offset to center board */
 
 /*
  * Translations from board coordinates to display coordinates.

Reply via email to