From 1033fba35c308f3253abd40f163d7c52ef7ac5fb Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 11 Jun 2014 16:47:39 +0000 Subject: 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. --- tetris/screen.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tetris/screen.c') 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; -- cgit v1.2.3-56-ge451