Fri Nov 6 19:53:37 2015 UTC ()
PR/50411: Rin Okuyama: fix two bugs:
- clear blocks in the 0 row, otherwise the pile up forever.
- black (white) blocks are not shown as "next shape":


(christos)
diff -r1.30 -r1.31 src/games/tetris/screen.c
diff -r1.30 -r1.31 src/games/tetris/tetris.c

cvs diff -r1.30 -r1.31 src/games/tetris/screen.c (expand / switch to unified diff)

--- src/games/tetris/screen.c 2015/07/07 22:53:25 1.30
+++ src/games/tetris/screen.c 2015/11/06 19:53:37 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: screen.c,v 1.30 2015/07/07 22:53:25 nat Exp $ */ 1/* $NetBSD: screen.c,v 1.31 2015/11/06 19:53:37 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek and Darren F. Provine. 8 * Chris Torek and Darren F. Provine.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -320,28 +320,28 @@ scr_update(void) @@ -320,28 +320,28 @@ scr_update(void)
320 lastshape = nextshape; 320 lastshape = nextshape;
321  321
322 /* clean */ 322 /* clean */
323 putpad(exit_standout_mode); 323 putpad(exit_standout_mode);
324 moveto(r-1, c-1); putstr(" "); 324 moveto(r-1, c-1); putstr(" ");
325 moveto(r, c-1); putstr(" "); 325 moveto(r, c-1); putstr(" ");
326 moveto(r+1, c-1); putstr(" "); 326 moveto(r+1, c-1); putstr(" ");
327 moveto(r+2, c-1); putstr(" "); 327 moveto(r+2, c-1); putstr(" ");
328 328
329 moveto(r-3, c-2); 329 moveto(r-3, c-2);
330 putstr("Next shape:"); 330 putstr("Next shape:");
331  331
332 /* draw */ 332 /* draw */
333 putpad(enter_standout_mode); 
334 setcolor(nextshape->color); 333 setcolor(nextshape->color);
 334 putpad(enter_standout_mode);
335 moveto(r, 2*c); 335 moveto(r, 2*c);
336 putstr(" "); 336 putstr(" ");
337 for(i=0; i<3; i++) { 337 for(i=0; i<3; i++) {
338 t = c + r*B_COLS; 338 t = c + r*B_COLS;
339 t += nextshape->off[i]; 339 t += nextshape->off[i];
340 340
341 tr = t / B_COLS; 341 tr = t / B_COLS;
342 tc = t % B_COLS; 342 tc = t % B_COLS;
343 343
344 moveto(tr, 2*tc); 344 moveto(tr, 2*tc);
345 putstr(" "); 345 putstr(" ");
346 } 346 }
347 putpad(exit_standout_mode); 347 putpad(exit_standout_mode);

cvs diff -r1.30 -r1.31 src/games/tetris/tetris.c (expand / switch to unified diff)

--- src/games/tetris/tetris.c 2015/06/13 04:53:13 1.30
+++ src/games/tetris/tetris.c 2015/11/06 19:53:37 1.31
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tetris.c,v 1.30 2015/06/13 04:53:13 dholland Exp $ */ 1/* $NetBSD: tetris.c,v 1.31 2015/11/06 19:53:37 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek and Darren F. Provine. 8 * Chris Torek and Darren F. Provine.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -106,26 +106,28 @@ elide(void) @@ -106,26 +106,28 @@ elide(void)
106 cell *p; 106 cell *p;
107 107
108 for (i = A_FIRST; i < A_LAST; i++) { 108 for (i = A_FIRST; i < A_LAST; i++) {
109 base = i * B_COLS + 1; 109 base = i * B_COLS + 1;
110 p = &board[base]; 110 p = &board[base];
111 for (j = B_COLS - 2; *p++ != 0;) { 111 for (j = B_COLS - 2; *p++ != 0;) {
112 if (--j <= 0) { 112 if (--j <= 0) {
113 /* this row is to be elided */ 113 /* this row is to be elided */
114 memset(&board[base], 0, B_COLS - 2); 114 memset(&board[base], 0, B_COLS - 2);
115 scr_update(); 115 scr_update();
116 tsleep(); 116 tsleep();
117 while (--base != 0) 117 while (--base != 0)
118 board[base + B_COLS] = board[base]; 118 board[base + B_COLS] = board[base];
 119 /* don't forget to clear 0th row */
 120 memset(&board[1], 0, B_COLS - 2);
119 scr_update(); 121 scr_update();
120 tsleep(); 122 tsleep();
121 break; 123 break;
122 } 124 }
123 } 125 }
124 } 126 }
125} 127}
126 128
127int 129int
128main(int argc, char *argv[]) 130main(int argc, char *argv[])
129{ 131{
130 int pos, c; 132 int pos, c;
131 const char *keys; 133 const char *keys;