:
#
# Netris -- A free networked version of T*tris
-# Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+# Copyright (C) 1994-1996,1999 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
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# $Id: Configure,v 1.17 1996/02/09 08:22:03 mhw Exp $
+# $Id: Configure,v 1.18 1999/05/16 06:56:19 mhw Exp $
#
CC="gcc"
COPT="-g -O"
CEXTRA=""
LEXTRA=""
+CURSES_HACK=false
while [ $# -ge 1 ]; do
opt="$1"
LEXTRA="$1"
shift
;;
+ --curses-hack)
+ CURSES_HACK=true
+ ;;
*)
cat << "END"
Usage: ./Configure [options...]
--copt <opt>: Set C optimization flags
--cextra <opt>: Set extra C flags
--lextra <opt>: Set extra linker flags
+ --curses-hack: Disable scroll-optimization for broken curses
END
exit 1
;;
echo "Checking for libraries"
echo 'main(){}' > test.c
LFLAGS=""
-for lib in -lsocket -lnsl -lcurses -ltermcap
-do
+for lib in -lcurses -lncurses; do
+ if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
+ LFLAGS="$lib"
+ fi
+done
+for lib in -lsocket -lnsl -ltermcap; do
if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
LFLAGS="$LFLAGS $lib"
fi
sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-SRCS-/$SRCS/g" \
-e "s/-OBJS-/$OBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
-e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
- -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" << "END" > Makefile
+ -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" \
+ << "END" > Makefile
#
# Automatically generated by ./Configure -- DO NOT EDIT!
#
if [ "$HAS_SIGPROCMASK" = "true" ]; then
echo "#define HAS_SIGPROCMASK" >> config.h
fi
+if [ "$CURSES_HACK" = "true" ]; then
+ echo "#define CURSES_HACK" >> config.h
+fi
echo "Running 'make depend'"
if make depend; then :; else cat << END; fi
# Netris
# Frequently asked questions
#
-# $Id: FAQ,v 1.3 1996/02/09 08:47:23 mhw Exp $
+# $Id: FAQ,v 1.4 1999/05/16 06:56:21 mhw Exp $
#
Questions
[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?
+[8] Occasionally when clearing a line, the display jerks, scrolling
+ very awkwardly. How can I fix it?
Answers
=======
before running Netris. If that doesn't work, your terminal
probably doesn't support cursor invisibility.
+[8] Occasionally when clearing a line, the display jerks, scrolling
+ very awkwardly. How can I fix it?
+
+ You can try running ./Configure with the "--curses-hack" option
+ and recompile. This utilizes a non-portable hack which will only
+ work with certain curses libraries, so it's disabled by default.
+
+ All screen updating is done by your curses library, which means
+ it's not something that Netris can control. Netris never tells
+ curses to scroll, but curses does so automatically in order to
+ optimize screen updates. This hack modifies curses's internal
+ variables, making it think that your terminal doesn't know how to
+ region-scroll.
+
+
# vi: tw=70 ai
#
# Netris -- A free networked version of T*tris
-# Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+# Copyright (C) 1994-1996,1999 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
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-# $Id: README,v 1.20 1996/02/09 08:22:06 mhw Exp $
+# $Id: README,v 1.21 1999/05/16 06:56:22 mhw Exp $
#
This is an unfinished developmental version of Netris, a free
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.
+file "COPYING" included with this distribution. For more
+information about GNU and the Free Software Foundation,
+check out <http://www.gnu.org/>.
In order to compile Netris you will need gcc. You may be able to
compile it with another ANSI C compiler, but if you attempt this
It's been built and tested on at least the following systems:
+ GNU/Linux
+ FreeBSD 2.1.5, 2.1.6, 2.2
NetBSD 1.0, 1.1
- Linux
SunOS 4.1.1, 4.1.3
Solaris 2.3, 2.4
HP-UX
See the FAQ in this directory if you have any problems.
-NEW IN VERSION 0.4
+NEW IN VERSION 0.5
==================
-- 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.
+Netris now specifically looks for ncurses and uses color if it's
+available, unless the -C option is given. Thanks to A.P.J. van Loo
+<cobra@multiweb.nl> for providing code which these changes are
+based on.
INSTALLATION
'm' down faster
's' toggle spying on the other player
'p' pause
- 'f' make game faster (irreversable)
+ 'f' make game faster (irreversible)
Ctrl-L redraw the screen
To see usage information, type "netris -h".
/*
* Netris -- A free networked version of T*tris
- * Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+ * Copyright (C) 1994-1996,1999 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
* 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.14 1996/02/09 08:22:08 mhw Exp $
+ * $Id: board.c,v 1.15 1999/05/16 06:56:24 mhw Exp $
*/
#include "netris.h"
CopyLine(scr, y, y + count);
for (y = 0; y < count; ++y)
for (x = 0; x < boardWidth[scr]; ++x)
- SetBlock(scr, y, x, (x == column) ? BT_none : BT_piece1);
+ SetBlock(scr, y, x, (x == column) ? BT_none : BT_white);
curY[scr] += count;
}
/*
* Netris -- A free networked version of T*tris
- * Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+ * Copyright (C) 1994-1996,1999 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
* 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.32 1996/02/09 08:47:25 mhw Exp $
+ * $Id: curses.c,v 1.33 1999/05/16 06:56:25 mhw Exp $
*/
#include "netris.h"
#include <string.h>
#include <stdlib.h>
+#ifdef NCURSES_VERSION
+# define HAVE_NCURSES
+#endif
+
+#ifdef HAVE_NCURSES
+static struct
+{
+ BlockType type;
+ short color;
+} myColorTable[] =
+{
+ { BT_white, COLOR_WHITE },
+ { BT_blue, COLOR_BLUE },
+ { BT_magenta, COLOR_MAGENTA },
+ { BT_cyan, COLOR_CYAN },
+ { BT_yellow, COLOR_YELLOW },
+ { BT_green, COLOR_GREEN },
+ { BT_red, COLOR_RED },
+ { BT_none, 0 }
+};
+#endif
+
static void PlotBlock1(int scr, int y, int x, BlockType type);
static MyEventType KeyGenFunc(EventGenRec *gen, MyEvent *event);
static int boardYPos[MAX_SCREENS], boardXPos[MAX_SCREENS];
static int statusYPos, statusXPos;
+static int haveColor;
static char *term_vi; /* String to make cursor invisible */
static char *term_ve; /* String to make cursor visible */
GetTermcapInfo();
/*
- * Do this atomically. Otherwise a badly timed Ctrl-C during
- * initialization will leave your terminal in a bad state.
+ * Block signals while initializing curses. Otherwise a badly timed
+ * Ctrl-C during initialization might leave the terminal in a bad state.
*/
BlockSignals(&oldMask, SIGINT, 0);
initscr();
+
+#ifdef CURSES_HACK
+ {
+ extern char *CS;
+
+ CS = 0;
+ }
+#endif
+
+#ifdef HAVE_NCURSES
+ haveColor = colorEnable && has_colors();
+ if (haveColor)
+ {
+ int i = 0;
+
+ start_color();
+ for (i = 0; myColorTable[i].type != BT_none; ++i)
+ init_pair(myColorTable[i].type, COLOR_BLACK,
+ myColorTable[i].color);
+ }
+#else
+ haveColor = 0;
+#endif
+
AtExit(CleanupScreens);
RestoreSignals(NULL, &oldMask);
move(0, 0);
addstr("Netris ");
addstr(version_string);
- addstr(" (C) 1994,1995,1996 Mark H. Weaver "
+ addstr(" (C) 1994-1996,1999 Mark H. Weaver "
"\"netris -h\" for more info");
statusYPos = 22;
statusXPos = 0;
static void PlotBlock1(int scr, int y, int x, BlockType type)
{
+ int colorIndex = abs(type);
+
move(boardYPos[scr] - y, boardXPos[scr] + 2 * x);
- switch (type) {
- case BT_none:
- addstr(" ");
- break;
- case -BT_piece1:
- if (standoutEnable)
- standout();
- addstr("$$");
- if (standoutEnable)
- standend();
- break;
- case BT_piece1:
- if (standoutEnable)
+
+ if (type == BT_none)
+ addstr(" ");
+ else
+ {
+ if (standoutEnable)
+ {
+#ifdef HAVE_NCURSES
+ if (haveColor)
+ attrset(COLOR_PAIR(colorIndex));
+ else
+#endif
standout();
- addstr("[]");
- if (standoutEnable)
- standend();
- break;
- default:
- assert(0);
+ }
+
+ addstr(type > 0 ? "[]" : "$$");
+ standend();
}
}
* 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.38 1996/02/09 08:22:11 mhw Exp $
+ * $Id: game.c,v 1.39 1999/05/16 06:56:27 mhw Exp $
*/
#define NOEXT
int initConn = 0, waitConn = 0, ch;
char *hostStr = NULL, *portStr = NULL;
- standoutEnable = 1;
+ standoutEnable = colorEnable = 1;
stepDownInterval = DEFAULT_INTERVAL;
MapKeys(DEFAULT_KEYS);
- while ((ch = getopt(argc, argv, "hHRs:r:Fk:c:woDSp:i:")) != -1)
+ while ((ch = getopt(argc, argv, "hHRs:r:Fk:c:woDSCp:i:")) != -1)
switch (ch) {
case 'c':
initConn = 1;
case 'D':
dropModeEnable = 1;
break;
+ case 'C':
+ colorEnable = 0;
+ break;
case 'S':
standoutEnable = 0;
break;
/*
* Netris -- A free networked version of T*tris
- * Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+ * Copyright (C) 1994-1996,1999 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
* 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.27 1996/02/09 08:22:14 mhw Exp $
+ * $Id: netris.h,v 1.28 1999/05/16 06:56:29 mhw Exp $
*/
#ifndef NETRIS_H
#define EM_any 000777
typedef enum _GameType { GT_onePlayer, GT_classicTwo, GT_len } GameType;
-typedef enum _BlockTypeA { BT_none, BT_piece1, BT_wall, BT_len } BlockTypeA;
+typedef enum _BlockTypeA { BT_none, BT_white, BT_blue, BT_magenta,
+ BT_cyan, BT_yellow, BT_green, BT_red,
+ BT_wall, BT_len } BlockTypeA;
typedef enum _Dir { D_down, D_right, D_up, D_left } Dir;
typedef enum _Cmd { C_end, C_forw, C_back, C_left, C_right, C_plot } Cmd;
typedef enum _FDType { FT_read, FT_write, FT_except, FT_len } FDType;
EXT Shape *curShape[MAX_SCREENS];
EXT int curY[MAX_SCREENS], curX[MAX_SCREENS];
EXT char opponentName[16], opponentHost[256];
-EXT int standoutEnable;
+EXT int standoutEnable, colorEnable;
EXT int robotEnable, robotVersion, fairRobot;
EXT int protocolVersion;
-$Id: robot_desc,v 1.3 1996/02/09 08:22:16 mhw Exp $
+$Id: robot_desc,v 1.4 1999/05/16 06:56:30 mhw Exp $
GENERAL PROTOCOL
The robot should ignore commands which it doesn't recognize. The protocol
may be extended by adding extra commands without incrementing the version
-number. The version number will only be increased when the command cannot
+number. The version number will only be increased when a command cannot
be safely ignored.
Netris will also ignore commands which it doesn't recognize, for the same
--------------
This command is never sent in "fair" robot mode.
-Everytime a new piece is created, this command is sent to the robot.
+Every time a new piece is created, this command is sent to the robot.
<num> is a positive integer uniquely identifying the piece. <num> should
be sent as a parameter to each movement command (sent to Netris) in
order to prevent accidental movement of the wrong piece.
our side. <pausedByThem> is 0 or 1, indicating whether any player other
than our side has paused the game. If either is 1, the game is paused.
-You may actually receive this command even when none of the flags change.
+You may actually receive this command even when neither of the flags change.
NORMAL GAME (robot --> Netris)
/*
* Netris -- A free networked version of T*tris
- * Copyright (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>
+ * Copyright (C) 1994-1996,1999 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
* 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.15 1996/02/09 08:22:17 mhw Exp $
+ * $Id: shapes.c,v 1.16 1999/05/16 06:56:31 mhw Exp $
*/
#include "netris.h"
static Cmd cmds_long[] = { C_back, C_plot, C_forw, C_plot, C_forw, C_plot,
C_forw, C_plot, C_end };
-TwoWayDecl(long, long, 0, BT_piece1);
+TwoWayDecl(long, long, 0, BT_blue);
static Cmd cmds_square[] = { C_plot, C_forw, C_left, C_plot, C_forw, C_left,
C_plot, C_forw, C_left, C_plot, C_end };
-static Shape shape_square = { &shape_square, 0, 0, D_up, 0, BT_piece1,
+static Shape shape_square = { &shape_square, 0, 0, D_up, 0, BT_magenta,
cmds_square };
static Cmd cmds_l[] = { C_right, C_back, C_plot, C_forw, C_plot, C_forw,
C_plot, C_left, C_forw, C_plot, C_end };
-FourWayDecl(l, l, 0, BT_piece1);
-FourWayDecl(l1, l, 1, BT_piece1);
+FourWayDecl(l, l, 0, BT_cyan);
+FourWayDecl(l1, l, 1, BT_yellow);
static Cmd cmds_t[] = { C_plot, C_forw, C_plot, C_back, C_right, C_forw,
C_plot, C_back, C_back, C_plot, C_end };
-FourWayDecl(t, t, 0, BT_piece1);
+FourWayDecl(t, t, 0, BT_white);
static Cmd cmds_s[] = { C_back, C_plot, C_forw, C_plot, C_left, C_forw,
C_plot, C_right, C_forw, C_plot, C_end };
-TwoWayDecl(s, s, 0, BT_piece1);
-TwoWayDecl(s1, s, 1, BT_piece1);
+TwoWayDecl(s, s, 0, BT_green);
+TwoWayDecl(s1, s, 1, BT_red);
ShapeOption stdOptions[] = {
{1, &shape_long_horiz},
* 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.27 1996/02/09 08:22:23 mhw Exp $
+ * $Id: util.c,v 1.29 1999/05/16 06:56:33 mhw Exp $
*/
#include "netris.h"
ExtFunc void Usage(void)
{
fprintf(stderr,
- "Netris version %s (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>\n"
+ "Netris version %s (C) 1994-1996,1999 Mark H. Weaver <mhw@netris.org>\n"
"Usage: netris <options>\n"
" -h Print usage information\n"
" -w Wait for connection\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"
+ " -S Disable inverse/bold/color for slow terminals\n"
+ " -C Disable color\n"
" -H Show distribution and warranty information\n"
" -R Show rules\n",
version_string, DEFAULT_PORT, DEFAULT_KEYS);
ExtFunc void DistInfo(void)
{
fprintf(stderr,
- "Netris version %s (C) 1994,1995,1996 Mark H. Weaver <mhw@netris.org>\n"
+ "Netris version %s (C) 1994-1996,1999 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"
ExtFunc void RemoveEventGen(EventGenRec *gen)
{
- assert(gen->next != NULL);
- while (nextGen->next != gen)
- nextGen = nextGen->next;
- nextGen->next = gen->next;
- gen->next = NULL;
+ /* assert(gen->next != NULL); /* Be more forgiving, for SIGINTs */
+ if (gen->next) {
+ while (nextGen->next != gen)
+ nextGen = nextGen->next;
+ nextGen->next = gen->next;
+ gen->next = NULL;
+ }
}
ExtFunc MyEventType WaitMyEvent(MyEvent *event, int mask)