restored by compiling with NO_PREVIEW defined.
-/* $NetBSD: input.c,v 1.3 1996/02/06 22:47:33 jtc Exp $ */
+/* $NetBSD: input.c,v 1.4 1999/01/03 02:00:17 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
break;
}
-/*
- * Eat up any input (used at end of game).
- */
-void
-eat_input()
-{
- struct timeval tv;
- char c;
-
- do {
- tv.tv_sec = tv.tv_usec = 0;
- } while (rwait(&tv) && read(0, &c, 1) == 1);
-}
-
/*
* getchar with timeout.
*/
-/* $NetBSD: input.h,v 1.2 1995/04/22 07:42:36 cgd Exp $ */
+/* $NetBSD: input.h,v 1.3 1999/01/03 02:00:17 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
* @(#)input.h 8.1 (Berkeley) 5/31/93
*/
-void eat_input __P((void));
int rwait __P((struct timeval *));
int tgetchar __P((void));
void tsleep __P((void));
-/* $NetBSD: screen.c,v 1.7 1998/08/10 02:25:45 perry Exp $ */
+/* $NetBSD: screen.c,v 1.8 1999/01/03 02:00:18 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
Cols = COnum;
if (Rows < MINROWS || Cols < MINCOLS) {
(void) fprintf(stderr,
- "the screen is too small: must be at least %d x %d",
- MINROWS, MINCOLS);
+ "the screen is too small: must be at least %dx%d, ",
+ MINCOLS, MINROWS);
stop(""); /* stop() supplies \n */
}
if (tcgetattr(0, &oldtt) < 0)
register regcell so, cur_so = 0;
register int i, ccol, j;
sigset_t sigset, osigset;
+ static struct shape *lastshape;
sigemptyset(&sigset);
sigaddset(&sigset, SIGTSTP);
putpad(HOstr);
else
moveto(0, 0);
- (void) printf("%d", score);
+ (void) printf("Score: %d", score);
curscore = score;
}
+#ifndef NO_PREVIEW
+ /* draw preview of nextpattern */
+ if (nextshape != lastshape) {
+ int i;
+ static int r=5, c=2;
+ int tr, tc, t;
+
+ lastshape = nextshape;
+
+ /* clean */
+ putpad(SEstr);
+ moveto(r-1, c-1); putstr(" ");
+ moveto(r, c-1); putstr(" ");
+ moveto(r+1, c-1); putstr(" ");
+ moveto(r+2, c-1); putstr(" ");
+
+ moveto(r-3, c-2);
+ putstr("Next shape:");
+
+ /* draw */
+ putpad(SOstr);
+ moveto(r, 2*c);
+ putstr(" ");
+ for(i=0; i<3; i++) {
+ t = c + r*B_COLS;
+ t += nextshape->off[i];
+
+ tr = t / B_COLS;
+ tc = t % B_COLS;
+
+ moveto(tr, 2*tc);
+ putstr(" ");
+ }
+ putpad(SEstr);
+ }
+#endif
+
bp = &board[D_FIRST * B_COLS];
sp = &curscreen[D_FIRST * B_COLS];
for (j = D_FIRST; j < D_LAST; j++) {
-.\" $NetBSD: tetris.6,v 1.4 1997/09/01 23:26:11 mikel Exp $
+.\" $NetBSD: tetris.6,v 1.5 1999/01/03 02:00:18 hubertf Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.Pp
Manual adapted from the original entry written by Nancy L. Tinkham and
Darren F. Provine.
+.Pp
+Code for previewing next shape added by Hubert Feyrer in 1999.
-/* $NetBSD: tetris.c,v 1.5 1998/09/13 15:27:30 hubertf Exp $ */
+/* $NetBSD: tetris.c,v 1.6 1999/01/03 02:00:18 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
void onintr __P((int)) __attribute__((__noreturn__));
void usage __P((void)) __attribute__((__noreturn__));
+struct shape *curshape;
+struct shape *nextshape;
+
+
/*
* Set up the initial board. The bottom display row is completely set,
* along with another (hidden) row underneath that. Also, the left and
char *argv[];
{
register int pos, c;
- register struct shape *curshape;
register char *keys;
register int level = 2;
char key_write[6][10];
scr_set();
pos = A_FIRST*B_COLS + (B_COLS/2)-1;
+ nextshape = randshape();
curshape = randshape();
scr_msg(key_msg, 1);
* Choose a new shape. If it does not fit,
* the game is over.
*/
- curshape = randshape();
+ curshape = nextshape;
+ nextshape = randshape();
pos = A_FIRST*B_COLS + (B_COLS/2)-1;
if (!fits_in(curshape, pos))
break;
}
continue;
}
- if (c == '\f')
+ if (c == '\f') {
scr_clear();
+ scr_msg(key_msg, 1);
+ }
}
scr_clear();
-/* $NetBSD: tetris.h,v 1.3 1998/09/13 15:27:30 hubertf Exp $ */
+/* $NetBSD: tetris.h,v 1.4 1999/01/03 02:00:18 hubertf Exp $ */
/*-
* Copyright (c) 1992, 1993
extern struct shape shapes[];
#define randshape() (&shapes[random() % 7])
+extern struct shape *curshape;
+extern struct shape *nextshape;
+
/*
* Shapes fall at a rate faster than once per second.
*