Add a little color. In order to minimize logic differences, keep 0 as the
empty board value, and since 7 is white, turn white into black (0) when painting.
This commit is contained in:
parent
aa4d50801e
commit
a5d2792650
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: screen.c,v 1.27 2011/10/03 12:32:28 roy Exp $ */
|
||||
/* $NetBSD: screen.c,v 1.28 2014/06/11 16:47:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -94,6 +94,18 @@ moveto(int r, int c)
|
||||
putpad(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
setcolor(int c)
|
||||
{
|
||||
char *buf;
|
||||
if (set_a_foreground == NULL)
|
||||
return;
|
||||
|
||||
buf = tiparm(set_a_foreground, c == 7 ? 0 : c);
|
||||
if (buf != NULL)
|
||||
putpad(buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up from termcap.
|
||||
*/
|
||||
@ -312,6 +324,7 @@ scr_update(void)
|
||||
|
||||
/* draw */
|
||||
putpad(enter_standout_mode);
|
||||
setcolor(nextshape->color);
|
||||
moveto(r, 2*c);
|
||||
putstr(" ");
|
||||
for(i=0; i<3; i++) {
|
||||
@ -349,7 +362,14 @@ scr_update(void)
|
||||
exit_standout_mode);
|
||||
cur_so = so;
|
||||
}
|
||||
setcolor(so);
|
||||
#ifdef DEBUG
|
||||
char buf[3];
|
||||
snprintf(buf, sizeof(buf), "%d%d", so, so);
|
||||
putstr(buf);
|
||||
#else
|
||||
putstr(" ");
|
||||
#endif
|
||||
} else
|
||||
putstr(so ? "XX" : " ");
|
||||
ccol = i + 1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: shapes.c,v 1.8 2009/05/25 04:33:53 dholland Exp $ */
|
||||
/* $NetBSD: shapes.c,v 1.9 2014/06/11 16:47:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -53,25 +53,25 @@
|
||||
#define BR B_COLS+1 /* bottom right */
|
||||
|
||||
const struct shape shapes[] = {
|
||||
/* 0*/ { 7, { TL, TC, MR, } },
|
||||
/* 1*/ { 8, { TC, TR, ML, } },
|
||||
/* 2*/ { 9, { ML, MR, BC, } },
|
||||
/* 3*/ { 3, { TL, TC, ML, } },
|
||||
/* 4*/ { 12, { ML, BL, MR, } },
|
||||
/* 5*/ { 15, { ML, BR, MR, } },
|
||||
/* 6*/ { 18, { ML, MR, 2 } }, /* sticks out */
|
||||
/* 7*/ { 0, { TC, ML, BL, } },
|
||||
/* 8*/ { 1, { TC, MR, BR, } },
|
||||
/* 9*/ { 10, { TC, MR, BC, } },
|
||||
/*10*/ { 11, { TC, ML, MR, } },
|
||||
/*11*/ { 2, { TC, ML, BC, } },
|
||||
/*12*/ { 13, { TC, BC, BR, } },
|
||||
/*13*/ { 14, { TR, ML, MR, } },
|
||||
/*14*/ { 4, { TL, TC, BC, } },
|
||||
/*15*/ { 16, { TR, TC, BC, } },
|
||||
/*16*/ { 17, { TL, MR, ML, } },
|
||||
/*17*/ { 5, { TC, BC, BL, } },
|
||||
/*18*/ { 6, { TC, BC, 2*B_COLS } } /* sticks out */
|
||||
/* 0*/ { 7, 7, { TL, TC, MR, } },
|
||||
/* 1*/ { 1, 8, { TC, TR, ML, } },
|
||||
/* 2*/ { 2, 9, { ML, MR, BC, } },
|
||||
/* 3*/ { 3, 3, { TL, TC, ML, } },
|
||||
/* 4*/ { 4, 12, { ML, BL, MR, } },
|
||||
/* 5*/ { 5, 15, { ML, BR, MR, } },
|
||||
/* 6*/ { 6, 18, { ML, MR, 2 } }, /* sticks out */
|
||||
/* 7*/ { 7, 0, { TC, ML, BL, } },
|
||||
/* 8*/ { 1, 1, { TC, MR, BR, } },
|
||||
/* 9*/ { 2, 10, { TC, MR, BC, } },
|
||||
/*10*/ { 2, 11, { TC, ML, MR, } },
|
||||
/*11*/ { 2, 2, { TC, ML, BC, } },
|
||||
/*12*/ { 4, 13, { TC, BC, BR, } },
|
||||
/*13*/ { 4, 14, { TR, ML, MR, } },
|
||||
/*14*/ { 4, 4, { TL, TC, BC, } },
|
||||
/*15*/ { 5, 16, { TR, TC, BC, } },
|
||||
/*16*/ { 5, 17, { TL, MR, ML, } },
|
||||
/*17*/ { 5, 5, { TC, BC, BL, } },
|
||||
/*18*/ { 6, 6, { TC, BC, 2*B_COLS } } /* sticks out */
|
||||
};
|
||||
|
||||
/*
|
||||
@ -97,6 +97,7 @@ void
|
||||
place(const struct shape *shape, int pos, int onoff)
|
||||
{
|
||||
const int *o = shape->off;
|
||||
onoff = onoff ? shape->color : 0;
|
||||
|
||||
board[pos] = onoff;
|
||||
board[pos + *o++] = onoff;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tetris.c,v 1.24 2011/08/31 16:24:56 plunky Exp $ */
|
||||
/* $NetBSD: tetris.c,v 1.25 2014/06/11 16:47:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -92,7 +92,7 @@ setup_board(void)
|
||||
|
||||
p = board;
|
||||
for (i = B_SIZE; i; i--)
|
||||
*p++ = i <= (2 * B_COLS) || (i % B_COLS) < 2;
|
||||
*p++ = (i <= (2 * B_COLS) || (i % B_COLS) < 2) ? 7 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: tetris.h,v 1.12 2009/08/12 08:51:21 dholland Exp $ */
|
||||
/* $NetBSD: tetris.h,v 1.13 2014/06/11 16:47:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
@ -123,6 +123,7 @@ extern int Rows, Cols; /* current screen size */
|
||||
* rotated forms.
|
||||
*/
|
||||
struct shape {
|
||||
int color;
|
||||
int rot; /* index of rotated version of this shape */
|
||||
int off[3]; /* offsets to other blots if center is at (0,0) */
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user