[comp.sources.games] v01i061: kriegspiel - A Chess Variant, Part02/04

games-request@tekred.TEK.COM (06/29/87)

Submitted by: Steve Schoch <schoch@ames.arpa>
Comp.sources.games: Volume 1, Issue 61
Archive-name: kriegspiel/Part02



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 4)."
# Contents:  README.protocol bishop_mask.h connect.c externs.h
#   help.nroff init.c main.c movecycle.c screen.c traps.c xboard.c
#   xmain.c xpieces.c
# Wrapped by billr@tekred on Fri Jun 26 18:23:53 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README.protocol -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README.protocol\"
else
echo shar: Extracting \"README.protocol\" \(2971 characters\)
sed "s/^X//" >README.protocol <<'END_OF_README.protocol'
XMay 20, 1987	Steve Schoch <schoch@ames.arpa>
X
XThis file describes the procotol between two games of Kriegspiel.
X
XDeciding on a Port
X     Each instance of a game will use this method to decide on which port
Xto connect to carry out the communication with the other game.  Since ks
Xrequires no server, one process will be the server, and one the client.
XAfter the initial exchange, there is no distinction between server and
Xclient.  Each assumes the other is a peer.
X     The ks program compares (using strcmp) the login name of the person
Xinvoking the game with that of the opponent (given on the command line).
XThe login name that is the greater (alphabetically) of the two assumes the
Xrole of server.  If both names are the same, the role is decided based on
Xthe IP address of this host, and the host of the opponent, the server
Xbeing the one with the lower IP address.
X     If both the login name and the host are the same, then which ever
Xhost binds to the port first is the server.
X
X     Once the role is determined, the port is chosen.  This is done by the
Xroutines hashaddr and hashport in connect.c.  They are too dificult to
Xexplain here.
X
XOptions
X       After connecting, the two processes agree on options.  Currently,
Xthe options, are color, announce pawn tries, and announce captures.
XIf neither player selects preferences, the defaults are to choose color
Xat random, with announce pawn tries and announce captures on.  If either
Xplay selects differently, for instance, if one player selects white,
Xwith announce captures off, then he will be white, and announce captures
Xwill be turned off.  If players select conflicting options, for instance,
Xif both want to be white, or one wants announce captures on, and one wants
Xit off, then that option is chosen at random.  Additionally, either player
Xcan force an option to be chosen at random.
X
X     This is done by the client sending it's option values as ascii
Xdigits, '2' for unset, '0' for no (white), '1' for yes (black), or '3'
Xto force it random.  Each line is ended eith <cr><lf>.  The server then
Xfigures out the settings of the options, and sends this back to the
Xclient program in the same manner, except that the values will only be
X'0' and '1'.
X
XThe Game
X     Each move or attempted move is sent as <start pos>-<end pos>, where
Xeach position is a letter (a-h) and a digit (1-8).  The positions are
Xthe same for both processes, with a1 being the starting square for
Xwhite's queen's bishop.  Again, each line sent is terminated with <cr><lf>.
XIf a player tries an illegal or blocked move, it is sent anyway, and
Xboth processes announce this fact.
X     In addition, there are several other messages that may be sent at
Xany time.  "say text", is sent by one program as a message from a player
Xto his opponent.  "resign" is sent when one player resigns.  draw is sent
Xwhen one player offers to call the game a draw, the opponent's process
Xsends either "yes" or "no" in response as directed by the player.
END_OF_README.protocol
if test 2971 -ne `wc -c <README.protocol`; then
    echo shar: \"README.protocol\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f bishop_mask.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"bishop_mask.h\"
else
echo shar: Extracting \"bishop_mask.h\" \(2336 characters\)
sed "s/^X//" >bishop_mask.h <<'END_OF_bishop_mask.h'
X#define bishop_mask_width 64
X#define bishop_mask_height 64
Xstatic short bishop_mask_bits[] = {
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0xc000, 0x0003, 0x0000,
X   0x0000, 0xc000, 0x0003, 0x0000,
X   0x0000, 0xc000, 0x0003, 0x0000,
X   0x0000, 0xe000, 0x0007, 0x0000,
X   0x0000, 0xf000, 0x000f, 0x0000,
X   0x0000, 0xf800, 0x001f, 0x0000,
X   0x0000, 0xfc00, 0x003f, 0x0000,
X   0x0000, 0xfe00, 0x007f, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xfe00, 0x007f, 0x0000,
X   0x0000, 0xfc00, 0x003f, 0x0000,
X   0x0000, 0xf800, 0x001f, 0x0000,
X   0x0000, 0xf000, 0x000f, 0x0000,
X   0x0000, 0xf800, 0x001f, 0x0000,
X   0x0000, 0xf800, 0x001f, 0x0000,
X   0x0000, 0xf800, 0x001f, 0x0000,
X   0x0000, 0xfc00, 0x003f, 0x0000,
X   0x0000, 0xfc00, 0x003f, 0x0000,
X   0x0000, 0xfc00, 0x003f, 0x0000,
X   0x0000, 0xfe00, 0x007f, 0x0000,
X   0x0000, 0xfe00, 0x007f, 0x0000,
X   0x0000, 0xfe00, 0x007f, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff80, 0x01ff, 0x0000,
X   0x0000, 0xff80, 0x01ff, 0x0000,
X   0x0000, 0xff80, 0x01ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xffe0, 0x07ff, 0x0000,
X   0x0000, 0xffe0, 0x07ff, 0x0000,
X   0x0000, 0xffe0, 0x07ff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xfff8, 0x1fff, 0x0000,
X   0x0000, 0xfff8, 0x1fff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xffe0, 0x07ff, 0x0000,
X   0x0000, 0xffe0, 0x07ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xff80, 0x01ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xff00, 0x00ff, 0x0000,
X   0x0000, 0xffc0, 0x03ff, 0x0000,
X   0x0000, 0xfff0, 0x0fff, 0x0000,
X   0x0000, 0xfff8, 0x1fff, 0x0000,
X   0x0000, 0xfffc, 0x3fff, 0x0000,
X   0x0000, 0xfffe, 0x7fff, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000,
X   0x0000, 0x0000, 0x0000, 0x0000};
END_OF_bishop_mask.h
if test 2336 -ne `wc -c <bishop_mask.h`; then
    echo shar: \"bishop_mask.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f connect.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"connect.c\"
