netris version 0.4 v0.4
authorMark Weaver <mhw@netris.org>
Sat, 10 Feb 1996 10:41:39 +0000 (10:41 +0000)
committerMischa POSLAWSKY <netris@shiar.org>
Mon, 16 Mar 2009 17:26:02 +0000 (18:26 +0100)
14 files changed:
Configure
FAQ
README
VERSION
board.c
curses.c
game.c
inet.c
netris.h
robot.c
robot_desc
shapes.c
sr.c
util.c

index 254366509539118bcae013ea0a5070ca9385bb65..7fe293ee71df458b7a55a0cff0c80378274614cb 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1,7 +1,7 @@
 :
 #
 :
 #
-# Netris -- A free networked version of Tetris
-# Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+# Netris -- A free networked version of T*tris
+# Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -17,7 +17,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
-# $Id: Configure,v 1.16 1995/07/11 08:55:42 mhw Exp $
+# $Id: Configure,v 1.17 1996/02/09 08:22:03 mhw Exp $
 #
 
 CC="gcc"
 #
 
 CC="gcc"
@@ -255,3 +255,5 @@ cat << END
 Now do a 'make'
 
 END
 Now do a 'make'
 
 END
+
+# vi: ts=4 ai
diff --git a/FAQ b/FAQ
index 9dd05196d016e19a15fcb1a78157412fcca56039..18a203c37b49497c105e27f566764df305b22442 100644 (file)
--- a/FAQ
+++ b/FAQ
@@ -2,11 +2,11 @@
 # Netris
 # Frequently asked questions
 #
 # Netris
 # Frequently asked questions
 #
-# $Id: FAQ,v 1.1 1995/07/11 07:50:43 mhw Exp $
+# $Id: FAQ,v 1.3 1996/02/09 08:47:23 mhw Exp $
 #
 
 #
 
-Contents
-========
+Questions
+=========
 [1] Where can I find the latest version?
 [2] The pieces look bizarre in my xterm window, and don't erase
     properly.  What's up?
 [1] Where can I find the latest version?
 [2] The pieces look bizarre in my xterm window, and don't erase
     properly.  What's up?
@@ -17,22 +17,21 @@ Contents
     -c player?
 [6] I'm using a slow terminal, and the game response is sluggish.
     What can I do?
     -c player?
 [6] I'm using a slow terminal, and the game response is sluggish.
     What can I do?
+[7] Why can't my terminal hide the cursor?
 
 Answers
 =======
 [1] Where can I find the latest version?
 
 
 Answers
 =======
 [1] Where can I find the latest version?
 
-    My machine doesn't currently have a constant hostname, but you can
-    usually find the hostname from `finger mhw@cs.brown.edu`, at least
-    until the Fall of 1995.
+    ftp://ftp.netris.org/pub/netris/
 
 
-    If you find my machine, you can get the latest version via
-    anonymous ftp from the /pub directory.  If anonymous ftp isn't
-    working, it's probably not my machine, so please don't badger it
-    with lots of retry attempts.
-
-    Unfortunately that is not a permanent site.  If that machine
-    doesn't exist, try mailing me.
+    The latest version is available via anonymous ftp from
+    ftp.netris.org in /pub/netris.
+    
+    Unfortunately this machine is currently on the far end of a
+    14.4kbps modem connection, and may go away at any time without
+    notice, but I'll do my best to keep it up.  If you have trouble
+    contacting the ftp server, try mailing me at <mhw@netris.org>.
 
 [2] The pieces look bizarre in my xterm window, and don't erase
     properly.  What's up?
 
 [2] The pieces look bizarre in my xterm window, and don't erase
     properly.  What's up?
@@ -91,7 +90,23 @@ Answers
 
     Try the -S option.  This disables use of standout mode (bold/inverse),
     which require control sequences to be sent twice (or more) per line.
 
     Try the -S option.  This disables use of standout mode (bold/inverse),
     which require control sequences to be sent twice (or more) per line.
