Module Name: src
Committed By: tls
Date: Sun Aug 10 06:51:14 UTC 2014
Modified Files:
src/games/tetris [tls-earlyentropy]: screen.c shapes.c tetris.6
tetris.c tetris.h
Log Message:
Rebase.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.27.18.1 src/games/tetris/screen.c
cvs rdiff -u -r1.8 -r1.8.22.1 src/games/tetris/shapes.c
cvs rdiff -u -r1.11 -r1.11.60.1 src/games/tetris/tetris.6
cvs rdiff -u -r1.24 -r1.24.18.1 src/games/tetris/tetris.c
cvs rdiff -u -r1.12 -r1.12.22.1 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.27 src/games/tetris/screen.c:1.27.18.1
--- src/games/tetris/screen.c:1.27 Mon Oct 3 12:32:28 2011
+++ src/games/tetris/screen.c Sun Aug 10 06:51:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: screen.c,v 1.27 2011/10/03 12:32:28 roy Exp $ */
+/* $NetBSD: screen.c,v 1.27.18.1 2014/08/10 06:51:14 tls Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -94,6 +94,20 @@ moveto(int r, int c)
putpad(buf);
}
+static void
+setcolor(int c)
+{
+ char *buf;
+ if (nocolor == 1)
+ return;
+ 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 +326,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 +364,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;
Index: src/games/tetris/shapes.c
diff -u src/games/tetris/shapes.c:1.8 src/games/tetris/shapes.c:1.8.22.1
--- src/games/tetris/shapes.c:1.8 Mon May 25 04:33:53 2009
+++ src/games/tetris/shapes.c Sun Aug 10 06:51:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: shapes.c,v 1.8 2009/05/25 04:33:53 dholland Exp $ */
+/* $NetBSD: shapes.c,v 1.8.22.1 2014/08/10 06:51:14 tls 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;
Index: src/games/tetris/tetris.6
diff -u src/games/tetris/tetris.6:1.11 src/games/tetris/tetris.6:1.11.60.1
--- src/games/tetris/tetris.6:1.11 Thu Sep 15 02:09:42 2005
+++ src/games/tetris/tetris.6 Sun Aug 10 06:51:14 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: tetris.6,v 1.11 2005/09/15 02:09:42 wiz Exp $
+.\" $NetBSD: tetris.6,v 1.11.60.1 2014/08/10 06:51:14 tls Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -32,7 +32,7 @@
.\"
.\" @(#)tetris.6 8.1 (Berkeley) 5/31/93
.\"
-.Dd May 31, 1993
+.Dd July 13, 2014
.Dt TETRIS 6
.Os
.Sh NAME
@@ -40,7 +40,7 @@
.Nd the game of tetris
.Sh SYNOPSIS
.Nm
-.Op Fl ps
+.Op Fl bps
.Op Fl k Ar keys
.Op Fl l Ar level
.Sh DESCRIPTION
@@ -73,6 +73,11 @@ quit
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl b
+By default, shapes are displayed colorfully if the user's CRT supports color.
+The
+.Fl b
+option can be used to restore the traditional black-and-white behavior.
.It Fl k
The default control keys can be changed using the
.Fl k
Index: src/games/tetris/tetris.c
diff -u src/games/tetris/tetris.c:1.24 src/games/tetris/tetris.c:1.24.18.1
--- src/games/tetris/tetris.c:1.24 Wed Aug 31 16:24:56 2011
+++ src/games/tetris/tetris.c Sun Aug 10 06:51:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tetris.c,v 1.24 2011/08/31 16:24:56 plunky Exp $ */
+/* $NetBSD: tetris.c,v 1.24.18.1 2014/08/10 06:51:14 tls Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -73,6 +73,7 @@ gid_t gid, egid;
char key_msg[100];
int showpreview;
+int nocolor;
static void elide(void);
static void setup_board(void);
@@ -92,7 +93,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;
}
/*
@@ -144,8 +145,11 @@ main(int argc, char *argv[])
keys = "jkl pq";
- while ((ch = getopt(argc, argv, "k:l:ps")) != -1)
+ while ((ch = getopt(argc, argv, "bk:l:ps")) != -1)
switch(ch) {
+ case 'b':
+ nocolor = 1;
+ break;
case 'k':
if (strlen(keys = optarg) != 6)
usage();
Index: src/games/tetris/tetris.h
diff -u src/games/tetris/tetris.h:1.12 src/games/tetris/tetris.h:1.12.22.1
--- src/games/tetris/tetris.h:1.12 Wed Aug 12 08:51:21 2009
+++ src/games/tetris/tetris.h Sun Aug 10 06:51:14 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tetris.h,v 1.12 2009/08/12 08:51:21 dholland Exp $ */
+/* $NetBSD: tetris.h,v 1.12.22.1 2014/08/10 06:51:14 tls Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -123,6 +123,7 @@ extern int Rows, Cols; /* current screen
* 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) */
};
@@ -167,6 +168,7 @@ extern gid_t gid, egid;
extern char key_msg[100];
extern int showpreview;
+extern int nocolor;
int fits_in(const struct shape *, int);
void place(const struct shape *, int, int);