else
echo shar: Extracting \"connect.c\" \(4394 characters\)
sed "s/^X//" >connect.c <<'END_OF_connect.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: connect.c,v 1.5 87/05/19 17:24:26 schoch Exp $";
X#endif
X
X#include "externs.h"
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <sys/param.h>
X#include <netinet/in.h>
X#include <netdb.h>
X#include <pwd.h>
X#include <errno.h>
X
Xextern int errno;
X
Xint sock;	/* in main */
XFILE *inp, *out;
X
Xconnectport (opponent, port)
X	char *opponent;
X	u_short port;
X{
X	struct sockaddr_in addr;
X	struct hostent *host;
X	struct passwd *mypasswd, *getpwuid();
X	char *hishostname, *myname, *index(), *getpw(), *malloc();
X	char myhostname[MAXHOSTNAMELEN+1];
X	char *hisaddr, *myaddr;
X	int hislen, mylen;
X	u_long iaddr;
X	uid_t getuid();
X	u_short hashport(), hashaddr();
X	char *copyhost();
X	int s, i;
X
X	if (gethostname (myhostname, MAXHOSTNAMELEN) < 0)
X		error ("gethostname in connectport");
X	host = gethostbyname(myhostname);
X	if (host == NULL) {
X		errno = 0;
X		error("don't know my own name.");
X	}
X	mylen = host->h_length;
X	myaddr = copyhost(host);
X	if (hishostname = index (opponent, '@')) {
X		*hishostname++ = '\0';        /* separate user and host */
X		if (hishostname[0] >= '0' && hishostname[0] <= '9') {
X			iaddr = inet_addr(hishostname);
X			hisaddr = (char *)&iaddr;
X			hislen = sizeof iaddr;
X		} else {
X			host = gethostbyname(hishostname);
X			if (host == NULL) {
X				errno = 0;
X				error("Unknown host");
X			}
X			hislen = host->h_length;
X			hisaddr = copyhost(host);
X			hishostname = host->h_name;
X		}
X	} else {
X		hislen = mylen;
X		hisaddr = myaddr;
X		hishostname = myhostname;
X	}
X	mypasswd = getpwuid ((int) getuid());
X	myname = mypasswd -> pw_name;
X	if (iamserver == UNSET)
X		if (i = strcmp (myname, opponent))
X			iamserver = (i < 0);
X		else if (i = comparehost(myaddr, hisaddr, mylen))
X			iamserver = (i < 0);
X	if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0)
X		error ("socket in connectport");
X	bzero ((char *) &addr, sizeof (addr));
X	if (port != 0) {
X		if (port > 1000) {
X			errno = 0;
X			error ("bad port number");
X		}
X	} else if (iamserver) {
X		port = hashaddr(myaddr, port, mylen);
X		port = hashaddr(hisaddr, port, hislen);
X		port = hashport(myname, port);
X		port = hashport(opponent, port);
X	} else {
X		port = hashaddr(hisaddr, port, hislen);
X		port = hashaddr(myaddr, port, mylen);
X		port = hashport(opponent, port);
X		port = hashport(myname, port);
X	}
X	port += 3000;
X	addr.sin_family = AF_INET;
X	addr.sin_port = htons (port);
X	if (iamserver) {
X		s = sock;
X		if (bind (s, /*(char *)*/ &addr, sizeof (addr)) < 0)
X			if (errno == EADDRINUSE && iamserver == UNSET) {
X				/* hope other player is server */
X				iamserver = FALSE;
X				close (s);
X				if ((sock = socket (AF_INET, SOCK_STREAM, 0))
X				    < 0)
X					error ("socket in connectport");
X			} else
X				error ("bind in connectport");
X		if (iamserver) {
X			if (listen (s, 1) < 0)
X				error ("listen in connectport");
X			while ((sock = accept (s, (struct sockaddr_in *) NULL,
X			    (int *) NULL)) < 0)
X				if (errno != EINTR)
X					error ("accept in connectport");
X			close(s);
X		}
X	}
X	if (!iamserver) {
X		bcopy (hisaddr, (char *) &addr.sin_addr, hislen);
X		while (connect (sock, /*(char *)*/ &addr, sizeof (addr)) < 0)
X			if ( errno == EINTR || errno == ECONNREFUSED) {
X				close (sock);
X				sleep(2);
X				if ((sock = socket (AF_INET, SOCK_STREAM, 0))
X				    < 0)
X					error ("socket in connectport");
X			} else
X				error ("connect in connectport");
X	}
X	if ((s = dup(sock)) < 0)
X		error("dup");
X	if ((inp = fdopen(sock, "r")) == NULL)
X		error("fdopen");
X	if ((out = fdopen(s, "w")) == NULL)
X		error("fdopen");
X	setlinebuf(out);
X}
X
Xu_short
Xhashport (s, port)
X	char *s;
X	u_short port;
X{
X	while (*s)
X		port = (port << 1) + *s++;
X	return (port & 0x7fff);
X}
X
X/*
X * addr is in network byte order.
X */
Xu_short
Xhashaddr(addr, port, len)
Xu_short port;
Xchar *addr;
X{
X
X	while (len--)
X		port = (port << 1) + *addr++;
X	return (port & 0x7fff);
X}
X
Xchar *
Xcopyhost(host)
Xstruct hostent *host;
X{
X	char *ret;
X
X	ret = malloc(host->h_length);
X	if (ret == NULL)
X		error("malloc");
X	bcopy(host->h_addr, ret, host->h_length);
X
X	return ret;
X}
X
X/* Compare h1 and h2 (in network byte order).  The network number is
X * more significant than the host number, thus we need to call ntohl().
X */
Xcomparehost(h1, h2, len)
Xchar *h1, *h2;
X{
X	auto unsigned long l1, l2;
X
X	bcopy(h1, &l1, sizeof l1);
X	bcopy(h2, &l2, sizeof l2);
X	l1 = ntohl(l1);
X	l2 = ntohl(l2);
X
X	if (l1 < l2)
X		return -1;
X	else if (l1 > l2)
X		return 1;
X	return 0;
X}
END_OF_connect.c
if test 4394 -ne `wc -c <connect.c`; then
    echo shar: \"connect.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f externs.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"externs.h\"
else
echo shar: Extracting \"externs.h\" \(2623 characters\)
sed "s/^X//" >externs.h <<'END_OF_externs.h'
X/*
X * $Header: externs.h,v 1.5 87/05/19 18:48:30 schoch Exp $
X */
X
X#include "constants.h"
X#include <stdio.h>
X
X#ifdef XKS
X#include <X/Xlib.h>
X#define NULL 0
X#define TOPSPACE	(64+18)
X#define FALSE		0
X#define TRUE		1
Xtypedef unsigned char bool;
X#else
X#include <curses.h>
X#endif XKS
X
X#include <errno.h>
X#include <sys/types.h>
X/* on machines without alloca () */
X/* #define alloca malloc         */
X
Xstruct IN
X{
X	int i;
X	struct IN *n;
X};
Xtypedef struct IN *LIST;
X
Xstruct MOVE
X{
X	int from;
X	int to;
X	struct MOVE *n;
X};
Xtypedef struct MOVE *MOVELIST;
X
Xextern	u_char	occupant [100];		/* what piece occupies square	*/
Xextern	u_char	whose [100];		/* which color occupies square	*/
Xextern	LIST	dirlist [7];		/* directions a piece moves	*/
Xextern		pawndir	[2];		/* direction pawns of move	*/
Xextern	LIST	piecelocs [2];		/* locations of pieces		*/
Xextern	int	kingloc [2];		/* location of king		*/
Xextern	MOVELIST movelist;		/* record of game		*/
Xextern	u_char	ourcolor;
Xextern	u_char	theircolor;
Xextern	char	*colorname [];
Xextern	int	lastmovefrom;
Xextern	int	lastmoveto;
Xextern	u_char	virgin [100]; 		/* pieces not moved or captured	*/
Xextern	bool	drawok [2];		/* side has agreed to draw	*/
Xextern	bool	resign;			/* somebody resigned		*/
Xextern	bool	dead;			/* somebody died		*/
Xextern	bool	reverse;		/* Show board in reverse	*/
Xextern	u_char	color;			/* Who's turn it is		*/
Xextern	u_char	state;			/* What state we're in		*/
Xextern	u_char	option [NOPTIONS];	/* options players must agree on*/
Xextern	bool	iamserver;		/* am I the server player?	*/
Xextern	FILE	*inp, *out;		/* socket for opponent		*/
Xextern	int	errno;			/* system error numbers		*/
X
X#ifdef XKS
XWindow	window;
XWindow	iconwindow;
XFont	font;
Xint	move;				/* piece being moved by mouse	*/
XPixmap	pieces_masks[8];
XPixmap	pieces_icons[8];
Xextern	u_char	ghost[100];		/* opponent's "ghost" pieces	*/
Xextern	u_char	captured[32];		/* pieces captured		*/
X#else
Xextern	char	symbol [7];		/* symbols for printing pieces	*/
Xextern	WINDOW	*blanksq [89];		/* blank chessboard squares	*/
Xextern	WINDOW	*square [89];		/* contents of chessboard	*/
Xextern	WINDOW	*win [23];		/* message window areas		*/
Xextern	WINDOW	*backupwin [23];	/* for switching screens	*/
Xextern	WINDOW	*backupscreen;		/* used for redrawing vt220	*/
Xextern	WINDOW	*blankscreen;		/* used for redrawing vt220	*/
Xextern	char	sqcolor [2];		/* character used for square	*/
Xextern	bool	vtterm;			/* is this a vt220?		*/
Xextern	bool	dumbterm;		/* are we dumb?			*/
Xextern	bool	reversescr;		/* can terminal inverse video?	*/
Xextern	int	sqheight;		/* height of a square		*/
Xextern	int	sqwidth;		/* width of a square		*/
X#endif
END_OF_externs.h
if test 2623 -ne `wc -c <externs.h`; then
    echo shar: \"externs.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f help.nroff -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"help.nroff\"