-    This looks nice, but can make the game unplayable on a slow terminal.
+    Standout mode makes the pieces look much more like blocks, but can
+    make the game unplayable on a slow terminal.
 
     Also, you can type 's' to toggle spying (updating your view of the
     opponent's board).
 
     Also, you can type 's' to toggle spying (updating your view of the
     opponent's board).
+
+[7] Why can't my terminal hide the cursor?
+
+    Netris uses the termcap library to look up the "vi" and "ve"
+    capabilities, which make the cursor invisible/visible
+    respectively.  These capabilities aren't very consistently
+    reported among un*xes, so I use compiled-in vt220 codes for
+    several vt100-like terminals.  Most emulators probably won't
+    support the codes, but they'll probably ignore them quietly.
+
+    Try setting the TERM environment variable to "vt100" or "vt220"
+    before running Netris.  If that doesn't work, your terminal
+    probably doesn't support cursor invisibility.
+
+# vi: tw=70 ai
diff --git a/README b/README
index ce6613138a6027b421ac18fdd9ee9cd1a128f27d..fc7d1558be58b92f24717e99e7d010e7ca19b400 100644 (file)
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
 #
 #
-# Netris -- A free networked version of Tetris
-# Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+# Netris -- A free networked version of T*tris
+# Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
-# $Id: README,v 1.19 1995/07/11 07:50:45 mhw Exp $
+# $Id: README,v 1.20 1996/02/09 08:22:06 mhw Exp $
 #
 
 This is an unfinished developmental version of Netris, a free
 #
 
 This is an unfinished developmental version of Netris, a free
-networked version of Tetris.  It is distributed under the terms
+networked version of T*tris.  It is distributed under the terms
 of the GNU General Public License, which is described in the
 file "COPYING" included with this distribution.
 
 of the GNU General Public License, which is described in the
 file "COPYING" included with this distribution.
 
@@ -30,18 +30,32 @@ you are on your own.
 
 It's been built and tested on at least the following systems:
 
 
 It's been built and tested on at least the following systems:
 
-    NetBSD-1.0
-    NetBSD-current July 9, 1995
+    NetBSD 1.0, 1.1
     Linux
     Linux
-    SunOS 4.1.1, 4.1.3, 5.3
+    SunOS 4.1.1, 4.1.3
+    Solaris 2.3, 2.4
     HP-UX
 
 If Netris doesn't build on your favorite system "out-of-the-box",
 I encourage you to mail me context diffs to fix the problem so I
 can fold it into the next version.
 
     HP-UX
 
 If Netris doesn't build on your favorite system "out-of-the-box",
 I encourage you to mail me context diffs to fix the problem so I
 can fold it into the next version.
 
+Netris should build cleanly on 64-bit systems such as the Alpha,
+although you might need to edit the definitions for netint{2,4},
+hton{2,4}, and ntoh{2,4} in netris.h.  Alpha users, please let me know
+how it goes, and send me diffs if needed!
+
 See the FAQ in this directory if you have any problems.
 
 See the FAQ in this directory if you have any problems.
 
+
+NEW IN VERSION 0.4
+==================
+- Netris now attempts to make the cursor invisible for terminals that
+  support it.  Xterm no, vt220 yes, vt100 maybe?
+- Ctrl-L (by default) will now redraw the screen.
+- Various cleanup and documentation changes.
+
+
 INSTALLATION
 ============
 1. Run "./Configure" to create a Makefile and config.h appropriate
 INSTALLATION
 ============
 1. Run "./Configure" to create a Makefile and config.h appropriate
@@ -53,26 +67,27 @@ INSTALLATION
 
 Try "./Configure -h" for more options
 
 
 Try "./Configure -h" for more options
 
+
 RUNNING
 =======
 To start a two-player game, do the following:
  1. Player 1 types "netris -w".  This means "wait for challenge".
  2. Player 2 types "netris -c <host>" where <host> is the hostname
 RUNNING
 =======
 To start a two-player game, do the following:
  1. Player 1 types "netris -w".  This means "wait for challenge".
  2. Player 2 types "netris -c <host>" where <host> is the hostname
-    of Player 1.  This means "challenge".  Player 1 must be waiting
-    when this command is typed.
+    of Player 1.  This means "challenge".
 
 To start a one-player game, run netris with no parameters.
 One-player mode is a tad boring at the moment, because it never
 gets any faster, and there's no scoring.  This will be rectified
 
 To start a one-player game, run netris with no parameters.
 One-player mode is a tad boring at the moment, because it never
 gets any faster, and there's no scoring.  This will be rectified
-at some point.
-
-To get usage, type "netris -h".
-To use a port number other than the default, use the -p option.
-To provide compatibility with the older protocol version, use
-  the -o option.
+at some point.  For now, use the "f" key (by default) to make the
+game go faster.  Speedups cannot be reversed for the remainder of
+the game.
 
 
-I plan on implementing a server that Netris players can connect to
-to find other players with similar skill across the globe.
+Unlike standard T*tris, Netris gives you a little extra time after
+dropping a piece before it solidifies.  This allows you to slide the
+piece into a notch without waiting for it to fall the whole way down.
+In fact, if you can even slide it off a cliff and it'll start falling
+again.  If you think it should automatically drop again in this case,
+use the -D option.
 
 The keys are:
  'j'    left
 
 The keys are:
  'j'    left
@@ -82,10 +97,36 @@ The keys are:
  'm'    down faster
  's'   toggle spying on the other player
  'p'   pause
  'm'    down faster
  's'   toggle spying on the other player
  'p'   pause
- 'f'   make game faster
+ 'f'   make game faster (irreversable)
+ Ctrl-L        redraw the screen
 
 
-You can remap the keys using the -k option.  The default is:
-    netris -k "jkl mspf"
+To see usage information, type "netris -h".
+To see distribution/warranty information, type "netris -H".
+To see the rules, type "netris -R".
+To use a port number other than the default, use the -p option.
 
 
-This version now at least partially supports robots.  A rough description
+You can remap the keys with "-k <keys>", where <keys> is a string
+containing the keys in the order listed above.  The default is:
+    netris -k "jkl mspf^l"
+
+You needn't specify all of the keys, for example -k "asd" will only
+change the main three keys.  "^x" notation can be used for control
+characters.
+
+The "m" key moves the falling piece down one block, in addition to the
+usual step-down timer.  Use this in repetition when "drop" would go
+too far but you don't want to wait for the piece of fall.
+
+
+RUMORS
+======
+At some point I may implement a server that Netris players can connect
+to to find other players with similar skill across the globe.
+
+This version at least partially supports robots.  A rough description
 of the protocol is in "robot_desc", and a sample robot is in sr.c.
 of the protocol is in "robot_desc", and a sample robot is in sr.c.
+
+The source code should be viewed with tab stops set every 4 columns,
+eg, "less -x4 game.c".
+
+# vi: tw=70 ai
diff --git a/VERSION b/VERSION
index be586341736ee60d6ca2be0f3762a307e8fe79f9..bd73f47072b1fe4b9914ec14a7f6d47fcc8f816a 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3
+0.4
diff --git a/board.c b/board.c
index 97f1124fe318bda0ffdd10b5b304472900005b7a..125cdd0000768d3e519b9a34d4b07bd49fc7f194 100644 (file)
--- a/board.c
+++ b/board.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: board.c,v 1.13 1995/07/11 08:53:20 mhw Exp $
+ * $Id: board.c,v 1.14 1996/02/09 08:22:08 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -241,3 +241,7 @@ ExtFunc void InsertJunk(int scr, int count, int column)
        curY[scr] += count;
 }
 
        curY[scr] += count;
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
index 2d9390064446c9b8244e2627cc7e4a2d413d7a11..047efa4bc496de98ca707516db7cc60d53fb8c07 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: curses.c,v 1.29 1995/07/11 08:53:21 mhw Exp $
+ * $Id: curses.c,v 1.32 1996/02/09 08:47:25 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -35,22 +35,34 @@ static EventGenRec keyGen =
 static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS];
 static int statusYPos, statusXPos;
 
 static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS];
 static int statusYPos, statusXPos;
 
