Index: uspace/app/tetris/screen.c
===================================================================
--- uspace/app/tetris/screen.c	(revision 0c25c10b972ef53d852bb84a0277997565177111)
+++ uspace/app/tetris/screen.c	(revision f3afd24a0d1153d9f334ec48804a551d363339fd)
@@ -37,5 +37,5 @@
 
 /** @addtogroup tetris
- * @{ 
+ * @{
  */
 /** @file
@@ -57,7 +57,11 @@
 #include <io/console.h>
 
-static cell curscreen[B_SIZE];	/* 1 => standout (or otherwise marked) */
+#define STOP  (B_COLS - 3)
+
+static cell curscreen[B_SIZE];  /* non-zero => standout (or otherwise marked) */
 static int curscore;
-static int isset;		/* true => terminal is in game mode */
+static int isset;               /* true => terminal is in game mode */
+
+static const struct shape *lastshape;
 
 
@@ -72,7 +76,7 @@
 }
 
-static void start_standout(void)
-{
-	console_set_rgb_color(fphone(stdout), 0xf0f0f0, 0);
+static void start_standout(uint32_t color)
+{
+	console_set_rgb_color(fphone(stdout), 0xf0f0f0, color);
 }
 
@@ -91,12 +95,10 @@
  * Clear the screen, forgetting the current contents in the process.
  */
-void
-scr_clear(void)
-{
-
+void scr_clear(void)
+{
 	resume_normal();
 	console_clear(fphone(stdout));
 	curscore = -1;
-	memset((char *)curscreen, 0, sizeof(curscreen));
+	memset(curscreen, 0, sizeof(curscreen));
 }
 
@@ -104,6 +106,5 @@
  * Set up screen
  */
-void
-scr_init(void)
+void scr_init(void)
 {
 	console_cursor_visibility(fphone(stdout), 0);
@@ -127,17 +128,19 @@
  * Set up screen mode.
  */
-void
-scr_set(void)
+void scr_set(void)
 {
 	winsize_t ws;
-
-	Rows = 0, Cols = 0;
+	
+	Rows = 0;
+	Cols = 0;
+	
 	if (get_display_size(&ws) == 0) {
 		Rows = ws.ws_row;
 		Cols = ws.ws_col;
 	}
-	if (Rows < MINROWS || Cols < MINCOLS) {
+	
+	if ((Rows < MINROWS) || (Cols < MINCOLS)) {
 		char smallscr[55];
-
+		
 		snprintf(smallscr, sizeof(smallscr),
 		    "the screen is too small (must be at least %dx%d)",
@@ -146,5 +149,5 @@
 	}
 	isset = 1;
-
+	
 	scr_clear();
 }
@@ -153,33 +156,33 @@
  * End screen mode.
  */
-void
-scr_end(void)
-{
-}
-
-void
-stop(char *why)
-{
-
+void scr_end(void)
+{
+	console_cursor_visibility(fphone(stdout), 1);
+}
+
+void stop(char *why)
+{
 	if (isset)
 		scr_end();
+	
 	errx(1, "aborting: %s", why);
 }
 
-
 /*
  * Update the screen.
  */
-void
-scr_update(void)
-{
-	cell *bp, *sp;
-	cell so, cur_so = 0;
-	int i, ccol, j;
-	static const struct shape *lastshape;
-
-	/* always leave cursor after last displayed point */
+void scr_update(void)
+{
+	cell *bp;
+	cell *sp;
+	cell so;
+	cell cur_so = 0;
+	int i;
+	int j;
+	int ccol;
+	
+	/* Always leave cursor after last displayed point */
 	curscreen[D_LAST * B_COLS - 1] = -1;
-
+	
 	if (score != curscore) {
 		moveto(0, 0);
@@ -187,25 +190,29 @@
 		curscore = score;
 	}
-
-	/* draw preview of next pattern */
-	if (showpreview && (nextshape != lastshape)) {
+	
+	/* Draw preview of next pattern */
+	if ((showpreview) && (nextshape != lastshape)) {
 		int i;
-		static int r=5, c=2;
+		static int r = 5, c = 2;
 		int tr, tc, t;
-
+		
 		lastshape = nextshape;
-
-		/* clean */
+		
+		/* Clean */
 		resume_normal();
-		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);
+		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 */
-		start_standout();
+		
+		/* Draw */
+		start_standout(nextshape->color);
 		moveto(r, 2 * c);
 		putstr("  ");
@@ -213,8 +220,8 @@
 			t = c + r * B_COLS;
 			t += nextshape->off[i];
-
+			
 			tr = t / B_COLS;
 			tc = t % B_COLS;
-
+			
 			moveto(tr, 2*tc);
 			putstr("  ");
@@ -222,5 +229,5 @@
 		resume_normal();
 	}
-
+	
 	bp = &board[D_FIRST * B_COLS];
 	sp = &curscreen[D_FIRST * B_COLS];
@@ -230,4 +237,5 @@
 			if (*sp == (so = *bp))
 				continue;
+			
 			*sp = so;
 			if (i != ccol) {
@@ -238,7 +246,8 @@
 				moveto(RTOD(j), CTOD(i));
 			}
+			
 			if (so != cur_so) {
 				if (so)
-					start_standout();
+					start_standout(so);
 				else
 					resume_normal();
@@ -246,5 +255,5 @@
 			}
 			putstr("  ");
-
+			
 			ccol = i + 1;
 			/*
@@ -256,10 +265,11 @@
 			 * the next cell is a different color.
 			 */
-#define	STOP (B_COLS - 3)
-			if (i > STOP || sp[1] != bp[1] || so != bp[1])
+			
+			if ((i > STOP) || (sp[1] != bp[1]) || (so != bp[1]))
 				continue;
+			
 			if (sp[2] != bp[2])
 				sp[1] = -1;
-			else if (i < STOP && so == bp[2] && sp[3] != bp[3]) {
+			else if ((i < STOP) && (so == bp[2]) && (sp[3] != bp[3])) {
 				sp[2] = -1;
 				sp[1] = -1;
@@ -267,20 +277,21 @@
 		}
 	}
+	
 	if (cur_so)
 		resume_normal();
- 	fflush(stdout);
-}
-
-/*
- * Write a message (set!=0), or clear the same message (set==0).
+	
+	fflush(stdout);
+}
+
+/*
+ * Write a message (set != 0), or clear the same message (set == 0).
  * (We need its length in case we have to overwrite with blanks.)
  */
-void
-scr_msg(char *s, int set)
-{
-	
+void scr_msg(char *s, int set)
+{
 	int l = str_size(s);
 	
 	moveto(Rows - 2, ((Cols - l) >> 1) - 1);
+	
 	if (set)
 		putstr(s);
@@ -292,3 +303,2 @@
 /** @}
  */
-