else
echo shar: Extracting \"help.nroff\" \(6850 characters\)
sed "s/^X//" >help.nroff <<'END_OF_help.nroff'
X.TH KRIEGSPIEL 1 "2 May 1986"
X.UC 4
X.SH NAME
Xkriegspiel \- A Chess Variant
X.SH SYNOPSIS
X.B ks
X[{+-}[bwcaprsdh]] user[@machine]
X.br
Xxks
X[{+-}[bwcaprs]] [display] [=geometry] user[@machine]
X.br
X.SH DESCRIPTION
X.I Kriegspiel
Xis a chess variant in which each player cannot see his opponents
Xpieces.  The computer acts as a judge for two players. The rules of
XKriegspiel are discussed at the end of this document.
X.PP
XThe game must be invoked separately by two users.  Various options may be
Xchosen in the command line; conflicting options (such as if both players
Xchoose white) are resolved with a flip of a coin.
X.PP
XMoves may be specified in either algebraic or descriptive notation.  Most
Xstandard methods will work.  For example, all of the following are legal
X(and equivalent) for white's first move:  p-k4, p/k2-k4, e2-e4, e4, pe4.
XIn descriptive notation, use an 'x' for pawn takes (such as pxkb4), but do
Xnot use an 'x' when taking using other pieces.  Castling can be done with
Xo-o (king side) and o-o-o (queen side), or by moving the king two squares.
X.PP
XThe other commands available are:
X.PP
X.br
X.ns
X.TP 15
Xresign
XI resign.
X.br
X.ns
X.TP
Xdraw
XOffer a draw.
X.br
X.ns
X.TP
Xhelp
XGive examples of legal commands.
X.br
X.ns
X.TP
Xany
XCan I take with any of my pawns?
X.br
X.ns
X.TP
X.RI say \ string
XSend message to opponent.
X.br
X.ns
X.TP
X.I Control-L
XRedraw the screen (when typed at any time).
X.PP
X.I Xks
Xis an version of the game for the X window system.
XPieces are moved with the left mouse button.
XOther commands are single letters on the keyboard.
XType 'h' for help after game starts.
X.PP
XUnder the default options, you will be informed of the following
Xinformation when applicable:
X.nf
X(1) your opponent tries an illegal move
X(2) you or your opponent is in check from the appropriate direction
X(3) your piece is taken (but not your opponent's piece is taken)
X(4) your opponent asks `any', and the response
X.fi
X.PP
XThe game ends if either player is checkmated or stalemated, if both players
Xhave insufficient material, if either player resigns, if both players
Xagree on a draw, or the game can end due to hardware error.  (But not if
Xthe same position comes up three times or if the game goes 50 consecutive
Xmoves without a piece take or pawn capture, as in ordinary chess).
X
X.SH OPTIONS
X.PP
XSome options preceded by a `-' will turn the option off.
XIf the players choose
Xconflicting option, then the option will be chosen by a flip of a coin.
X.PP
X.br
X.ns
X.TP 15
X-w
XI wish to be white.  Negated by opponent choosing options `c' or
X`w'
X.br
X.ns
X.TP
X-b
XI wish to be black.  Negated by opponent choosing options `c' or
X`b'
X.br
X.ns
X.TP
X-c
XForce color to be chosen randomly.  This is the default if neither person
Xchooses a color.
X.br
X.ns
X.TP
X[+-]a
XAnnounce to both players when a piece is taken, revealing also
Xwhether it was a pawn or a major piece that was taken.  Also
Xannounce if a pawn ever promotes.
X.br
X.ns
X.TP
X[+-]p
XAnnounce to both players how many possible ways the player to move
Xcan take with his pawns (if he can at all).  The player to move can
Xonly try three moves which take with his pawns.  If, after exhausting these
Xthree tries, the player's
Xonly legal move is to take with his pawn, then the player is
Xcheckmated or stalemated as appropriate.  If the player tries the
Xsame take twice, this will not be counted against him.  The `any'
Xcommand is ignored under this option.
X.br
X.ns
X.TP
X-r
XReverse the direction from which algebraic moves are accepted if I
Xam black.  (Thus, e2-e4 on black's first move would move the pawn
Xin front of your king up two squares.  Without this option set, the
Xmove would be entered as d7-d5 in algebaic)
X.br
X.ns
X.TP
X-d
XDumb terminal:  Use this option if the graphics don't seem to be
Xworking well.  This may help.
X.br
X.ns
X.TP
X-h
XPrint out this help file.
X.br
X.ns
X.TP
X[+-]s
XMake me the server.  This option should only be used as a last
Xresort.  Invisibly to the user, one player is the
Xserver, and one is the client.  These are usually chosen by the
Xprogram by a protocol.  If you're having troubles connecting with
Xyour opponent, then try the following:  One player invoke the
Xprogram with the `+s' option, and one with the `-s' option.
X.br
X.ns
X.TP
X.I n
XA number between one and a thousand to be used as the port.  This option
Xshould only be used if you are having troubles connecting.  Both players
Xshould select the same number between 1 and 1000 to be used to compute
Xthe port on which they communicate.
X.SH RULES
XKriegspiel is a chess variation dating back at least before WWII.
XIt requires three people: two players and a judge.  The players sit back to
Xback, each with a board with only their own pieces.  The judge has a board
Xbetween the players, with the entire position.  Each player in his turn
Xtries different moves.  For each illegal move tried, the judge says
X`illegal' aloud.  If a player is put into check, this fact is said out
Xloud, along with the direction from which he/she is in check: Check along
Xthe file, rank, short diagonal, long diagonal (from the point of view of
Xthe king), and knight.  When the player makes a legal move, that is the
Xmove he must play.
X.PP
XBeyond this, the ammount of information the judge should reveal is
Xcontroversial.  The author prefers the following.  If a piece is taken, the
Xjudge (quietly) removes the piece from the injured party's board.  On
Xher/his turn, a person may ask `any?', meaning `Are there any ways of
Xtaking any of my opponent's pieces with any of my pawns?'  The judge
Xanswers aloud `yes' or `no', as appropriate.  The reason this rule is
Xincluded is to speed up the game;  otherwise each player would try all
Xpossible pawn takes at the start of each turn.  The disadvantage with
Xasking `any?' is that the opponent also finds out the answer; the advantage
Xis that the player is under no obligation to actually take a piece with one
Xof his pawns, even if the answer is yes.  (Thus, he has gained information
Xfor free.)
X.PP
XSome people prefer to play that takes are announced out loud,
Xalong with whether the piece taken was a pawn or not, allowing the players
Xto have an idea how well their doing.  Furthermore, that it should be
Xannounced not only whether a person has any available pawn tries, but also
Xhow many on every move.  This extra information, it is said, makes the game
Xless chaotic and random, and keeps it from becoming like Battleship.
XHowever, the extra information is somewhat tempered by the fact that a
Xperson may only try to take in three different ways with his pawns, after
Xwhich a pawn take becomes illegal.
X.SH AUTHOR
XDavid Wolfe
X.SH BUGS
XThere is no way of saving a game in progress.  This is particularly
Xfrustrating if you are playing on an unreliable network:  If the network
Xgoes down, give it up...
X.PP
XOther bugs, unknown.  Please notify Steve Schoch <schoch@ames.arpa>
Xor David Wolfe <wolfe@ernie.berkeley.edu>
END_OF_help.nroff
if test 6850 -ne `wc -c <help.nroff`; then
    echo shar: \"help.nroff\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f init.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"init.c\"
else
echo shar: Extracting \"init.c\" \(3826 characters\)
sed "s/^X//" >init.c <<'END_OF_init.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: init.c,v 1.1 87/02/12 10:58:25 schoch Exp $";
X#endif
X
X#include "externs.h"
X#include <ctype.h>
X
Xinitdirlists ()
X{
X	LIST linsert ();
X	dirlist [PAWN] = (LIST) NIL;
X	dirlist [KING] = linsert (linsert (linsert (linsert (linsert (linsert
X         (linsert (linsert ((LIST) NIL, -10), -9), 1), 11), 10), 9), -1), -11);
X	dirlist [KNIGHT] = linsert (linsert (linsert (linsert (linsert (linsert
X	 (linsert (linsert ((LIST)NIL, -19),-8), 12), 21), 19), 8), -12), -21);
X	dirlist [BISHOP] = linsert (linsert (linsert (linsert
X            ((LIST) NIL, -9), 11), 9), -11);
X	dirlist [ROOK] = linsert (linsert (linsert (linsert
X            ((LIST) NIL, -10), 1), 10), -1);
X	dirlist [QUEEN] = linsert (linsert (linsert (linsert (linsert (linsert
X          (linsert (linsert ((LIST) NIL, -10),-9), 1), 11), 10), 9), -1), -11);
X}
X
Xinitpiecelocs ()
X{
X	piecelocs [BLACK] = linsert (linsert (linsert (linsert (linsert
X            (linsert (linsert (linsert (linsert (linsert (linsert (linsert
X	    (linsert (linsert (linsert (linsert ((LIST) NIL, 11), 12), 13), 14)
X            , 15), 16), 17), 18), 21), 22), 23), 24), 25), 26), 27), 28);
X        piecelocs [WHITE] = linsert (linsert (linsert (linsert (linsert
X            (linsert (linsert (linsert (linsert (linsert (linsert (linsert
X            (linsert (linsert (linsert (linsert ((LIST) NIL, 71), 72), 73), 74)
X            , 75), 76), 77), 78), 81), 82), 83), 84), 85), 86), 87), 88);
X	kingloc [WHITE] = 85;
X	kingloc [BLACK] = 15;
X}
X
X
Xinitboard(allpieces)
X	int allpieces;
X{
X	int row, col, spot, i, j;
X	static u_char initwhose [100] = { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
X				        3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
X				        3, 1, 1, 1, 1, 1, 1, 1, 1, 3,
X				        3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
X				        3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
X				        3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
X				        3, 2, 2, 2, 2, 2, 2, 2, 2, 3,
X				        3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
X				        3, 0, 0, 0, 0, 0, 0, 0, 0, 3,
X				        3, 3, 3, 3, 3, 3, 3, 3, 3, 3 };
X
X	static int initoccupant [100] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X					  0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
X					  0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
X					  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X					  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X					  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X					  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
X					  0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
X					  0, 5, 3, 4, 6, 2, 4, 3, 5, 0,
X					  0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
X
X	if (ourcolor == WHITE)
X		theircolor = BLACK;
X	else if (ourcolor == BLACK)
X		theircolor = WHITE;
X	for (i = 0; i < 100; i++) {
X		whose [i] = initwhose [i];
X		occupant [i] = initoccupant [i];
X#ifdef XKS
X		if (whose[i] == theircolor)
X			ghost[i] = occupant[i];
X		else
X			ghost[i] = 0;
X#endif
X		virgin[i] = TRUE;
X	}
X
X#ifdef XKS
X	for (i = 0; i < 32; i++)
X		captured[i] = 0;
X#else
X	for (row = 0; row <= 7; row++)
X		for (col = 0; col <= 7; col ++) {
X			if (ourcolor == WHITE) {
X				i = row;
X				j = col;
X			} else {
X				i = 7 - row;
X				j = 7 - col;
X			}
X			spot = 10 * (row + 1) + (col + 1);
X			blanksq [spot] = subwin (stdscr, sqheight, sqwidth,
X						 sqheight * i, sqwidth * j);
X			square [spot] = subwin (stdscr, 1, 1,
X					  (sqheight * i) + (sqheight / 2),
X					  (sqwidth * j) + (sqwidth / 2));
X			if (reversescr && (row + col) % 2 == 0) {
X				wstandout (blanksq [spot]);
X				wstandout (square [spot]);
X			}
X			for (i = 1; i <= sqwidth; i++)
X				for (j = 1; j <= sqheight; j++)
X					waddch (blanksq [spot], ' ');
X			waddch (square [spot], sqcolor [(row + col) % 2]);
X		}
X	for (row = 1; row <= 2; row++)
X		for (col = 1; col <= 8; col++) {
X			if (ourcolor == WHITE)
X				spot = 10 * (9 - row) + col;
X			else
X				spot = 10 * row + col;
X			waddch (square [spot], symbol [occupant [spot]]);
X			if (allpieces)
X				waddch (square [99 - spot], tolower
X					(symbol [occupant [99 - spot]]));
X		}
X#endif XKS
X}
END_OF_init.c
if test 3826 -ne `wc -c <init.c`; then
    echo shar: \"init.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f main.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"main.c\"
else
echo shar: Extracting \"main.c\" \(2962 characters\)
sed "s/^X//" >main.c <<'END_OF_main.c'
X/* Kriegspiel written by David Wolfe based on a program by Bert Enderton
X    May 5, 1986
X
X    Network interface modified by Steve Schoch <schoch@ames.arpa>
X*/
X
X#ifndef lint
Xstatic char rcsid[] = "$Header: main.c,v 1.3 87/05/19 17:23:17 schoch Exp $";
X#endif
X
X/* main.c */
X#include "externs.h"
X#include <ctype.h>
X#include <signal.h>
X#include <strings.h>
X
Xchar symbol [7] = { '-', 'P', 'K', 'N', 'B', 'R', 'Q' };
Xu_char whose [100];
Xu_char occupant [100];
Xchar *colorname [2] = { "white", "black" };
Xint pawndir [2] = { -10, 10 };
X
XLIST		dirlist [7];
XLIST		piecelocs [2];
Xint		kingloc [2];
XMOVELIST	movelist = (MOVELIST) NULL;
Xu_char		ourcolor = UNSET;
Xu_char		theircolor;
Xint		lastmovefrom = 0;
Xint		lastmoveto = 0;
Xu_char		virgin [100];
Xbool		drawok [2] = { FALSE, FALSE};
Xbool		resign = FALSE;
Xbool		dead = FALSE;
Xu_char		color=WHITE, state=PLAYING;
Xu_char		option [NOPTIONS];
XWINDOW		*blanksq [89];
XWINDOW		*square [89];
XWINDOW		*win [23];
XWINDOW		*backupwin [23];
XWINDOW		*backupscreen;
XWINDOW		*blankscreen;
Xchar		sqcolor [2];
Xbool		vtterm;
Xbool		dumbterm = FALSE;
Xbool		reversescr;
Xint		sqheight;
Xint		sqwidth;
Xbool		reverse = FALSE;
Xbool		iamserver = UNSET;
XFILE		*inp, *out;
Xlong		random();
X
Xmain (argc, argv, envp)
X	int argc;
X	char **argv, **envp;
X{
X	int i, j, port = 0, trap_sigint();
X	char *p, *malloc ();
X	long time ();
X
X	signal (SIGINT, SIG_IGN);
X	signal (SIGPIPE, SIG_IGN);
X	srandom (time((long *) NULL));
X	if (!strcmp (argv [1], "help")) {
X		execle(PRINT_FILE, PRINT_FILE,
X		       HELP_FILE, 0, envp);
X		perror ("execle");
X		exit (1);
X	}
X	if (argc <= 1) {
X		printf ("Usage: %s [-bwcaprsdh] user\n", argv[0]);
X		printf ("Or for help: %s help\n", argv[0]);
X		exit (0);
X	}
X	for (i = 0; i < NOPTIONS; i++)
X		option [i] = UNSET;
X	j = 0;
X	for (i = 1; i < argc - 1; i++) {
X		j = TRUE;
X		for (p = argv [i]; *p != '\000'; p++) {
X			if isupper (*p)
X				*p = tolower (*p);
X			if (*p == '-')
X				j = FALSE;
X			else if (*p == 'b')
X				option [COLOR] = BLACK;
X			else if (*p == 'w')
X				option [COLOR] = WHITE;
X			else if (*p == 'c')
X				option [COLOR] = RANDOM;
X			else if (*p == 'a')
X				option [ANNOUNCETAKES] = j;
X			else if (*p == 'p')
X				option [ANNOUNCEPAWNS] = j;
X			else if (*p == 'r')
X				reverse = TRUE;
X			else if (*p == 's')
X				iamserver = j;
X			else if (*p == 'd')
X				dumbterm = j;
X			else if (isdigit (*p))
X				port = port * 10 + (*p - '0');
X			else if (*p == 'h') {
X				execle(PRINT_FILE, PRINT_FILE,
X				       HELP_FILE, 0, envp);
X				perror ("execle");
X				exit (1);
X			}
X		}
X	}
X	initdirlists ();
X	initpiecelocs ();
X	initscreen ();
X	refresh();
X	redraw();
X	signal (SIGINT, trap_sigint);
X	p = argv [argc - 1];
X	message("Connecting...", MESSAGE);
X	refresh ();
X	connectport (p, port);
X	mclear(MESSAGE);
X	message("type help for\nsample commands", MESSAGE);
X	refresh ();
X	dooptions();
X	if (ourcolor == WHITE) {
X		message("--- WHITE ---", MYCOLOR);
X		reverse = 0;
X	} else
X		message("--- BLACK ---", MYCOLOR);
X	initboard (FALSE);
X	movecycle ();
X}
END_OF_main.c
if test 2962 -ne `wc -c <main.c`; then
    echo shar: \"main.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f movecycle.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"movecycle.c\"
else
echo shar: Extracting \"movecycle.c\" \(6178 characters\)
sed "s/^X//" >movecycle.c <<'END_OF_movecycle.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: movecycle.c,v 1.2 87/05/19 17:22:07 schoch Exp $";
X#endif
X
X#include "externs.h"
X
X#ifdef XKS
Xmovecycle()
X{
X    fd_set readfds, fds;
X    extern int sock;
X    int n;
X
X    XSelectInput(window, ExposeWindow | ExposeRegion |
X	ButtonPressed | ButtonReleased | LeaveWindow | LeftDownMotion |
X	KeyPressed);
X    FD_ZERO(&fds);
X    FD_SET(dpyno(), &fds);
X    FD_SET(sock, &fds);
X    for(;;) {
X	while (XPending())
X	    handle_input();
X	readfds = fds;
X	n = select(FD_SETSIZE, &readfds, 0, 0, 0);
X	if (n < 0) {
X	    if (errno == EINTR)
X		continue;
X	    perror("select");
X	    exit(1);
X	}
X	if (n == 0)
X	    exit(0);
X	if (FD_ISSET(dpyno(), &readfds))
X	    handle_input();
X	if (FD_ISSET(sock, &readfds))
X	    if (handle_sock()) {
X		FD_CLR(sock, &fds);
X		close(sock);
X		sock = -1;
X	    }
X    }
X
X}
X
Xextern bool note_on;
Xint	pawntries=0;
Xchar	*colorname[3] = { "white", "black", "undecided" };
X
X/* This function is called when either side tries a move.
X * If the move is not valid, then we signal an error, no matter
X * who tries the move (this is so we can see what our opponent is
X * trying.
X *     If the move is correct, then we toggle color.
X */
Xmovetry(from, to, whose)
Xu_char whose;
X{
X	/* We can cheat with this initialization  of pawntries because
X	 * we know you can't take a pawn at the beginning of the games.
X	 */
X	static pawnattempts=0;
X	static LIST checkdirs = NIL;
X	int l;
X	LIST check ();
X	char buf[128];
X
X	mclear (CAPTURE);
X
X	if ((l = legalmove (pawntries, &pawnattempts, checkdirs,
X				       from, to, color)) != TRUE
X	    && !drawok [color] && !drawok [1 - color]
X	    && !resign && !dead) {
X		illegal (l, color);
X		return l;
X	}
X	mclear (CHECK);
X	mclear(LEGAL);
X	if (!note_on) {
X	    if (ourcolor == WHITE)
X		    message("--- WHITE ---", MESSAGE);
X	    else
X		    message("--- BLACK ---", MESSAGE);
X	}
X
X	if (!drawok [1 - color] && !drawok [color]
X	    && !resign && !dead) {
X		makemove (from, to, color);
X		if (occupant [to] == KING && to == from + 2)
X			makemove (from + 3, from + 1, color);
X		if (occupant [to] == KING && to == from - 2)
X			makemove (from - 4, from - 1, color);
X		lastmovefrom = from;
X		lastmoveto = to;
X	}
X	if (!resign && drawok [1 - color] && !drawok [color]) {
X		drawok [1 - color] = FALSE;
X		message("Draw refused.", LEGAL);
X	}
X
X	color = 1 - color;
X
X	checkdirs = check (color);
X
X	if (mate (pawnattempts, color)) {
X		if (checkdirs != NIL) {
X			message("CHECKMATE !", CHECK);
X			sprintf(buf, "%s wins.", colorname[1 - color]);
X			message(buf, TOMOVE);
X		} else {
X			message("STALEMATE", CHECK);
X			mclear(TOMOVE);
X		}
X		state = OVER;
X		mclear(PAWNTRIES);
X		return 0;
X	}
X	if (insufficient () || (drawok [WHITE] && drawok [BLACK])) {
X		message("Game ends in a draw.", CHECK);
X		mclear(TOMOVE);
X		mclear(PAWNTRIES);
X		state = OVER;
X		return 0;
X	}
X	if (resign) {
X		sprintf(buf, "%s resigns.", colorname[whose]);
X		message(buf, CHECK);
X		mclear(TOMOVE);
X		mclear(LEGAL);
X		mclear(PAWNTRIES);
X		state = OVER;
X		return 0;
X	}
X	if (dead) {
X		message("DEAD", CHECK);
X		message("lost your opponent (sorry)", MESSAGE);
X		state = OVER;
X		return 0;
X	}
X
X	pawnattempts = 0;
X	pawntries = countpawntries (color);
X	if (drawok[1 - color]) {
X		message("Draw offered.", LEGAL);
X		if (color == ourcolor)
X			message("Type y or n.", TOMOVE);
X		else
X			mclear(TOMOVE);
X	} else {
X		sprintf(buf, "%s to move", colorname[color]);
X		message(buf, TOMOVE);
X	}
X
X	if (option [ANNOUNCEPAWNS]) {
X		if(pawntries && pawnattempts < 3) {
X			if (pawntries == 1)
X				strcpy(buf, "1 pawntry");
X			else
X				sprintf(buf, "%d pawntries", pawntries);
X			message(buf, PAWNTRIES);
X		} else
X			mclear(PAWNTRIES);
X	} else
X		mclear(PAWNTRIES);
X
X	reportchecks (checkdirs, kingloc [color]);
X	return 0;
X}
X#else XKS
Xmovecycle ()
X{
X	int from, to, pawntries, pawnattempts, l;
X	LIST check (), checkdirs;
X
X	while (TRUE) {
X		mclear(CLOCK);
X		mclear(PROMPT);
X		pawnattempts = 0;
X		wprintw (win [TOMOVE], "%s to move\r", colorname [color]);
X		pawntries = countpawntries (color);
X		if (option [ANNOUNCEPAWNS] && pawntries && pawnattempts < 3)
X			if (pawntries == 1)
X				wprintw (win [PAWNTRIES], "1 pawntry");
X			else
X				wprintw (win [PAWNTRIES], "%d pawntries",
X					 pawntries);
X		checkdirs = check (color);
X		reportchecks (checkdirs, kingloc [color]);
X		if (mate (pawnattempts, color)) {
X			mclear(CHECK);
X			if (checkdirs != NIL)
X				message("CHECKMATE !", CHECK);
X			else
X				message("STALEMATE", CHECK);
X			state = OVER;
X			break;
X		}
X		if (insufficient () || (drawok [WHITE] && drawok [BLACK])) {
X			mclear(CHECK);
X			message("DRAW", CHECK);
X			state = OVER;
X			break;
X		}
X		if (resign) {
X			mclear(CHECK);
X			message("RESIGNS", CHECK);
X			state = OVER;
X			break;
X		}
X		if (dead) {
X			mclear(CHECK);
X			message("DEAD", CHECK);
X			mclear(MESSAGE);
X			state = OVER;
X			waddstr (win[MESSAGE], "lost your\nopponent\n(sorry)");
X		}
X		entermove (&from, &to, color, pawntries);
X		while ((l = legalmove (pawntries, &pawnattempts, checkdirs,
X				       from, to, color)) != TRUE
X		&& !drawok [color] && !drawok [1 - color]
X		&& !resign && !dead) {
X			illegal (l, color);
X			entermove (&from, &to, color, pawntries);
X		}
X		mclear(CAPTURE);
X		mclear(PAWNTRIES);
X		mclear(CHECK);
X		if (!drawok [1 - color] && !drawok [color]
X		&& !resign && !dead) {
X			makemove (from, to, color);
X			if (occupant [to] == KING && to == from + 2)
X				makemove (from + 3, from + 1, color);
X			if (occupant [to] == KING && to == from - 2)
X				makemove (from - 4, from - 1, color);
X			lastmovefrom = from;
X			lastmoveto = to;
X		}
X		if (drawok [1 - color] && !drawok [color])
X			drawok [color] = FALSE;
X		color = 1 - color;
X		mclear(MESSAGE);
X	}
X	mclear(TOMOVE);
X	mclear(CLOCK);
X	mclear(CAPTURE);
X	mclear(PAWNTRIES);
X	while (TRUE) {
X		waddstr (win [PROMPT], "\rreview game?");
X		mclear(MESSAGE);
X		waddstr (win [MESSAGE], "type y or n");
X		mclear(INPUT);
X		waddstr (win [INPUT], ": ");
X		move (win [INPUT]->_cury + win [INPUT]->_begy,
X		      win [INPUT]->_curx + win [INPUT]->_begx);
X		refresh ();
X		mclear(CHECK);
X		switch (getchar ()) {
X		case 'y':
X			mclear(PROMPT);
X			mclear(MESSAGE);
X			review();
X			break;
X		case 'n':
X			error ((char *) NULL);
X		default:
X			printf ("\007");
X		}
X	}
X}
X#endif XKS
END_OF_movecycle.c
if test 6178 -ne `wc -c <movecycle.c`; then
    echo shar: \"movecycle.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f screen.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"screen.c\"
else
echo shar: Extracting \"screen.c\" \(3147 characters\)
sed "s/^X//" >screen.c <<'END_OF_screen.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: screen.c,v 1.1 87/02/12 11:11:03 schoch Exp $";
X#endif
X
X#include "externs.h"
X#include <ctype.h>
X
Xmessage(s, where)
Xchar *s;
X{
X
X	waddstr(win[where], s);
X}
X
Xmclear(where)
X{
X	wclear(win[where]);
X}
X
Xinitscreen ()
X{
X	int ww, ws1, ws2, ws3, ws;
X	char *termtype, *getenv();
X
X	termtype = getenv("TERM");
X	vtterm = (!strncmp(termtype, "vt", 2) && !dumbterm);
X	if (vtterm)
X		COLS = 40;
X	if (dumbterm)
X		LINES = 10;
X	initscr();
X	noecho();
X	crmode();
X	if (SO == NIL || dumbterm)
X		reversescr = FALSE;
X	else
X		reversescr = TRUE;
X	if (vtterm) {
X		sqheight = 3;
X		sqwidth = 3;
X		sqcolor [WHITE] = ' ';
X		sqcolor [BLACK] = ' ';
X		backupscreen = newwin (LINES, COLS, 0, 0);
X		blankscreen = newwin (LINES, COLS, 0, 0);
X	} else if (reversescr) {
X		sqheight = 3;
X		sqwidth = 5;
X		sqcolor [WHITE] = ' ';
X		sqcolor [BLACK] = ' ';
X	} else {
X		sqheight = 1;
X		sqwidth = 2;
X		sqcolor [WHITE] = '.';
X		sqcolor [BLACK] = '*';
X	}
X	if (vtterm)
X		ws = sqwidth * 8 + 1;
X	else if (dumbterm)
X		ws = sqwidth * 8 + 4;
X	else
X		ws = sqwidth * 8 + 10;
X	ww = COLS - ws;
X	if (dumbterm) {
X		ww = ww / 3 - 1;
X		ws1 = ws + 1;
X		ws2 = ws1 + ww + 1;
X		ws3 = ws2 + ww + 1;
X		win [MYCOLOR] = subwin   (stdscr, 1, 15    ,  9,   3);
X		win [TOMOVE] = subwin    (stdscr, 1, ww    ,  1, ws3);
X		win [CLOCK] = newwin     (/*none*/1,  1    ,  1,   1);
X		win [CAPTURE] = subwin   (stdscr, 1, ww    ,  3, ws3);
X		win [PAWNTRIES] = subwin (stdscr, 1, ww    ,  4, ws3);
X		win [CHECK] = subwin     (stdscr, 3, ww    ,  5, ws3);
X		win [PROMPT] = subwin    (stdscr, 1, ww    ,  1, ws1);
X		win [INPUT] = subwin     (stdscr, 3, ww    ,  2, ws1);
X		win [LEGAL] = subwin     (stdscr, 1, ww    ,  5, ws1);
X		win [MESSAGE] = subwin   (stdscr, 4, ww    ,  1, ws2);
X		win [OPPONENT] = subwin  (stdscr, 5, ww    ,  5, ws2);
X		backupwin [PROMPT] = subwin    (stdscr, 1, ww    ,  1, ws1);
X		backupwin [MESSAGE] = subwin   (stdscr, 4, ww    ,  1, ws2);
X		backupwin [INPUT] = subwin     (stdscr, 3, ww    ,  2, ws1);
X	} else {
X		win [MYCOLOR] = subwin   (stdscr, 1, ww    ,  1, ws);
X		win [TOMOVE] = subwin    (stdscr, 1, ww - 1,  3, ws);
X		win [CLOCK] = subwin     (stdscr, 1,          1,  3, COLS-1);
X		win [CAPTURE] = subwin   (stdscr, 1, ww    ,  5, ws);
X		win [PAWNTRIES] = subwin (stdscr, 1, ww    ,  6, ws);
X		win [CHECK] = subwin     (stdscr, 3, ww    ,  7, ws);
X		win [PROMPT] = subwin    (stdscr, 1, ww    , 10, ws);
X		win [INPUT] = subwin     (stdscr, 3, ww    , 11, ws);
X		win [LEGAL] = subwin     (stdscr, 1, ww    , 14, ws);
X		win [MESSAGE] = subwin   (stdscr, 4, ww    , 15, ws);
X		win [OPPONENT] = subwin  (stdscr, 5, ww    , 19, ws);
X		scrollok (win [MESSAGE], TRUE);
X		scrollok (win [INPUT], TRUE);
X		backupwin [PROMPT] = subwin    (stdscr, 1, ww    , 10, ws);
X		backupwin [MESSAGE] = subwin   (stdscr, 4, ww    , 15, ws);
X		backupwin [INPUT] = subwin     (stdscr, 3, ww    , 11, ws);
X	}
X}
X
Xredraw_pos(pos)
X{
X	waddch(square[pos], sqcolor[(pos + pos / 10) % 2]);
X}
X
Xredraw_piece(pos)
X{
X	if (whose[pos] == ourcolor)
X		waddch(square[pos], symbol[occupant[pos]]);
X	else
X		waddch(square[pos], tolower(symbol[occupant[pos]]));
X}
X
Xdisplay_capture(color, piece)
X{
X}
END_OF_screen.c
if test 3147 -ne `wc -c <screen.c`; then
    echo shar: \"screen.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f traps.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"traps.c\"
else
echo shar: Extracting \"traps.c\" \(1191 characters\)
sed "s/^X//" >traps.c <<'END_OF_traps.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: traps.c,v 1.2 87/02/12 11:11:36 schoch Exp $";
X#endif
X
X#include "externs.h"
X#include <signal.h>
X
Xtrap_sigint ()
X{
X	int y, x;
X	char c;
X
X	signal (SIGINT, SIG_IGN);
X	getyx (stdscr, y, x);
X	overwrite (stdscr, backupscreen);
X	overwrite (win [PROMPT], backupwin[PROMPT]);
X	overwrite (win [MESSAGE], backupwin[MESSAGE]);
X	overwrite (win [INPUT], backupwin[INPUT]);
X	overwrite (blankscreen, stdscr);
X	wclear (win [PROMPT]);
X	wclear (win [MESSAGE]);
X	wclear (win [INPUT]);
X	waddstr (win [PROMPT], "Quit?");
X	waddstr (win [MESSAGE], "type y or n");
X	waddstr (win [INPUT], ": ");
X	move (win [INPUT]->_cury + win [INPUT]->_begy,
X	      win [INPUT]->_curx + win [INPUT]->_begx);
X	refresh ();
X	c = getchar();
X	while (c!='n' && c!='N' && c!='y' && c!='Y') {
X		if (c == '\f')  /*  ^L */
X			refresh ();
X		c = getchar();
X	}
X	if (c == 'y') {
X		if (out)
X			fputs("resign\r\n", out);
X		error ((char *) NULL);
X	}
X	overwrite (backupscreen, stdscr);
X	overwrite (backupwin [PROMPT], win [PROMPT]);
X	overwrite (backupwin [MESSAGE], win [MESSAGE]);
X	overwrite (backupwin [INPUT], win [INPUT]);
X	move (y, x);
X	touchwin (stdscr);
X	redraw ();
X	signal (SIGINT, trap_sigint);
X}
END_OF_traps.c
if test 1191 -ne `wc -c <traps.c`; then
    echo shar: \"traps.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xboard.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xboard.c\"
else
echo shar: Extracting \"xboard.c\" \(3608 characters\)
sed "s/^X//" >xboard.c <<'END_OF_xboard.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: xboard.c,v 1.6 87/05/19 17:21:01 schoch Exp $";
X#endif
X
X#include "externs.h"
X
Xstatic deltax, deltay;
Xstatic	Pixmap shadow;
Xstatic	int frompos;
Xstatic	bool realmove;
X
Xstartmove(pos, x, y)
X{
X
X    if (pos < 0)
X	return;
X    if (pos >= 100) {
X	fprintf(stderr, "Help!  pos out of range.\n");
X	return;
X    }
X    if (dead || resign || (drawok[BLACK] && drawok[WHITE])) {
X	message("The game is over!", TOMOVE);
X	return;
X    }
X    if (whose[pos] == OFFBOARD) {
X	int myx;
X
X	if (ourcolor == WHITE && (y < 64*8+TOPSPACE || y > 64*8+TOPSPACE+64))
X	    return;
X	if (ourcolor == BLACK && !reverse &&
X	    (y < TOPSPACE-64 || y > TOPSPACE))
X	    return;
X	if (ourcolor == BLACK && reverse &&
X	    (y < 64*8+TOPSPACE || y > 64*8+TOPSPACE+64))
X	    return;
X	if (x < 0 || x > 8*64)
X	    return;
X	myx = x - 16;
X	if (myx < 0)
X	    pos = 0;
X	else
X	    pos = myx / 32;
X	pos += (ourcolor == WHITE) ? 16 : 0;
X	if (captured[pos] == 0) {
X	    if (myx % 32 < 16)
X		pos--;
X	    else
X		pos++;
X	    if (pos < 0)
X		return;
X	    if (captured[pos] == 0)
X		return;
X	}
X	move = 1;
X	deltax = x - (pos%16)*32;
X	deltay = y-TOPSPACE;
X	if (ourcolor == WHITE || reverse)
X	    deltay -= 64*8;
X	else
X	    deltay += 64;
X	shadow = pieces_icons[captured[pos]];
X	frompos = -pos;
X	realmove = FALSE;
X	goto done;
X    }
X    if ((occupant[pos] == 0 || whose[pos] == theircolor) && ghost[pos] == 0)
X	return;
X    if (whose[pos] == ourcolor) {
X	if (color != ourcolor) {
X	    message("It's not your turn!", TOMOVE);
X	    return;
X	} else if (drawok[theircolor]) {
X	    message("Respond with 'y' or 'n'", TOMOVE);
X	    return;
X	} else
X	    realmove = TRUE;
X    } else
X	realmove = FALSE;		/* ghost */
X    move = 1;
X    frompos = pos;
X    if (reverse) {
X	deltax = x - (8-pos%10)*64;
X	deltay = y-TOPSPACE - (8-pos/10)*64;
X    } else {
X	deltax = x - (pos%10-1)*64;
X	deltay = y-TOPSPACE - (pos/10-1)*64;
X    }
X    /* Do sanity checking here! */
X    if (ghost[pos])
X	shadow = pieces_icons[ghost[pos]];
X    else
X	shadow = pieces_icons[occupant[pos]];
Xdone:
X    XPixmapPut(window, 0, 0, x-deltax, y-deltay, 64, 64, shadow, GXxor, 1);
X}
X
Xstopmove(pos, x, y)
X{
X    bool *arr;
X    int ox, oy;
X
X    if (move == 0)
X	return;
X    move = 0;
X    /* Remove shadow */
X    XPixmapPut(window, 0, 0, x - deltax, y - deltay, 64, 64, shadow, GXxor, 1);
X
X    if (pos < 0)	/* out of window */
X	return;
X    if (pos == frompos)
X	return;		/* didn't move anywhere */
X
X    /* Check if opponent resigned while we were in the process of moving. */
X    if (dead || resign || (drawok[BLACK] && drawok[WHITE]))
X	return;
X    if (realmove == FALSE) {		/* move a ghost */
X	if (frompos <= 0) {
X	    frompos = -frompos;
X	    arr = captured;
X	    if (whose[pos] == OFFBOARD)
X		return;		/* it didn't go anywhere */
X	} else
X	    arr = ghost;
X	if (whose[pos] == ourcolor || ghost[pos])
X	    return;			/* A ghost can't capture. */
X	if (arr == ghost)
X	    redraw_pos(frompos);
X	else {
X	    ox = (frompos % 16) * 32;
X	    if (reverse)
X		oy = TOPSPACE + ((frompos>15) ? -64 : 64*8);
X	    else
X		oy = TOPSPACE + ((frompos>15) ? 64*8 : -64);
X	    XPixmapPut(window, 0, 0, ox, oy, 64, 64, shadow, GXandInverted, 1);
X	}
X	if (whose[pos] == OFFBOARD) {
X	    ghost_capture(frompos);
X	    ghost[frompos] = 0;
X	    return;
X	}
X	ghost[pos] = arr[frompos];
X	arr[frompos] = 0;
X	redraw_ghost(pos);
X	return;
X    }
X    if (whose[pos] == OFFBOARD) {
X	return;
X    }
X    domove(frompos, pos);
X
X}
X
Xpiecemove(oldx, oldy, x, y)
X{
X
X    XPixmapPut(window, 0, 0, oldx-deltax,oldy-deltay,
X	64, 64, shadow, GXxor, 1);
X    XPixmapPut(window, 0, 0, x - deltax, y - deltay,
X	64, 64, shadow, GXxor, 1);
X}
END_OF_xboard.c
if test 3608 -ne `wc -c <xboard.c`; then
    echo shar: \"xboard.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xmain.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xmain.c\"
else
echo shar: Extracting \"xmain.c\" \(3140 characters\)
sed "s/^X//" >xmain.c <<'END_OF_xmain.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: xmain.c,v 1.7 87/05/19 17:19:25 schoch Exp $";
X#endif
X
X#include <strings.h>
X#include <ctype.h>
X#include <sys/signal.h>
X#include <errno.h>
X#include "externs.h"
X
Xextern int errno;
X
XLIST	dirlist[7];
XLIST	piecelocs[2];
Xint	kingloc[2];
Xu_char	whose[100];
Xu_char	occupant[100];
Xu_char	virgin[100];
Xu_char	ghost[100];
Xu_char	captured[32];
Xu_char	ourcolor = UNSET;
Xu_char	theircolor = UNSET;
Xu_char	state = PLAYING, color=WHITE;
Xbool	iamserver = UNSET;
Xbool	drawok[2];
Xbool	resign, dead;
Xbool	reverse;
Xu_char	option[NOPTIONS];
Xint	pawndir[2] = { -10, 10 };
Xint	lastmovefrom = 0;
Xint	lastmoveto = 0;
XMOVELIST movelist = (MOVELIST)NULL;
X
XDisplay *display;
XOpaqueFrame frame;
X
Xchar *malloc();
Xlong random();
X
Xmain(argc, argv)
Xchar **argv;
X{
X    int i;
X    u_short port=0;
X    char *displayname = NULL;
X    char *program;
X    char *geometry = NULL;
X    char *cp;
X
X    if (program = rindex(argv[0], '/'))
X	program++;
X    else
X	program = argv[0];
X    for(i = 0; i < NOPTIONS; i++)
X	option[i] = UNSET;
X    srandom(time(0) ^ getpid());
X    argc--; argv++;
X    while (argc) {
X	if (*argv[0] == '-' || *argv[0] == '+') {
X	    if (*argv[0] == '-')
X		i = FALSE;
X	    else
X		i = TRUE;
X	    while (*++(*argv))
X		switch (*argv[0]) {
X		    case 'b':
X			option[COLOR] = BLACK;
X			break;
X		    case 'w':
X			option[COLOR] = WHITE;
X			break;
X		    case 'c':
X			option[COLOR] = RANDOM;
X			break;
X		    case 'a':
X			option[ANNOUNCETAKES] = i;
X			break;
X		    case 'p':
X			option[ANNOUNCEPAWNS] = i;
X			break;
X		    case 'r':
X			reverse = TRUE;
X			break;
X		    case 's':
X			iamserver = i;
X			break;
X		    default:
X			goto usage;
X		}
X	    argv++; argc--;
X	    continue;
X	}
X	if ((cp = index(*argv, ':')) && isdigit(cp[1])) {
X	    displayname = *argv;
X	    argv++; argc--;
X	    continue;
X	}
X	if (*argv[0] == '=') {
X	    geometry = *argv;
X	    argv++; argc--;
X	    continue;
X	}
X	break;
X    }
X    if (argc != 1) {
Xusage:
X	fprintf(stderr, "Usage: xks [-+][bwcaprs] [=[width]x[height][[+-]xoff[[+-]yoff]]]\n");
X	fprintf(stderr, "\t[display:name] user[@host]\n");
X	exit(1);
X    }
X
X    display = XOpenDisplay(displayname);
X    if (display == NULL) {
X	fprintf(stderr, "Can't open display %s\n", displayname);
X	exit(1);
X    }
X
X    frame.border = WhitePixmap;
X    frame.background = BlackPixmap;
X    frame.bdrwidth = 2;
X    window = XCreate("xks", program, geometry, "=0x0+0+0", &frame,
X	64*8+1, 64*9+18*3+TOPSPACE);
X    if (window == 0) {
X	fprintf(stderr, "Can't create window\n");
X	cleanup(1);
X    }
X
X    XMapWindow(window);
X    initdirlists();
X    initpiecelocs();
X    font = XGetFont("timrom12bsx");
X    if (font == 0) {
X	fprintf(stderr, "Can't get font.\n");
X    }
X    screen_init();
X    p_init();
X    signal(SIGINT, cleanup);
X    message("Connecting...", MESSAGE);
X    XFlush();
X    connectport(*argv, port);
X    dooptions();
X    if (ourcolor == WHITE) {
X	    message("--- WHITE ---", MESSAGE);
X	    reverse = FALSE;
X    } else
X	    message("--- BLACK ---", MESSAGE);
X    initboard(FALSE);
X    redraw();
X    movecycle();
X}
X
Xcleanup(sig)
Xint sig;
X{
X    if (out)
X	fputs(out, "resign\r\n");
X    XCloseDisplay(display);
X    exit(sig);
X}
END_OF_xmain.c
if test 3140 -ne `wc -c <xmain.c`; then
    echo shar: \"xmain.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xpieces.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xpieces.c\"
else
echo shar: Extracting \"xpieces.c\" \(6072 characters\)
sed "s/^X//" >xpieces.c <<'END_OF_xpieces.c'
X#ifndef lint
Xstatic char rcsid[] = "$Header: xpieces.c,v 1.9 87/05/19 18:46:27 schoch Exp $";
X#endif
X
X#include "externs.h"
X
X#define piece_width 64
X#define piece_height 64
X#include "pawn.h"
X#include "pawn_mask.h"
X#include "bishop.h"
X#include "bishop_mask.h"
X#include "queen.h"
X#include "queen_mask.h"
X#include "king.h"
X#include "king_mask.h"
X#include "rook.h"
X#include "rook_mask.h"
X#include "knight.h"
X#include "knight_mask.h"
X#include "icon.h"
X
XPixmap icon_pixmap;
X
Xp_init()
X{
X    Pixmap mask, piece;
X    Bitmap bp;
X
X    bp = XStoreBitmap(piece_width, piece_height, pawn_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[PAWN] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, pawn_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[PAWN] = mask;
X
X
X    bp = XStoreBitmap(piece_width, piece_height, bishop_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[BISHOP] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, bishop_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[BISHOP] = mask;
X
X
X    bp = XStoreBitmap(piece_width, piece_height, queen_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[QUEEN] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, queen_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[QUEEN] = mask;
X
X
X    bp = XStoreBitmap(piece_width, piece_height, king_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[KING] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, king_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[KING] = mask;
X
X
X    bp = XStoreBitmap(piece_width, piece_height, rook_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[ROOK] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, rook_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[ROOK] = mask;
X
X
X    bp = XStoreBitmap(piece_width, piece_height, knight_bits);
X    piece = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_icons[KNIGHT] = piece;
X
X    bp = XStoreBitmap(piece_width, piece_height, knight_mask_bits);
X    mask = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X    pieces_masks[KNIGHT] = mask;
X
X    bp = XStoreBitmap(icon_width, icon_height, icon_bits);
X    icon_pixmap = XMakePixmap(bp, WhitePixel, BlackPixel);
X    XFreeBitmap(bp);
X
X    iconwindow = XCreateWindow(RootWindow, 0, 0,
X	    icon_width, icon_height, 0, 0, 0);
X
X    XSetIconWindow(window, iconwindow);
X    XSelectInput(iconwindow, ExposeWindow);
X}
X
Xredraw_pieces()
X{
X    int row, col, spot;
X
X    for (row = 1; row <= 8; row++)
X	for (col = 1; col <= 8; col++) {
X	    spot = 10 * row + col;
X	    if (ghost[spot] && state == PLAYING)
X		redraw_ghost(spot);
X	    else if (whose[spot] == ourcolor ||
X		(state != PLAYING && occupant[spot]))
X		    redraw_piece(spot);
X	}
X    XPixSet(window, 0, 18, 64*8, 64, BlackPixel);
X    XPixSet(window, 0, TOPSPACE+64*8, 64*8, 64, BlackPixel);
X    for (spot = 0; spot < 32; spot+=2)
X	if (captured[spot])
X	    redraw_captured(spot);
X    for (spot = 1; spot < 32; spot+=2)
X	if (captured[spot])
X	    redraw_captured(spot);
X}
X
Xredraw_ghost(spot)
X{
X    Pixmap mask, icon;
X    register x, y;
X
X    if (reverse) {
X	x = (8-spot%10) * 64;
X	y = (8-spot/10) * 64 + TOPSPACE;
X    } else {
X	x = (spot%10-1) * 64;
X	y = (spot/10-1) * 64 + TOPSPACE;
X    }
X    if (ghost[spot] == 0) {
X	fprintf("no ghost at %d\n", spot);
X	return;
X    }
X    mask = pieces_masks[ghost[spot]];
X    icon = pieces_icons[ghost[spot]];
X
X    if (mask == 0) {
X	fprintf(stderr, "Invalid mask for location %d, occupied by %d\n",
X	    spot, ghost[spot]);
X	return;
X    }
X    if (icon == 0) {
X	fprintf(stderr, "Invalid icon for location %d, occupied by %d\n",
X	    spot, ghost[spot]);
X	return;
X    }
X    XPixmapPut(window, 0, 0, x, y, 64, 64,
X	icon, (theircolor==WHITE) ? GXor : GXandInverted, 1);
X}
X
Xredraw_piece(spot)
X{
X    Pixmap mask, icon;
X    register x, y;
X
X    if (reverse) {
X	x = (8-spot%10) * 64;
X	y = (8-spot/10) * 64 + TOPSPACE;
X    } else {
X	x = (spot%10-1) * 64;
X	y = (spot/10-1) * 64 + TOPSPACE;
X    }
X    if (whose[spot] != ourcolor && state == PLAYING) {
X	fprintf(stderr, "cannot draw spot %d: occupied by %d\n",
X	    spot, occupant[spot]);
X	return;
X    }
X    mask = pieces_masks[occupant[spot]];
X    icon = pieces_icons[occupant[spot]];
X
X    if (mask == 0) {
X	fprintf(stderr, "Invalid mask for location %d, occupied by %d\n",
X	    spot, occupant[spot]);
X	return;
X    }
X    if (icon == 0) {
X	fprintf(stderr, "Invalid icon for location %d, occupied by %d\n",
X	    spot, occupant[spot]);
X	return;
X    }
X    if (ghost[spot])
X	redraw_pos(spot);
X    XPixmapPut(window, 0, 0, x, y, 64, 64,
X	mask, (whose[spot]==WHITE) ? GXor : GXandInverted, 1);
X    XPixmapPut(window, 0, 0, x, y,
X	64, 64, icon, (whose[spot]==WHITE) ? GXandInverted :
X	GXor, 1);
X}
X
Xredraw_captured(n)
X{
X    int piece = captured[n];
X    int color;
X    int x, y;
X    Pixmap mask, icon;
X
X    if (n < 16) {
X	y = 18;
X	color = WHITE;
X    } else {
X	n -= 16;
X	y = 64+18 + 8*64;
X	color = BLACK;
X    }
X    if (reverse) {
X	if (color == WHITE)
X	    y = 64+18 + 8*64;
X	else
X	    y = 18;
X    }
X    x = n*32;
X    mask = pieces_masks[piece];
X    icon = pieces_icons[piece];
X    if (mask == 0 || icon == 0)
X	return;
X    if (color == ourcolor || state != PLAYING) {
X	XPixmapPut(window, 0, 0, x, y, 64, 64,
X	    mask, (color==WHITE) ? GXor : GXandInverted, 1);
X	XPixmapPut(window, 0, 0, x, y,
X	    64, 64, icon, (color==WHITE) ? GXandInverted :
X	    GXor, 1);
X    } else
X	XPixmapPut(window, 0, 0, x, y, 64, 64, icon, GXor, 1);
X}
X
Xredraw_icon(reverse)
Xbool reverse;
X{
X	XPixmapPut(iconwindow, 0, 0, 0, 0, icon_width, icon_height,
X	    icon_pixmap, reverse ? GXcopyInverted : GXcopy, 1);
X}
END_OF_xpieces.c
if test 6072 -ne `wc -c <xpieces.c`; then
    echo shar: \"xpieces.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 2 \(of 4\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0