+static char *term_vi;  /* String to make cursor invisible */
+static char *term_ve;  /* String to make cursor visible */
+
 ExtFunc void InitScreens(void)
 {
        MySigSet oldMask;
 
 ExtFunc void InitScreens(void)
 {
        MySigSet oldMask;
 
+       GetTermcapInfo();
+
+       /*
+        * Do this atomically.  Otherwise a badly timed Ctrl-C during
+        * initialization will leave your terminal in a bad state.
+        */
        BlockSignals(&oldMask, SIGINT, 0);
        initscr();
        AtExit(CleanupScreens);
        RestoreSignals(NULL, &oldMask);
        BlockSignals(&oldMask, SIGINT, 0);
        initscr();
        AtExit(CleanupScreens);
        RestoreSignals(NULL, &oldMask);
+
        cbreak();
        noecho();
        cbreak();
        noecho();
+       OutputTermStr(term_vi, 0);
        AddEventGen(&keyGen);
        AddEventGen(&keyGen);
+
        move(0, 0);
        addstr("Netris ");
        addstr(version_string);
        move(0, 0);
        addstr("Netris ");
        addstr(version_string);
-       addstr(" (C) 1994,1995  Mark Weaver         "
-               "\"netris -h\" for more info");
+       addstr(" (C) 1994,1995,1996  Mark H. Weaver     "
+                       "\"netris -h\" for more info");
        statusYPos = 22;
        statusXPos = 0;
 }
        statusYPos = 22;
        statusXPos = 0;
 }
