dslinux/user/games/bsdgames/tetris tetris.c

stsp stsp at user.in-berlin.de
Thu Aug 17 01:17:12 CEST 2006


Update of /cvsroot/dslinux/dslinux/user/games/bsdgames/tetris
In directory antilope:/tmp/cvs-serv30781

Modified Files:
	tetris.c 
Log Message:
Make tetris use D-Pad and A and B buttons. Typing h, j etc.
on the keyboard with the stylus didn't exactly make it fun
to play.

Patch originally made by davr. Thanks heaps :)

Now if this tetris implementation only had online multi-player
support...


Index: tetris.c
===================================================================
RCS file: /cvsroot/dslinux/dslinux/user/games/bsdgames/tetris/tetris.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- tetris.c	22 Oct 2005 20:07:21 -0000	1.1
+++ tetris.c	16 Aug 2006 23:17:09 -0000	1.2
@@ -36,8 +36,8 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
-	The Regents of the University of California.  All rights reserved.\n");
+//__COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
+//he Regents of the University of California.  All rights reserved.\n");
 #endif /* not lint */
 
 /*
@@ -80,6 +80,8 @@
 	void	onintr(int) __attribute__((__noreturn__));
 	void	usage(void) __attribute__((__noreturn__));
 
+#define ASCII_ESC	27
+
 /*
  * Set up the initial board.  The bottom display row is completely set,
  * along with another (hidden) row underneath that.  Also, the left and
@@ -145,7 +147,7 @@
 		exit(1);
 	close(fd);
 
-	keys = "jkl pq";
+	keys = "DACBpq";
 
 	while ((ch = getopt(argc, argv, "k:l:ps")) != -1)
 		switch(ch) {
@@ -193,10 +195,7 @@
 		}
 	}
 
-	sprintf(key_msg,
-"%s - left   %s - rotate   %s - right   %s - drop   %s - pause   %s - quit",
-		key_write[0], key_write[1], key_write[2], key_write[3],
-		key_write[4], key_write[5]);
+	sprintf(key_msg, "\n%s - pause   %s - quit", key_write[4], key_write[5]);
 
 	(void)signal(SIGINT, onintr);
 	scr_init();
@@ -216,6 +215,12 @@
 		scr_update();
 		place(curshape, pos, 0);
 		c = tgetchar();
+                if(c == ASCII_ESC)
+                {
+                    c = tgetchar();
+                    if((c & 0xff) == '[')
+                        c = tgetchar();
+                }
 		if (c < 0) {
 			/*
 			 * Timeout.  Move down if possible.
@@ -274,7 +279,7 @@
 				pos--;
 			continue;
 		}
-		if (c == keys[1]) {
+		if (c == keys[1] || c == '\n') {
 			/* turn */
 			const struct shape *new = &shapes[curshape->rot];
 




More information about the dslinux-commit mailing list