summaryrefslogtreecommitdiffstats
path: root/tetris/screen.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2014-06-11 16:47:39 +0000
committerchristos <christos@NetBSD.org>2014-06-11 16:47:39 +0000
commit1033fba35c308f3253abd40f163d7c52ef7ac5fb (patch)
tree7188b5503b94cde1c8280e6c0336559d7a778bea /tetris/screen.c
parentdb7a726b9bff1bdf1fbba8c65d338e1236f854bb (diff)
downloadbsdgames-darwin-1033fba35c308f3253abd40f163d7c52ef7ac5fb.tar.gz
bsdgames-darwin-1033fba35c308f3253abd40f163d7c52ef7ac5fb.tar.zst
bsdgames-darwin-1033fba35c308f3253abd40f163d7c52ef7ac5fb.zip
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.
Diffstat (limited to 'tetris/screen.c')
-rw-r--r--tetris/screen.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/tetris/screen.c b/tetris/screen.c
index 2d58303b..50a019d3 100644
--- a/tetris/screen.c
+++ b/tetris/screen.c
@@ -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;