@@ -59,6 +71,72 @@ ExtFunc void CleanupScreens(void)
 {
        RemoveEventGen(&keyGen);
        endwin();
 {
        RemoveEventGen(&keyGen);
        endwin();
+       OutputTermStr(term_ve, 1);
+}
+
+ExtFunc void GetTermcapInfo(void)
+{
+       char *term, *buf, *data;
+       int bufSize = 10240;
+
+       if (!(term = getenv("TERM")))
+               return;
+       if (tgetent(scratch, term) == 1) {
+               /*
+                * Make the buffer HUGE, since tgetstr is unsafe.
+                * Allocate it on the heap too.
+                */
+               data = buf = malloc(bufSize);
+
+               /*
+                * There is no standard include file for tgetstr, no prototype
+                * definitions.  I like casting better than using my own prototypes
+                * because if I guess the prototype, I might be wrong, especially
+                * with regards to "const".
+                */
+               term_vi = (char *)tgetstr("vi", &data);
+               term_ve = (char *)tgetstr("ve", &data);
+
+               /* Okay, so I'm paranoid; I just don't like unsafe routines */
+               if (data > buf + bufSize)
+                       fatal("tgetstr overflow, you must have a very sick termcap");
+
+               /* Trim off the unused portion of buffer */
+               buf = realloc(buf, data - buf);
+       }
+
+       /*
+        * If that fails, use hardcoded vt220 codes.
+        * They don't seem to do anything bad on vt100's, so
+        * we'll try them just in case they work.
+        */
+       if (!term_vi || !term_ve) {
+               static char *vts[] = {
+                               "vt100", "vt101", "vt102",
+                               "vt200", "vt220", "vt300",
+                               "vt320", "vt400", "vt420",
+                               "screen", "xterm", NULL };
+               int i;
+
+               for (i = 0; vts[i]; i++)
+                       if (!strcmp(term, vts[i]))
+                       {
+                               term_vi = "\033[?25l";
+                               term_ve = "\033[?25h";
+                               break;
+                       }
+       }
+       if (!term_vi || !term_ve)
+               term_vi = term_ve = NULL;
+}
+
+ExtFunc void OutputTermStr(char *str, int flush)
+{
+       if (str) {
+               fputs(str, stdout);
+               if (flush)
+                       fflush(stdout);
+       }
 }
 
 ExtFunc void InitScreen(int scr)
 }
 
 ExtFunc void InitScreen(int scr)
@@ -133,10 +211,10 @@ ExtFunc void PlotUnderline(int scr, int x, int flag)
 ExtFunc void ShowDisplayInfo(void)
 {
        move(statusYPos - 9, statusXPos);
 ExtFunc void ShowDisplayInfo(void)
 {
        move(statusYPos - 9, statusXPos);
-       printw("Seed = %d", initSeed);
+       printw("Seed: %d", initSeed);
        clrtoeol();
        move(statusYPos - 8, statusXPos);
        clrtoeol();
        move(statusYPos - 8, statusXPos);
-       printw("Speed = %dms", speed / 1000);
+       printw("Speed: %dms", speed / 1000);
        clrtoeol();
        if (robotEnable) {
                move(statusYPos - 6, statusXPos);
        clrtoeol();
        if (robotEnable) {
                move(statusYPos - 6, statusXPos);
@@ -207,6 +285,11 @@ ExtFunc void RefreshScreen(void)
        refresh();
 }
 
        refresh();
 }
 
+ExtFunc void ScheduleFullRedraw(void)
+{
+       touchwin(stdscr);
+}
+
 static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event)
 {
        if (MyRead(gen->fd, &event->u.key, 1))
 static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event)
 {
        if (MyRead(gen->fd, &event->u.key, 1))
@@ -215,3 +298,7 @@ static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event)
                return E_none;
 }
 
                return E_none;
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
diff --git a/game.c b/game.c
index 82c03bfcd56d2e6b95ec9bdc387b83aa47c823f5..26ab6a8f72496f0e20f8a2fff416bc2a44c84da3 100644 (file)
--- a/game.c
+++ b/game.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: game.c,v 1.37 1995/07/11 08:53:23 mhw Exp $
+ * $Id: game.c,v 1.38 1996/02/09 08:22:11 mhw Exp $
  */
 
 #define NOEXT
  */
 
 #define NOEXT
 #include <sys/types.h>
 #include <netinet/in.h>
 
 #include <sys/types.h>
 #include <netinet/in.h>
 
-enum { KT_left, KT_rotate, KT_right, KT_drop,
-       KT_down, KT_toggleSpy, KT_pause, KT_faster, KT_numKeys };
+enum { KT_left, KT_rotate, KT_right, KT_drop, KT_down,
+       KT_toggleSpy, KT_pause, KT_faster, KT_redraw, KT_numKeys };
 
 static char *keyNames[KT_numKeys+1] = {
        "Left", "Rotate", "Right", "Drop", "Down", "ToggleSpy", "Pause",
 
 static char *keyNames[KT_numKeys+1] = {
        "Left", "Rotate", "Right", "Drop", "Down", "ToggleSpy", "Pause",
-       "Faster", NULL };
+       "Faster", "Redraw", NULL };
 
 static char *gameNames[GT_len] = { "OnePlayer", "ClassicTwo" };
 
 
 static char *gameNames[GT_len] = { "OnePlayer", "ClassicTwo" };
 
-static char keyTable[KT_numKeys+1] = "jkl mspf";
+static char keyTable[KT_numKeys+1];
 static int dropModeEnable = 0;
 static char *robotProg;
 
 static int dropModeEnable = 0;
 static char *robotProg;
 
+ExtFunc void MapKeys(char *newKeys)
+{
+       int i, k, ch;
+       char used[256];
+       int errs = 0;
+
+       /* XXX assumptions about ASCII encoding here */
+       for (i = k = 0; newKeys[i] && k < KT_numKeys; i++,k++) {
+               if (newKeys[i] == '^' && newKeys[i+1])
+                       keyTable[k] = toupper(newKeys[++i]) - ('A' - 1);
+               else
+                       keyTable[k] = newKeys[i];
+       }
+       memset(used, 0, sizeof(used));
+       for (k = 0; k < KT_numKeys; k++) {
+               ch = (unsigned char) keyTable[k];
+               if (used[ch]) {
+                       if (iscntrl(ch) && ch < ' ')
+                               sprintf(scratch, "Ctrl-%c", ch + ('A' - 1));
+                       else if (isprint(ch))
+                               sprintf(scratch, "\"%c\"", ch);
+                       else
+                               sprintf(scratch, "0x%X", ch);
+                       if (!errs)
+                               fprintf(stderr, "Duplicate key mappings:\n");
+                       errs++;
+                       fprintf(stderr, "  %s mapped to both %s and %s\n",
+                                       scratch, keyNames[used[ch]-1], keyNames[k]);
+               }
+               used[ch] = k + 1;
+       }
+       if (errs)
+               exit(1);
+}
+
 ExtFunc int StartNewPiece(int scr, Shape *shape)
 {
        curShape[scr] = shape;
 ExtFunc int StartNewPiece(int scr, Shape *shape)
 {
        curShape[scr] = shape;
@@ -131,7 +166,7 @@ ExtFunc void OneGame(int scr, int scr2)
                                        if (!p)
                                                break;
                                keyEvent:
                                        if (!p)
                                                break;
                                keyEvent:
-                                       if (paused && (key != KT_pause))
+                                       if (paused && (key != KT_pause) && (key != KT_redraw))
                                                break;
                                        switch(key) {
                                                case KT_left:
                                                break;
                                        switch(key) {
                                                case KT_left:
@@ -184,6 +219,11 @@ ExtFunc void OneGame(int scr, int scr2)
                                                        ShowDisplayInfo();
                                                        changed = 1;
                                                        break;
                                                        ShowDisplayInfo();
                                                        changed = 1;
                                                        break;
+                                               case KT_redraw:
+                                                       ScheduleFullRedraw();
+                                                       if (paused)
+                                                               RefreshScreen();
+                                                       break;
                                        }
                                        if (dropMode && DropPiece(scr) > 0) {
                                                if (spied)
                                        }
                                        if (dropMode && DropPiece(scr) > 0) {
                                                if (spied)
@@ -321,6 +361,7 @@ ExtFunc int main(int argc, char **argv)
 
        standoutEnable = 1;
        stepDownInterval = DEFAULT_INTERVAL;
 
        standoutEnable = 1;
        stepDownInterval = DEFAULT_INTERVAL;
+       MapKeys(DEFAULT_KEYS);
        while ((ch = getopt(argc, argv, "hHRs:r:Fk:c:woDSp:i:")) != -1)
                switch (ch) {
                        case 'c':
        while ((ch = getopt(argc, argv, "hHRs:r:Fk:c:woDSp:i:")) != -1)
                switch (ch) {
                        case 'c':
@@ -355,20 +396,15 @@ ExtFunc int main(int argc, char **argv)
                        case 'S':
                                standoutEnable = 0;
                                break;
                        case 'S':
                                standoutEnable = 0;
                                break;
+                       case 'k':
+                               MapKeys(optarg);
+                               break;
                        case 'H':
                                DistInfo();
                                exit(0);
                        case 'R':
                                Rules();
                                exit(0);
                        case 'H':
                                DistInfo();
                                exit(0);
                        case 'R':
                                Rules();
                                exit(0);
-                       case 'k':
-                       {
-                               int i;
-
-                               for (i=0;optarg[i] && i < KT_numKeys;i++)
-                                       keyTable[i] = optarg[i];
-                               break;
-                       }
                        case 'h':
                                Usage();
                                exit(0);
                        case 'h':
                                Usage();
                                exit(0);
@@ -492,3 +528,7 @@ ExtFunc int main(int argc, char **argv)
        return 0;
 }
 
        return 0;
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
diff --git a/inet.c b/inet.c
index 392231ea286741892aafc81066c737ad02a031f0..dbfe7484f0d8b9bb2a65f956ce9afc7e9d979bb5 100644 (file)
--- a/inet.c
+++ b/inet.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: inet.c,v 1.17 1995/07/11 08:53:25 mhw Exp $
+ * $Id: inet.c,v 1.18 1996/02/09 08:22:13 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -210,3 +210,7 @@ ExtFunc void CloseNet(void)
                RemoveEventGen(&netGen);
 }
 
                RemoveEventGen(&netGen);
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
index e5c69ec92291364fa0f5fd0c16cd315437045241..5864cf775872fbebb4f6a398632b53501ea99317 100644 (file)
--- a/netris.h
+++ b/netris.h
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: netris.h,v 1.26 1995/07/11 08:53:26 mhw Exp $
+ * $Id: netris.h,v 1.27 1996/02/09 08:22:14 mhw Exp $
  */
 
 #ifndef NETRIS_H
  */
 
 #ifndef NETRIS_H
@@ -65,6 +65,8 @@ typedef long netint4;
 
 #define DEFAULT_PORT 9284      /* Very arbitrary */
 
 
 #define DEFAULT_PORT 9284      /* Very arbitrary */
 
+#define DEFAULT_KEYS "jkl mspf^l"
+
 /* Protocol versions */
 #define MAJOR_VERSION          1       
 #define PROTOCOL_VERSION       3
 /* Protocol versions */
 #define MAJOR_VERSION          1       
 #define PROTOCOL_VERSION       3
@@ -172,3 +174,7 @@ extern char *version_string;
 
 #endif /* NETRIS_H */
 
 
 #endif /* NETRIS_H */
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
diff --git a/robot.c b/robot.c
index 7af5ab94b903be8d99361a772d4823088f6844d8..23875a3bd4b9984bf0c1815e95e7970c5f8318e2 100644 (file)
--- a/robot.c
+++ b/robot.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: robot.c,v 1.7 1995/07/11 08:53:28 mhw Exp $
+ * $Id: robot.c,v 1.8 1996/02/09 08:22:15 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -168,3 +168,7 @@ static MyEventType RobotGenFunc(EventGenRec *gen, MyEvent *event)
        return E_robot;
 }
 
        return E_robot;
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
index bcb52df56c7f07962caaa223081ce136b0d1b38c..01c697002a89b5db72576f33dceeafd12243375e 100644 (file)
@@ -1,4 +1,4 @@
-$Id: robot_desc,v 1.2 1994/12/12 22:42:42 mhw Exp $
+$Id: robot_desc,v 1.3 1996/02/09 08:22:16 mhw Exp $
 
 
 GENERAL PROTOCOL
 
 
 GENERAL PROTOCOL
@@ -220,3 +220,6 @@ lines sent to Netris are preceeded by "> ".
   TimeStamp 1.326
 [...]
   Exit
   TimeStamp 1.326
 [...]
   Exit
+
+
+# vi: tw=70 ai
index 45b2b5e780e8794314576dd9e022ac18b1d1ad3b..c62f69b2d827af4e45df5c0f0d381293fc41f1ce 100644 (file)
--- a/shapes.c
+++ b/shapes.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: shapes.c,v 1.14 1995/07/11 08:53:29 mhw Exp $
+ * $Id: shapes.c,v 1.15 1996/02/09 08:22:17 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -185,3 +185,7 @@ ExtFunc Shape *NetNumToShape(short num)
        return netMapping[num];
 }
 
        return netMapping[num];
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
diff --git a/sr.c b/sr.c
index d9b1172e32a71ad20580d07ef800e0f4cc9d0d5d..a5974fdc2375d54c5c54a06b4404878750bf8c06 100644 (file)
--- a/sr.c
+++ b/sr.c
@@ -1,6 +1,6 @@
 /*
  * sr -- A sample robot for Netris
 /*
  * sr -- A sample robot for Netris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: sr.c,v 1.9 1995/07/11 08:53:30 mhw Exp $
+ * $Id: sr.c,v 1.10 1996/02/09 08:22:20 mhw Exp $
  */
 
 #include <stdio.h>
  */
 
 #include <stdio.h>
@@ -468,3 +468,7 @@ int main(int argc, char **argv)
        return 0;
 }
 
        return 0;
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */
diff --git a/util.c b/util.c
index b52d7613f154c610840adc22734fb0987c7b8146..98248ed64e3ab11d625e6fa514325e2ae9c63146 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1,6 +1,6 @@
 /*
 /*
- * Netris -- A free networked version of Tetris
- * Copyright (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>
+ * Netris -- A free networked version of T*tris
+ * Copyright (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
- * $Id: util.c,v 1.26 1995/07/11 08:53:32 mhw Exp $
+ * $Id: util.c,v 1.27 1996/02/09 08:22:23 mhw Exp $
  */
 
 #include "netris.h"
  */
 
 #include "netris.h"
@@ -66,74 +66,77 @@ ExtFunc void AtExit(void (*handler)(void))
 ExtFunc void Usage(void)
 {
        fprintf(stderr,
 ExtFunc void Usage(void)
 {
        fprintf(stderr,
-               "Netris version %s (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>\n"
-               "Usage: netris <options>\n"
-               "  -h           Print usage information\n"
-               "  -w           Wait for connection\n"
-               "  -c <host>    Initiate connection\n"
-               "  -p <port>    Set port number (default is %d)\n"
-               "  -k <keys>    Remap keys.  The argument is a string containing\n"
-               "                 the keys in order: left, rotate, right, drop,\n"
-               "                 down-faster, toggle-spying, pause\n"
-               "  -i <sec>     Set the step-down interval, in seconds\n"
-               "  -r <robot>   Execute <robot> (a command) as a robot controlling\n"
-               "                 the game instead of the keyboard\n"
-               "  -F           Use fair robot interface\n"
-               "  -s <seed>    Start with given random seed\n"
-               "  -D           Drops go into drop mode\n"
-               "                 This means that sliding off a cliff after a drop causes\n"
-               "                 another drop automatically\n"
-               "  -S           Disable standout mode (inverse/bold) for slow terminals\n"
-               "  -H           Show distribution and warranty information\n"
-               "  -R           Show rules\n",
-               version_string, DEFAULT_PORT);
+         "Netris version %s (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>\n"
+         "Usage: netris <options>\n"
+         "  -h         Print usage information\n"
+         "  -w         Wait for connection\n"
+         "  -c <host>  Initiate connection\n"
+         "  -p <port>  Set port number (default is %d)\n"
+         "  -k <keys>  Remap keys.  The argument is a prefix of the string\n"
+         "               containing the keys in order: left, rotate, right, drop,\n"
+         "               down-faster, toggle-spying, pause, faster, redraw.\n"
+         "               \"^\" prefixes controls.  (default is \"%s\")\n"
+         "  -i <sec>   Set the step-down interval, in seconds\n"
+         "  -r <robot> Execute <robot> (a command) as a robot controlling\n"
+         "               the game instead of the keyboard\n"
+         "  -F         Use fair robot interface\n"
+         "  -s <seed>  Start with given random seed\n"
+         "  -D         Drops go into drop mode\n"
+         "               This means that sliding off a cliff after a drop causes\n"
+         "               another drop automatically\n"
+         "  -S         Disable standout mode (inverse/bold) for slow terminals\n"
+         "  -H         Show distribution and warranty information\n"
+         "  -R         Show rules\n",
+         version_string, DEFAULT_PORT, DEFAULT_KEYS);
 }
 
 ExtFunc void DistInfo(void)
 {
        fprintf(stderr,
 }
 
 ExtFunc void DistInfo(void)
 {
        fprintf(stderr,
-               "Netris version %s (C) 1994,1995  Mark Weaver <Mark_Weaver@brown.edu>\n"
-               "\n"
-               "This program is free software; you can redistribute it and/or modify\n"
-               "it under the terms of the GNU General Public License as published by\n"
-               "the Free Software Foundation; either version 2 of the License, or\n"
-               "(at your option) any later version.\n"
-               "\n"
-               "This program is distributed in the hope that it will be useful,\n"
-               "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-               "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-               "GNU General Public License for more details.\n"
-               "\n"
-               "You should have received a copy of the GNU General Public License\n"
-               "along with this program; if not, write to the Free Software\n"
-               "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n",
-               version_string);
+         "Netris version %s (C) 1994,1995,1996  Mark H. Weaver <mhw@netris.org>\n"
+         "\n"
+         "This program is free software; you can redistribute it and/or modify\n"
+         "it under the terms of the GNU General Public License as published by\n"
+         "the Free Software Foundation; either version 2 of the License, or\n"
+         "(at your option) any later version.\n"
+         "\n"
+         "This program is distributed in the hope that it will be useful,\n"
+         "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+         "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
+         "GNU General Public License for more details.\n"
+         "\n"
+         "You should have received a copy of the GNU General Public License\n"
+         "along with this program; if not, write to the Free Software\n"
+         "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n",
+         version_string);
 }
 
 ExtFunc void Rules(void)
 {
        fprintf(stderr,
 }
 
 ExtFunc void Rules(void)
 {
        fprintf(stderr,
-               "Netris version %s rules\n"
-               "\n"
-               "Two player mode\n"
-               "---------------\n"
-               "It's just like normal Tetris except that when you clear more than\n"
-               "one row with a single piece, the other player's board is moved up\n"
-               "and junk rows are added to the bottom.  If you clear 2, 3 or 4\n"
-               "rows, 1, 2 or 4 junk rows are added to your opponent's board,\n"
-               "respectively.  The junk rows have exactly one empty column.\n"
-               "For each group of junk rows given, the empty columns will line\n"
-               "up.  This is intentional.\n"
-               "\n"
-               "The longest surviving player wins the game.\n"
-               "\n"
-               "One player mode\n"
-               "---------------\n"
-               "This mode is currently very boring, because there's no scoring\n"
-               "and it never gets any faster.  This will be rectified at some point.\n"
-               "I'm not very motivated to do it right now because I'm sick of one\n"
-               "player Tetris.\n",
-               version_string);
+         "Netris version %s rules\n"
+         "\n"
+         "Two player mode\n"
+         "---------------\n"
+         "It's just like normal T*tris except that when you clear more than\n"
+         "one row with a single piece, the other player's board is moved up\n"
+         "and junk rows are added to the bottom.  If you clear 2, 3 or 4\n"
+         "rows, 1, 2 or 4 junk rows are added to your opponent's board,\n"
+         "respectively.  The junk rows have exactly one empty column.\n"
+         "For each group of junk rows given, the empty columns will line\n"
+         "up.  This is intentional.\n"
+         "\n"
+         "The longest surviving player wins the game.\n"
+         "\n"
+         "One player mode\n"
+         "---------------\n"
+         "This mode is currently very boring, because there's no scoring\n"
+         "and it never gets any faster.  This will be rectified at some point.\n"
+         "I'm not very motivated to do it right now because I'm sick of one\n"
+         "player T*tris.  For now, use the \"f\" key (by default) to make the\n"
+         "game go faster.  Speedups cannot be reversed for the remainder of\n"
+         "the game.\n",
+         version_string);
 }
 
 /*
 }
 
 /*
@@ -376,3 +379,7 @@ ExtFunc MyEventType WaitMyEvent(MyEvent *event, int mask)
        }
 }
 
        }
 }
 
+/*
+ * vi: ts=4 ai
+ * vim: noai si
+ */