[comp.sources.games] v04i006: xgo - go for curses or X-windows, Part02/04

games@tekred.TEK.COM (04/09/88)

Submitted by: Greg Hale <sting.berkeley.edu!hale@ucbvax>
Comp.sources.games: Volume 4, Issue 6
Archive-name: xgo/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:  Makefile changes.c curse.c doloop.c go.h life.c main.c
#   mesg.c opts.c putpiece.c score.c strength.c xbit.c xclick.c
#   xexpose.c xinitloop.c xloop.c xmesg.c xwindow.c
# Wrapped by billr@saab on Fri Apr  8 14:27:15 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(4220 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
X#
X# Makefile for Go and Xgo
X# by Greg Hale
X# Monday, June 8, 1987
X#	Excuse the joe-makefile for the joe-code
X#
X
XCFLAGS= -DBINDIR=\"${BINDIR}\"
X
X# name of the man page file
X# go.l will run through lex so we need a different name
X
XMANSRC=go.6
XMAN1=go.doc
X
X# destination manual pages
XMAN=go.doc
XDESTMAN=go.doc
XDESTXMAN=xgo.doc
X
X# destination directory
XMANDIR=/usr/public
X
X# PROGRAM NAMES
XXGO=xgo
XGO=go
X
X# archive program & file to make
XSHAR=shar
XSHARCHIVE=go.shar
X
XFTPDIR=/a/ftp/ftp
XBINDIR=/usr/public
X
X# Sample games directory
X
XGAMES=games
XSAMPLENAME=go.samples
XSAMPLEDIR= $(BINDIR)/$(SAMPLENAME)
X
X
X# files which make up the shell archive along with sources
XFILES = README Makefile $(GAMES) $(MAN1) $(MAN) go.players
X
X# This is where the list of go.players goes
XETCDIR=/usr/public
X
XMOBJECTS = chkmve.o \
X	curse.o \
X	doloop.o \
X	exit.o \
X	go.o \
X	init.o \
X	loop.o \
X	mesg.o \
X	movecur.o \
X	moveto.o \
X	plt.o \
X	printboard.o \
X	status.o \
X	traps.o \
X	util.o
X
XXOBJECTS = xbit.o \
X	xclick.o \
X	xexit.o \
X	xexpose.o \
X	xgo.o \
X	xinit.o \
X	xinitloop.o \
X	xio.o \
X	xkeyp.o \
X	xloop.o \
X	xmesg.o \
X	xplt.o \
X	xprintboard.o \
X	xstatus.o \
X	xtraps.o \
X	xutil.o \
X	xvar.o \
X	xwindow.o
X
XSHARED = changes.o \
X	connect.o \
X	backup.o \
X	del.o \
X	dohand.o \
X	doother.o \
X	file.o \
X	fill.o \
X	handicap.o \
X	initboard.o \
X	kill.o \
X	killit.o \
X	life.o \
X	looputil.o \
X	main.o \
X	setboard.o \
X	strength.o \
X	tally.o \
X	help.o \
X	opts.o \
X	putpiece.o \
X	score.o \
X	var.o \
X	nomove.o
X
XSRCS =	backup.c changes.c chkmve.c \
X	connect.c curse.c del.c \
X	dohand.c doloop.c doother.c \
X	exit.c file.c  fill.c \
X	go.c  handicap.c  help.c \
X	init.c  initboard.c  kill.c \
X	killit.c  life.c  loop.c \
X	looputil.c  main.c  mesg.c \
X	movecur.c  moveto.c  nomove.c \
X	opts.c \
X	plt.c \
X	printboard.c \
X	putpiece.c \
X	score.c \
X	setboard.c \
X	status.c \
X	strength.c \
X	tally.c \
X	traps.c \
X	util.c \
X	var.c \
X	xbit.c \
X	xclick.c \
X	xexit.c \
X	xexpose.c \
X	xgo.c \
X	xinit.c \
X	xinitloop.c \
X	xio.c \
X	xkeyp.c \
X	xloop.c \
X	xmesg.c \
X	xplt.c \
X	xprintboard.c \
X	xstatus.c \
X	xtraps.c \
X	xutil.c \
X	xvar.c \
X	xwindow.c
X
XHDRS =	XButton.h \
X	Xblack.h \
X	Xcursblk.h \
X	Xcursmsk.h \
X	Xcurswht.h \
X	Xd.h \
X	Xdl.h \
X	Xdr.h \
X	Xfbl.h \
X	Xfwh.h \
X	Xintersect.h \
X	Xl.h \
X	Xmask.h \
X	Xmask0.h \
X	Xneu.h \
X	Xpiecemask.h \
X	Xpoint.h \
X	Xr.h \
X	Xu.h \
X	Xul.h \
X	Xur.h \
X	Xwhite.h \
X	go.h \
X	mesg.h \
X	xgo.h \
X	xpiecenum.h \
X	xwin.h
X
Xall: $(GO) $(XGO) $(MAN) $(MAN1)
X
X$(GO): $(MOBJECTS) $(SHARED)
X	@echo "loading $(GO)..."
X	@cc $(MOBJECTS) $(SHARED) -lcurses -ltermlib -o $(GO);
X	@echo "done."
X
X
X$(XGO): $(XOBJECTS) $(SHARED)
X	@echo "loading $(XGO)..."
X	@cc $(XOBJECTS) $(SHARED) -lcurses -ltermlib -lX -o $(XGO);
X	@echo "done."
X
X$(MAN): $(MANSRC) $(MAN1)
X
X$(MAN1): $(MANSRC)
X	@echo -n "typesetting manual..."
X	@nroff -man $(MANSRC) > $(MAN1)
X	@echo "done."
X
Xtags:
X	ctags *.c *.h
X
Xclean:
X	@echo -n "removing extra files..."
X	@-rm -f *.o $(GO) $(XGO) $(SHARCHIVE) $(SHARCHIVE).Z
X	@echo "done."
X
Xclx:
X	@-rm -f x*.o $(XGO)
X
Xinstallgo: $(GO)
X	@echo "Installing go..."
X	-install -m 755 $(GO) $(BINDIR)
X	-install -m 666 go.players $(ETCDIR)
X	-install -m 644 $(MAN) $(MANDIR)/$(DESTMAN)
X	@-rm -f $(SAMPLEDIR)
X	-ln -s `pwd`/$(GAMES) $(SAMPLEDIR)
X	echo "done"
X
Xinstall:
X	@echo "Installing go/xgo..."
X	-install -m 755 $(XGO) $(BINDIR)
X	-install -m 755 $(GO) $(BINDIR)
X	-install -m 666 go.players $(ETCDIR)
X	-install -m 644 $(MAN) $(MANDIR)/$(DESTMAN)
X	@-rm -f $(MANDIR)/$(DESTXMAN)
X	ln -s $(MANDIR)/$(DESTMAN) $(MANDIR)/$(DESTXMAN)
X	@-rm -f $(SAMPLEDIR)
X	ln -s `pwd`/$(GAMES) $(SAMPLEDIR)
X	@echo "done"
X
X$(SHARCHIVE): $(SRCS) $(HDRS) $(FILES)
X	@echo -n "making shell archive..."
X	@$(SHAR) $(FILES) $(SRCS) $(HDRS) > $@
X	@echo "done"
X
Xshar: $(SHARCHIVE)
X
Xftp: $(SHARCHIVE)
X	@echo -n "installing shell archive..."
X	@compress $(SHARCHIVE)
X	@install -m 644 $(SHARCHIVE).Z $(FTPDIR)/src
X	@echo "done"
X
Xmake:
X	mkmf -d
X
X$(XOBJECTS): xgo.h go.h
X$(MOBJECTS): go.h
X$(SHARED): go.h
Xxbit.c: X*.h
Xxwindow.c: xwin.h
Xxexpose.c: xwin.h
Xxio.c: xwin.h
X
X
X# $Log:	Makefile,v $
X# Revision 1.4  88/02/19  14:02:09  hale
X# added sample games installation and archive
X# 
X# Revision 1.3  88/02/19  13:46:29  hale
X# small changes in CFLAGS
X# 
X# Revision 1.2  88/02/13  12:58:04  hale
X# added logging.
X# 
X# 
X
END_OF_Makefile
if test 4220 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f changes.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"changes.c\"
else
echo shar: Extracting \"changes.c\" \(1888 characters\)
sed "s/^X//" >changes.c <<'END_OF_changes.c'
X/*
X * $Header: changes.c,v 1.2 88/02/13 12:42:04 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
Xchanges()
X{
X    extern int changeflg;
X    if (changeflg) {
X	printf("\
X----------------------------------------------------------------------\n\
X\n\
X			   GO $Revision$\n\
X			     By Greg Hale\n\
X\n\
XWelcome to the oriental game of go.  If you do not know how to play,\n\
XI recommend that you read the documentation or find someone who knows\n\
Xhow to play.\n\
X\n\
XThis program was developed at the Experimental Computing Facility at the\n\
XUniversity of California, Berkeley, by Greg Hale.  Thanks to all the\n\
Xother members for their input, support, and test playing.\n\
X\n\
X12/20/87: backwards-incompatable version\n\
X	new command line arguments, variable board size,\n\
X	last move option, stregth kept track of.\n\
X1/30/88: backwards-incompatable version\n\
X	demonstration/instructional mode and quiet beeping\n\
X	added.\n\
X2/10/88: fixed bug in decline/cancel actions, changed scoring\n\
X	and rank procedures.  Slight modification to demo mode.\n\
X	Komi added to score, scoring mode modified, command line\n\
X	arguments, and resignation is a possible way to exit the\n\
X	game.\n\
X\n\
X----------------------------------------------------------------------\n\
X");
X	printf("[Hit return to continue]");
X	getchar();
X    }
X}
X/*
X * $Log:	changes.c,v $
X * Revision 1.2  88/02/13  12:42:04  hale
X * added logging, updated time
X * 
X */
X
END_OF_changes.c
if test 1888 -ne `wc -c <changes.c`; then
    echo shar: \"changes.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f curse.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"curse.c\"
else
echo shar: Extracting \"curse.c\" \(1841 characters\)
sed "s/^X//" >curse.c <<'END_OF_curse.c'
X/*
X * $Header: curse.c,v 1.3 88/02/19 13:46:58 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X
X
Xcurpos = 0;
X#define OFFX (2*MAXX+2)
X#define MAXL 23
X
Xconnectmes()
X{
X	extern char *myname, myhostname[];
X	mvaddstr (0,1,"Waiting for other player to start his process.");
X	mvaddstr (1,1,sprintf(buf,"Have him type \"go/xgo %s[@%s]\"",
X		myname,&myhostname[0]));
X	refresh ();
X}
X
Xdoneconnectmes()
X{
X	clear();
X	refresh();
X}
X
XCLEAR()
X{
X	clear();
X	refresh();
X}
X
XDoQuit()
X{
X	char c;
X	addmes("- Opponent wishes to quit.  Do you accept? (y/n)");
X	do c = GetAKey0();
X	while (c!='y' && c!='n');
X	if (c=='y') {
X		SEND(MACCEPT);
X		Score();
X	} else {
X		dodecline();
X		SEND(MDECLINE);
X	}
X	move(0,0);
X	clrtoeol();
X	refresh();
X}
X
X
X#define mesgy 1
X#define mesgy2 5
X#define mesgx 42
X
X
Xaddmes(mes)
Xchar *mes;
X{
X	do {
X	    move(curpos+mesgy,mesgx);
X	    printw("%.35s",mes);
X	    curpos = (curpos + 1) % (mesgy2-mesgy+1);
X	    move(curpos+mesgy,mesgx);
X	    clrtoeol();
X	    if (strlen(mes)<=35) break;
X	    else mes+=35;
X	} while(1);
X	refresh();
X}
X
Xbeginline()
X{
X	move(curpos+mesgy,OFFX);
X}
X
X/*
X * $Log:	curse.c,v $
X * Revision 1.3  88/02/19  13:46:58  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.2  88/02/13  12:44:18  hale
X * added logging.
X * 
X */
X
END_OF_curse.c
if test 1841 -ne `wc -c <curse.c`; then
    echo shar: \"curse.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f doloop.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"doloop.c\"
else
echo shar: Extracting \"doloop.c\" \(2953 characters\)
sed "s/^X//" >doloop.c <<'END_OF_doloop.c'
X/*
X * $Header: doloop.c,v 3.0 88/03/10 12:07:19 hale Locked $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X
Xextern int mesflg, demflg, loadflg;
X
X
XDoLoop()
X{
X	char c;
X	c = GetAKey0();
X	if (mesflg) domesg(c);
X	else if ((c=='e') || (!chkmve(c) && !disable)) {
X		switch (c) {
X			WHEN REDRAW: touchwin(stdscr);
X				clear();
X				PrintBoard(&board);
X
X
X			WHEN 'e':
X				SetStat(EXIT);
X				SEND(MEXIT);
X			
X			WHEN 'S':
X				dosave();
X			WHEN '#':
X				if (loadflg) doload();
X				else Beep();
X
X			WHEN 'q': if (AreWe(SCORE)) {
X					SEND(MQUIT);
X					disable = 1;
X					}
X			WHEN 't': if (AreWe(SCORE)) dotally();
X
X			WHEN 'c': if (AreWe(SCORE)) {
X				docancel();
X				SEND(MCANCEL);
X				}
X
X			WHEN 'C': 
X				if (demflg && AreWe(HANDICAP)) {
X					SEND(MCLEAR);
X					doclear();
X				}
X
X			WHEN 'm':
X				mesflg++;
X				
X			WHEN 'R':
X				SEND(MRESIGN);
X				doresign(true);
X
X			WHEN 's': if(AreWe(HANDICAP)) {
X					SEND(MSWITCH);
X					doswitch();
X				} else if (AreWe(PLAY)) {
X					SEND(MSCORE);
X					ClrStat(PLAY);
X					doscore();
X				}
X
X			WHEN '/': if (AreWe(PLAY)) {
X					ShowLast();
X				    } else Beep();
X			WHEN 'p': if (AreWe(PLAY) && myturn) {
X					curplr = !curplr;
X					SEND(MPASS);
X				} else if (AreWe(HANDICAP)) {
X					SEND(MPLAY);
X					doplay();
X				}
X			WHEN '?': help(); PrintBoard(&board);
X
X			WHEN '1': DoHand(cx,cy,0);
X			WHEN '2': DoHand(cx,cy,1);
X
X
X			WHEN ' ':
X				if (AreWe(HANDICAP))
X					if (demflg)
X						dodemo(cx,cy,1);
X					else
X						sethand(cx,cy,!b(cx,cy));
X				else if (AreWe(SCORE))
X					doscorehit(cx,cy);
X				else if (AreWe(PLAY) && myturn)
X					putpiece(cx,cy,curplr,true);
X			OTHERWISE: ;
X		}
X	}
X}
X/*
X * $Log:	doloop.c,v $
X * Revision 3.0  88/03/10  12:07:19  hale
X * Added save games, a few changes to the I/O,
X * added load and clear options.  Not thouroughly tested, though, and
X * I think a few bugs are in the load code.  A library of sample problems
X * has been started and saved with the working directory.
X * 
X * Revision 1.4  88/02/19  13:48:21  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:22:46  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:46:27  hale
X * added several commands for save game and resign.
X * 
X */
X
END_OF_doloop.c
if test 2953 -ne `wc -c <doloop.c`; then
    echo shar: \"doloop.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f go.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"go.h\"
else
echo shar: Extracting \"go.h\" \(2630 characters\)
sed "s/^X//" >go.h <<'END_OF_go.h'
X/*
X * $Header: go.h,v 1.2 88/02/13 12:57:08 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include <curses.h>
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <errno.h>
X
X#include "mesg.h"
X/* #include "externs.h" */
X
X
X
X/*
X * HOW TO PRINT THE MAN PAGE- default is 
X * "nroff -man /usr/man/manl/go.l | /usr/ucb/more"
X */
X#define	HELP_CMD "/usr/ucb/more /usr/public/go.doc"
X
X#define MAXDIM 19		/* maximum dimension */
X#define MINDIM 9		/* minimum board dimension */
X#define DEFAULTPORT 525		/* default port to connect with */
X
X#define GOFILE "/.go_strength"	/* information on player's strength */
X#define DEFAULTSTR 1		/* default strength if never played */
X#define MAXSTR 48		/* count from 1... maxstr */
X#define WINSUP 6		/* how many wins (losses) in a row are needed to
X				 * go up a rank if you are weaker than
X				 * the other player. */
X#define KOMI	5.5		/* standard komi- add to white at end of game */
X
X
X#define P1 1			/* board types - player 1 pieces */
X#define P2 2			/* player 2 pieces */
X#define NONE 0			/* nothing */
X#define MARK 3			/* neutral/marks for searches */
X
X
X#define FASTMOVE 3		/* speed with <shift><dir> */
X#define REDRAW '\014'		/* ^l */
X#define MAXBUF 200		/* maximum line buffer */
X
X#define DEBUG(m) 
X
X
X#define WHEN break; case
X#define OTHERWISE break; default
X#define and &&
X#define or ||
X
X#define true 1
X#define false 0
X#define UNSET 2
X
X
X#define error(x) { fprintf(stderr,x); Exit(); }
X
X#define SEND(m)  sendit(m)
X#define RECV(m) receive(m)
X
Xtypedef struct { char d[MAXDIM][MAXDIM]; } BOARD;
X#define b(x1,y1) board.d[x1][y1]	/* JOE CODE- lazy hack. */
X#define m(x2,y2) marks.d[x2][y2]	/* my apologies */
X
X#define HITAKEYMES "[Hit any key]"
X
X#define SCORE		0x1		/* state values */
X#define QUIT		0x2
X#define EXIT		0x4
X#define REDRAWING	0x8
X#define CANCEL		0x10
X#define PLAY		0x20
X#define HANDICAP	0x40
X
Xextern BOARD backup,board,marks;
Xextern int curplr,hama[],MAXX,MAXY,cx,cy;
Xextern int disable,myturn,sock,sockmask[],status,player,dimensions;
Xextern char *blanks,display[];
Xextern char pieces[], buf[];
Xextern bool iamserver;
Xextern int iwon;
X/*
X * $Log:	go.h,v $
X * Revision 1.2  88/02/13  12:57:08  hale
X * added logging.
X * 
X */
X
END_OF_go.h
if test 2630 -ne `wc -c <go.h`; then
    echo shar: \"go.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f life.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"life.c\"
else
echo shar: Extracting \"life.c\" \(1623 characters\)
sed "s/^X//" >life.c <<'END_OF_life.c'
X/*
X * $Header: life.c,v 1.2 88/02/13 12:49:45 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X
XIsSafe(x,y)
Xint x,y;
X{
X	int t;
X	if (!ir(x,y) || (t = b(x,y))==NONE) return (false);
X	InitBoard(&marks);
X	return (esc(x,y,t));
X}
X
Xesc(x,y,t)
Xint x,y,t;
X{
X	if (!ir(x,y)) return (false);
X	if (b(x,y)==NONE) return(true);
X	if (!m(x,y) && b(x,y)==t) {
X	    m(x,y)=MARK;
X	    return( esc(x-1,y,t) ||
X		    esc(x+1,y,t) ||
X		    esc(x,y-1,t) ||
X		    esc(x,y+1,t));
X	}
X	return (false);
X}
X
X
XOwner(x,y)
Xint x,y;
X{
X	int o;
X	InitBoard(&marks);
X	o= Owner0(x,y);
X	return(o==-1? 3: o);
X}
X
XOwner0(x,y)
Xint x,y;
X{
X	int c,n;
X	if (m(x,y) || !ir(x,y)) return 3;
X	m(x,y)=1;
X	if (b(x,y)!=NONE) return (b(x,y)+3);
X	return( New( New( New( New(3,x-1,y), x+1,y), x,y-1), x,y+1) );
X		   
X}
X
XNew(o,x2,y2)	/* 3= undetermined, 4=p1, 5=p2, -1=shared */
Xreg int o;
Xint x2,y2;
X{
X	reg int n; /* old, new */
X	n= Owner0(x2,y2);
X	if (o==3) return n;
X	if (n==3) return o;
X	if (o<0) return o;
X	return (n==o ? o : -1);
X}
X
Xint ir(x,y)
Xint x,y;
X{
X	return ((x>=0) && (x<MAXX) && (y>=0) && (y<MAXY));
X}
X
X/*
X * $Log:	life.c,v $
X * Revision 1.2  88/02/13  12:49:45  hale
X * added logging.
X * 
X */
X
END_OF_life.c
if test 1623 -ne `wc -c <life.c`; then
    echo shar: \"life.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\" \(3460 characters\)
sed "s/^X//" >main.c <<'END_OF_main.c'
X/*
X * $Header: main.c,v 3.0 88/03/10 12:07:32 hale Exp $
X */
X
X
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X/*
X    Go written by Greg Hale (April 20 1987)
X*/
X
X/* main.c */
X/* #include "xgo.h" */
X#include "go.h"
X#include <ctype.h>
X#include <signal.h>
X#include <strings.h>
X
Xbool		iamserver = UNSET;
Xlong		random();
Xlong		time();
Xchar		*arg0;
X
X
Xmain0 (argc, argv, envp)
Xint argc;
Xchar **argv, **envp;
X{
X	extern int loadflg, myport;
X	extern char *loadname, *hisname;
X	int port,i, j, trap_sigint(),tstp(),ts_tp();
X	char *p, *malloc ();
X
X	arg0 = (arg0 = rindex(argv[0],'/')) ? arg0+1: argv[0];
X
X	port = myport;
X
X	signal (SIGINT, SIG_IGN);
X	signal (SIGPIPE, SIG_IGN);
X	srandom (time((long *) NULL));
X
X	Init();
X
X	signal (SIGINT, trap_sigint);
X	p = hisname;		/* used to be argv[argc-1] */
X	connectport (p, port);
X	doneconnectmes();
X
X	player = iamserver;
X	printscore();
X	initmesg();
X
X	Synchronize();
X
X	if (loadflg) {
X		doload();		/* load in saved game */
X	} else {
X		PrintBoard(&board);
X		sethandi();
X	}
X
X	Loop ();
X	Exit();
X}
X
X
X/*
X * Make sure all game parameters match in programs
X */
XSynchronize()
X{
X	extern int demflg,strength,opponstr,handin,handicaps;
X	int temp;
X
X	swap(MSTR, strength, &opponstr,
X		"Strength not sent from other program.\n");
X
X	swap(MMODE, demflg,&temp,"Demoflag not sent from other program.\n");
X	demflg |= temp;
X
X
X	swap(MSIZE,dimensions,&temp,
X		"Size not sent from other program.\n");
X	if (temp<dimensions) dimensions = temp;
X	dimensions = dimensions / 2 * 2 + 1;
X	MAXX = MAXY = dimensions;
X	handin = (dimensions > 12) ? 3 : 2;
X
X	swap(MHAND,handicaps,&temp,
X		"# of handicaps not sent from other program.\n");
X	if (temp >0 || handicaps > 0) {
X		handicaps = (temp > handicaps ? temp : handicaps);
X	} else {
X		temp = opponstr - strength;
X		handicaps = (temp > 0 ? temp : -temp);
X		handicaps = (handicaps * dimensions * dimensions) / (19 * 19);
X		if (temp) player = temp > 0;
X	}
X
X}
X
X
Xswap(mesg,s,r,err)
Xchar *mesg,*err;
Xint *r,s;
X{
X	char line[100];
X	int temp;
X
X	SEND(mesg);
X	RECV(line);
X	if (strcmp(line,mesg)) {
X		error(err);
X	}
X
X	sprintf(line,"%d",s);
X	SEND(line);
X
X	RECV(line);
X	*r= atoi(line);
X}
X/*
X * $Log:	main.c,v $
X * Revision 3.0  88/03/10  12:07:32  hale
X * Added save games, a few changes to the I/O,
X * added load and clear options.  Not thouroughly tested, though, and
X * I think a few bugs are in the load code.  A library of sample problems
X * has been started and saved with the working directory.
X * 
X * Revision 1.4  88/02/19  13:48:56  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:23:06  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:49:59  hale
X * modified entry to have load option work and opponnents name is loaded
X * properly.
X * 
X */
X
END_OF_main.c
if test 3460 -ne `wc -c <main.c`; then
    echo shar: \"main.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f mesg.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"mesg.c\"
else
echo shar: Extracting \"mesg.c\" \(1861 characters\)
sed "s/^X//" >mesg.c <<'END_OF_mesg.c'
X/*
X * $Header: mesg.c,v 1.2 88/02/13 12:50:27 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X
Xextern char *opponent;
X
Xint mesgx=42;
Xint mesgy=7;
Xint mesgx2=79;
Xint mesgy2=14;
X
X
Xint talkx=42;
Xint talky=16;
Xint talkx2=79;
Xint talky2=23;
X
Xstatic char mesgbuf[1000];
Xint cur;
Xint curx;
Xint cury;
Xint mesflg;
X
X#define FD_INPUT 0
X
Xint tcury;
X
Xinitmesg()
X{
X	mesflg=0;
X	cur= -1;
X	curx=mesgx;
X	cury=mesgy;
X
X	tcury=talky;
X
X
X	mvprintw(0,mesgx,"   -- GO --");
X	mvprintw(mesgy-1,mesgx,"   -- your messages --");
X	mvprintw(talky-1,talkx,"   -- opponent --");
X}
X
Xaddtalk(s)
Xchar *s;
X{
X	mvaddstr(tcury,talkx,s);
X	if(tcury++ == talky2) tcury=talky;
X	move(tcury,talkx);
X	clrtoeol();
X}
X
Xdomesg(c)
Xchar c;
X{
X	if (c=='\b' || c=='\177') {
X		delchar();
X	} else if (c=='\n') {
X		if(cur>=0) {
X			sendbuf();
X			curx=mesgx;
X			if (cury++ == mesgy2) cury=mesgy;
X		} else {
X			mesflg = 0;
X			return(0);
X		}
X		move (cury,curx);
X		clrtoeol();
X	} else {
X		addchar(c);
X	}
X	move (cury,curx);
X}
X
Xaddchar(c)
Xchar c;
X{
X	mesgbuf[++cur] = c;
X	mvaddch(cury,curx,c);
X	if (curx++ == mesgx2) {
X		curx=mesgx;
X		if (cury++ == mesgy2) cury=mesgy;
X		sendbuf();
X	}
X}
X
Xdelchar()
X{
X	if (cur>=0 && curx>mesgx) {
X		curx--;
X		cur--;
X		mvaddch(cury,curx,' ');
X	}
X}
X
Xsendbuf()
X{
X	mesgbuf[++cur] = '\0';
X	SEND(MMESSAGE);
X	SEND(mesgbuf);
X	cur= -1;
X}
X/*
X * $Log:	mesg.c,v $
X * Revision 1.2  88/02/13  12:50:27  hale
X * added logging.
X * 
X */
X
END_OF_mesg.c
if test 1861 -ne `wc -c <mesg.c`; then
    echo shar: \"mesg.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f opts.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"opts.c\"
else
echo shar: Extracting \"opts.c\" \(3712 characters\)
sed "s/^X//" >opts.c <<'END_OF_opts.c'
X/*
X * $Header: opts.c,v 1.2 88/02/13 12:50:46 hale Exp $
X */
X
X#include "go.h"
X#include <strings.h>
X
X
X
X#define ISARG(s) (!strncmp(*argv,s,strlen(s)))
X
Xint numberblink;
X
Xparseline (argc, argv)
Xint argc;
Xchar **argv;
X{
X	char **argval;
X	extern char *loadname,*hisname, *myname;
X	extern int strength,beepflg,demflg,changeflg,myport,handicaps;
X	extern int loadflg;
X	extern float wins;
X
X	GetStr();
X
X	numberblink = 4;
X	changeflg = 0;
X	handicaps = -2;
X	argval = argv;
X	display[0] = '\0';
X	dimensions = MAXDIM;
X	myport = DEFAULTPORT;
X	demflg = beepflg = 0;
X	hisname = NULL;
X
X	while (++argv,--argc>0) {
X		if (ISARG("-h")) {
X			longhelp();
X		} else if (ISARG("-s")) {
X			if (--argc>0) {
X				dimensions = atoi(*++argv);
X				if (dimensions < 7) dimensions = 7;
X				if (dimensions > 19) dimensions = 19;
X			} else helpstart(argval);
X		} else if (ISARG("-d")) {
X			if (--argc>0) strcpy(*++argv,display);
X			else helpstart(argval);
X		} else if (ISARG("-p")) {
X			if (--argc>0) myport = atoi(*++argv);
X			else helpstart(argval);
X		} else if (ISARG("-H")) {
X			if (--argc>0) handicaps = atoi(*++argv);
X			else helpstart(argval);
X		} else if (ISARG("-c")) {
X			changeflg=1;
X		} else if (ISARG("-r")) {
X			showstr();
X			exit(0);
X		} else if (ISARG("-m")) {
X			demflg=1;
X		} else if (ISARG("-b")) {
X			beepflg=1;
X		} else if (ISARG("-n")) {
X			if (--argc>0) {
X				numberblink = atoi(*++argv);
X				if (numberblink<0) numberblink = 4;
X			} else helpstart(argval);
X
X		} else if (ISARG("-l")) {
X			if (--argc>0) {
X				loadflg++;
X				loadname= *++argv;
X			} else helpstart(argval);
X
X		} else if (ISARG("-R")) {
X		    wins = 0.0;
X		    if (--argc) {
X			if (*argv[1]=='+') {
X				strength++;
X				argv++;
X			} else if (*argv[1]=='-') {
X				strength--;
X				argv++;
X
X			} else if (--argc) {
X			    switch (*argv[2]) {
X				WHEN 'k':
X					strength = 31 - atoi(argv[1]);
X				WHEN 'd':
X					strength = 30 + atoi(argv[1]);
X				WHEN 'p':
X					strength = 39 + atoi(argv[1]);
X				OTHERWISE:
X					helpstart(argval);
X			    }
X			    argv+=2;
X			} else
X			    helpstart(argval);
X
X			if (strength < 1) strength = 1;
X			else if (strength > MAXSTR) strength = MAXSTR;
X
X			savestr0();
X			exit(0);
X		    } else
X			    helpstart(argval);
X		} else {
X			hisname = *argv++;
X		}
X	}
X	if (hisname == NULL) helpstart();
X}
X
X
Xhelpstart(argv)
Xchar *argv[];
X{
X	fprintf (stderr,"\nUsage:\n");
X	fprintf (stderr,"%s {opts} user[@host]\n",argv[0]);
X
X	fprintf (stderr,"{opts} is any of :\n");
X	fprintf (stderr,"-d display             set your display.\n");
X	fprintf (stderr,"-p port#               which address to meet at.\n");
X	fprintf (stderr,"-m                     turn on demo mode during handicap setup.\n");
X	fprintf (stderr,"-b                     turn on beeping during plays and messages.\n");
X	fprintf (stderr,"-s size                set the board size [7-19].\n");
X	fprintf (stderr,"-n blink               set the number of times to blink a piece.\n");
X	fprintf (stderr,"-H #handicaps          set the number of handicap stones.\n");
X	fprintf (stderr,"-c                     give a quick summery of the last changes\n");
X	fprintf (stderr,"-l <filename>          load a saved/sample game.\n");
X	fprintf (stderr,"                       changes made to the program and the version number.\n\n");
X
X	fprintf (stderr,"OR:\n");
X	fprintf (stderr,"\"%s -r\" for your current rank.\n",argv[0]);
X	fprintf (stderr,"\"%s -h\" for help.\n",argv[0]);
X	fprintf (stderr,"\"%s -R # {k|d|p} to set your rank to # kyu/dan/pro dan respectively\n",argv[0]);
X	fprintf (stderr,"\"%s -R {+|-} to increase/decrease your rank respectively\n",argv[0]);
X	exit (0);
X}
X
X
X/*
X * $Log:	opts.c,v $
X * Revision 1.2  88/02/13  12:50:46  hale
X * added searching for new opts and opponent name.
X * 
X */
X
END_OF_opts.c
if test 3712 -ne `wc -c <opts.c`; then
    echo shar: \"opts.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f putpiece.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"putpiece.c\"
else
echo shar: Extracting \"putpiece.c\" \(2049 characters\)
sed "s/^X//" >putpiece.c <<'END_OF_putpiece.c'
X/*
X * $Header: putpiece.c,v 1.2 88/02/13 12:51:43 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X#define DELAY 30000
X
Xint lastx,lasty;
X
Xputpiece (cx,cy,cur,blinkflg)
Xint cx,cy;
Xint cur;
Xint blinkflg;
X{
X	if (b(cx,cy)==NONE) {
X		int c,d;
X		savelast();
X		c = !cur+1;
X		d = cur+1;
X		setboard(cx,cy,d);
X		if(NoMove(cx,cy,c,d)) {
X			b(cx,cy)=0; 
X			Plt(&board,cx,cy); 
X			Beep();
X		} else {
X			Kill(cx,cy,d);
X
X			if (!compboard()) {
X				addmes("- That's a KO. You can't");
X				addmes("  go there.");
X				restlast();
X				Beep();
X			} else {
X				lastx = cx;
X				lasty = cy;
X				SEND(MMOVE);
X				SendCoord(cx,cy);
X				sprintf(buf,"%d",cur);
X				SEND(buf);
X				Plt(&board,cx,cy);
X				REFRESH();
X				if (blinkflg) blink(cx,cy,d);
X				NextPlr();
X				saveboard0();
X			}
X		}
X	} else {
X		Beep();
X	}
X}
X
XShowLast()
X{
X	blink(lastx,lasty,b(lastx,lasty));
X}
X
Xblink(x,y,d)
Xint x,y,d;
X{
X	extern int numberblink;
X	int i;
X	if (!AreWe(HANDICAP)) for(i=0; i<numberblink; i++) {
X		bdelay(15);
X		b(x,y)=0; 
X		Plt(&board,x,y);
X		REFRESH();
X		bdelay(8);
X		b(x,y)=d; 
X		Plt(&board,x,y);
X		REFRESH();
X	}
X}
X	
Xbdelay(n)
Xint n;
X{
X	int y,x;
X	for(y=n; y>0; y--)
X	    for (x=5000; x>0; x--)
X		;
X}
X
XGetCoord(x,y)
Xint *x,*y;
X{
X	RECV(buf);
X	*x = atoi(buf);
X	RECV(buf);
X	*y = atoi(buf);
X}
X
XSendCoord(x,y)
Xint x,y;
X{
X	sprintf(buf,"%d",x);
X	DEBUG(printf("SENDCOORD X:%s\n",buf);)
X	SEND(buf);
X	sprintf(buf,"%d",y);
X	DEBUG(printf("SENDCOORD Y:%s\n",buf);)
X	SEND(buf);
X}
X
X
Xdelay()
X{
X	int d;
X	for (d=0; d<DELAY; d++)
X		;
X}
X
X/*
X * $Log:	putpiece.c,v $
X * Revision 1.2  88/02/13  12:51:43  hale
X * added logging.
X * 
X */
X
END_OF_putpiece.c
if test 2049 -ne `wc -c <putpiece.c`; then
    echo shar: \"putpiece.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f score.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"score.c\"
else
echo shar: Extracting \"score.c\" \(1919 characters\)
sed "s/^X//" >score.c <<'END_OF_score.c'
X/*
X * $Header: score.c,v 1.2 88/02/13 12:51:47 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "go.h"
X
XScore()
X{
X	extern int handicaps;
X	char temp[100];
X	int komi,i,j,s1,s2,s1pts,s2pts;;
X	s1=s2=0;
X	Tally();
X	for (i=0; i<MAXX; i++) {
X		for (j=0; j<MAXY; j++) {
X			if (b(i,j)==4) {
X				s1++;
X			} else if(b(i,j)==5) {
X				s2++;
X			}
X
X		}
X	}
X	komi = handicaps>0 ? 0.0 : 2.0 * KOMI;
X	s1pts=s1;
X	s2pts=s2;
X	s2+=hama[1];
X	s1+=hama[0];
X	s1 *= 2;
X	s2 = s2*2 + komi;
X	if (s1>s2)
X		sprintf(temp,"Black has won by %d points!",(s1-s2)/2);
X	else if (s2>s1)
X		sprintf(temp,"White has won by %d points!",(s2-s1)/2);
X		else sprintf(temp,"It was a tie game!");
X	addmes("");
X	addmes("***************");
X	addmes("Final Results:");
X	addmes(temp);
X
X	iwon = (player && (s1>s2)) || (!player && (s1<s2));
X	savestr();
X
X	GetAKey();
X	printf("\n\n");
X	printf("------------------------------------------------\n");
X	printf("-              Final Results:                  -\n");
X	printf("------------------------------------------------\n");
X	printf("-     Territory + Captured + Komi = Final Score\n");
X	printf("-Black:  %3d        %3d        0         %3d\n",
X				s1pts, hama[0], s1/2);
X	printf("-White:  %3d        %3d        %1.1f   %3.1f\n",
X		    s2pts, hama[1], komi, (float)s2/2.0);
X	printf("-------------------------------------------------\n");
X	printf("%s\n",temp);
X	Exit();
X}
X/*
X * $Log:	score.c,v $
X * Revision 1.2  88/02/13  12:51:47  hale
X * added logging.
X * 
X */
X
END_OF_score.c
if test 1919 -ne `wc -c <score.c`; then
    echo shar: \"score.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f strength.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"strength.c\"
else
echo shar: Extracting \"strength.c\" \(2198 characters\)
sed "s/^X//" >strength.c <<'END_OF_strength.c'
X/*
X * $Header: strength.c,v 1.3 88/02/19 13:49:15 hale Exp $
X */
X
X#include "go.h"
X#include <pwd.h>
X
XFILE *strfile;
Xchar filename[500];
Xextern int strength,opponstr;
Xextern float wins;
X
XGetStr()
X{
X	int id;
X	struct passwd *pw;
X	char *dir;
X	id=geteuid();
X	pw=getpwuid(id);
X	dir = pw->pw_dir;
X	strcpy(filename,dir);
X	strcat(filename,GOFILE);
X	/* fprintf(stderr,"FILENAME:%s\n",filename); */
X	if ((strfile = fopen(filename, "r")) != NULL) {
X		fscanf(strfile,"%d",&strength);
X		fscanf(strfile,"%f",&wins);
X		fclose(strfile);
X	} else {
X		strength = 0;
X		wins = 0.0;
X	}
X
X}
X
X
X
X
Xsavestr()
X{
X	float getdelta(), newwins;
X	newwins = getdelta();
X	if (newwins * wins < 0.0) wins = newwins;
X	else wins += newwins;
X	savestr0();
X}
X
Xsavestr0()
X{
X	if ((strfile=fopen(filename, "w")) != NULL) {
X	    if ((wins >= WINSUP && strength < MAXSTR)) {
X		fprintf(strfile,"%d 0.0\n", strength+1);
X	    } else if ((wins <= -WINSUP && strength > 1)) {
X		fprintf(strfile,"%d 0.0\n", strength-1);
X	    } else {
X		fprintf(strfile,"%d %f\n", strength,wins);
X	    }
X	    fclose(strfile);
X	}
X}
X
X
Xfloat getdelta()
X{
X	if (iwon) {		/* i won */
X		if (strength < opponstr)	/* i'm weaker */
X			return ( (opponstr - strength)/10.0 +1.0);
X		else
X			return ( ((strength - opponstr) > 20) ? 2.0 : 1.0);
X	} else {
X		if (strength < opponstr)
X			return (-1.0);
X		else
X			return ( -((strength - opponstr)/20.0+1.0) );
X	}
X}
X
Xshowstr()
X{
X	GetStr();
X	if (strength < 31) {
X		printf("Your strength is about: %d kyu.\n", 31-strength);
X	} else if (strength < 40) {
X		printf("Your strength is about: %d dan.\n", strength-30);
X	} else if (strength < MAXSTR+1) {
X		printf("Your strength is about: %d professional dan.\n", strength-39);
X	} else {
X		printf("Your are at maximum strength.\n");
X	}
X	if (wins>=0) printf("You have also won %d games in a row.\n",(int)(wins/2.0));
X	else printf("You have also lost %d games in a row.\n",-(int)(wins));
X}
X/*
X * $Log:	strength.c,v $
X * Revision 1.3  88/02/19  13:49:15  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.2  88/02/13  12:52:11  hale
X * modified strength function.
X * 
X */
X
END_OF_strength.c
if test 2198 -ne `wc -c <strength.c`; then
    echo shar: \"strength.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xbit.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xbit.c\"
else
echo shar: Extracting \"xbit.c\" \(2965 characters\)
sed "s/^X//" >xbit.c <<'END_OF_xbit.c'
X/*
X * $Header: xbit.c,v 1.2 88/02/13 12:53:11 hale Locked $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X#include "xpiecenum.h"
X
X#include "Xmask.h"
X#include "Xmask0.h"
X#include "Xpiecemask.h"
X#include "Xintersect.h"
X#include "Xpoint.h"
X#include "Xblack.h"
X#include "Xwhite.h"
X#include "Xdl.h"
X#include "Xdr.h"
X#include "Xul.h"
X#include "Xur.h"
X#include "Xu.h"
X#include "Xr.h"
X#include "Xd.h"
X#include "Xl.h"
X#include "Xneu.h"
X#include "Xfwh.h"
X#include "Xfbl.h"
X#include "XButton.h"
X
X#define MAXPIECES 20
X
Xstatic Bitmap p[MAXPIECES];
X
X
XInitBit()
X{
X	p[Smask]=XStoreBitmap(25,25,mask_bits);
X	p[Smask0]=XStoreBitmap(25,25,mask0_bits);
X	p[Spiecemask]=XStoreBitmap(25,25,piecemask_bits);
X	p[Sintersect]=XStoreBitmap(25,25,intersect_bits);
X	p[Spoint]=XStoreBitmap(25,25,point_bits);
X	p[Swhite]=XStoreBitmap(25,25,black_bits);
X	p[Sblack]=XStoreBitmap(25,25,white_bits);
X	p[Sdl]=XStoreBitmap(25,25,dl_bits);
X	p[Sdr]=XStoreBitmap(25,25,dr_bits);
X	p[Sul]=XStoreBitmap(25,25,ul_bits);
X	p[Sur]=XStoreBitmap(25,25,ur_bits);
X	p[Su]=XStoreBitmap(25,25,u_bits);
X	p[Sr]=XStoreBitmap(25,25,r_bits);
X	p[Sd]=XStoreBitmap(25,25,d_bits);
X	p[Sl]=XStoreBitmap(25,25,l_bits);
X	p[Sneu]=XStoreBitmap(25,25,neu_bits);
X	p[Sfbl]=XStoreBitmap(25,25,fwh_bits);
X	p[Sfwh]=XStoreBitmap(25,25,fbl_bits);
X	p[Sbutton]=XStoreBitmap(80,30,XButton_bits);
X}
X
X#define PltShp(pc) XPixFill(Wboard,x*25,y*25,25,25,WhitePixel,pc,GXcopy,AllPlanes);
X#define ErsShp(pc) XPixFill(Wboard,x*25,y*25,25,25,WhitePixel,pc,GXclear,AllPlanes);
X
X
X
XPltPiece(x,y,pi)
Xint x,y,pi;
X{
X	PltShp(p[cp(x,y)]);
X	switch (pi) {
X		WHEN 1: ErsShp(p[Spiecemask]);
X			PltShp(p[Sblack]);
X		WHEN 2: ErsShp(p[Spiecemask]);
X			PltShp(p[Swhite]);
X		WHEN 4: ErsShp(p[Spiecemask]);
X			PltShp(p[Sfbl]);
X		WHEN 5: ErsShp(p[Spiecemask]);
X			PltShp(p[Sfwh]);
X
X		WHEN 0:
X		default:
X			ErsShp(p[Spiecemask]);
X			PltShp(p[cp(x,y)]);
X	}
X}
X
Xcp(x,y)
Xint x,y;
X{
X	extern int handin;
X	if ((x==handin || x==MAXX-1-handin || x == (MAXX-1)/2) &&
X	   (y==handin || y==MAXY-1-handin || y == (MAXY-1)/2)) {
X		return Spoint;
X	} else if (x == 0) {
X		if (y == 0) return Sul;
X		if (y == MAXY-1) return Sdl;
X		return Sl;
X	} else if (x == MAXX-1) {
X		if (y==0) return Sur;
X		if (y==MAXY-1) return Sdr;
X		return Sr;
X	} else if (y == 0) {
X		return Su;
X	} else if (y == MAXY-1) {
X		return Sd;
X	} else return Sintersect;
X}
X
X
X/*
X * $Log:	xbit.c,v $
X * Revision 1.2  88/02/13  12:53:11  hale
X * modified redraw to draw background behind shapes
X * so there are no blank spots between pieces on redraw.
X * 
X */
X
END_OF_xbit.c
if test 2965 -ne `wc -c <xbit.c`; then
    echo shar: \"xbit.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xclick.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xclick.c\"
else
echo shar: Extracting \"xclick.c\" \(2745 characters\)
sed "s/^X//" >xclick.c <<'END_OF_xclick.c'
X/*
X * $Header: xclick.c,v 1.4 88/02/19 13:49:24 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X
Xclick (br)
XXButtonPressedEvent *br;
X{
X	extern int demflg;
X	int i;
X	int x = br->x/25;
X	int y = br->y/25;
X	int but,col;
X
X	but = br->detail & 07;
X
X	if (AreWe(REDRAWING)) {
X		ClrStat(REDRAWING);
X		PrintBoard(&board);
X
X	} else if (br->window == Wplay) {
X		SEND(MPLAY);
X		doplay();
X
X	} else if (br->window == Wexit) {
X		SetStat(EXIT);
X		SEND(MEXIT);
X	
X	} else if (br->window == Wsave) {
X		dosave();
X
X	} else if (br->window == Wload) {
X		doload();
X
X	} else if (br->window == Wboard) {
X		if ((AreWe(QUIT))||(x>=MAXX) || (y>=MAXY) ||
X		    (x < 0) || (y < 0)) {
X			Beep();
X		} else if (AreWe(HANDICAP)) {
X			if (demflg)
X				dodemo(x,y,but);
X			else
X				sethand(x,y,!b(x,y));
X		} else if (AreWe(SCORE)) {
X			doscorehit(x,y);
X		} else if (myturn && AreWe(PLAY)) {
X			putpiece (x,y,curplr,true);
X		} else Beep();
X
X	} else if (br->window == Wresign) {
X		SEND(MRESIGN);
X		doresign();
X
X	} else if (br->window == Wtally) {
X		dotally();
X
X	} else if (br->window == Wclear) {
X		SEND(MCLEAR);
X		doclear();
X
X	} else if (br->window == Wshow) {
X		ShowLast();
X
X	} else if (br->window == Wswitch) {
X		SEND(MSWITCH);
X		doswitch();
X
X	} else if (br->window == Wdecline) {
X		dodecline();
X		SEND(MDECLINE);
X
X	} else if (br->window == Waccept) {
X		SEND(MACCEPT);
X		Score();	/* note: score EXITS */
X
X	} else if (br->window == Wcancel) {
X		docancel();
X		SEND(MCANCEL);
X
X	} else if (br->window == Wscore) {
X		SEND(MSCORE);
X		doscore();
X
X	} else if (br->window == Wquit) {
X		ClrStat(PLAY);
X		SEND(MQUIT);
X
X	} else if (!myturn) {
X		Beep();
X
X	} else if (br->window == Wpass) {
X		curplr = !curplr;
X		SEND(MPASS);
X
X	} else {
X		Beep();
X	}
X}
X
X/*
X * $Log:	xclick.c,v $
X * Revision 1.4  88/02/19  13:49:24  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:23:18  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:53:43  hale
X * heavily modified for centralization of code.
X * 
X */
X
END_OF_xclick.c
if test 2745 -ne `wc -c <xclick.c`; then
    echo shar: \"xclick.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xexpose.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xexpose.c\"
else
echo shar: Extracting \"xexpose.c\" \(2226 characters\)
sed "s/^X//" >xexpose.c <<'END_OF_xexpose.c'
X/*
X * $Header: xexpose.c,v 1.4 88/02/19 13:49:28 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X#include "xwin.h"
X
X#define W ev->window
X#define B(txt) XText(ev->window, (BTNWID-XStringWidth(txt,fi,0,0))/2,4,txt,strlen(txt),fi->id,WhitePixel,BlackPixel)
X
XExpose(ev)
XXExposeEvent *ev;
X{
X	    int x1,y1,x2,y2;
X	    if (W == Wboard) {
X		x1=ev->x/25;
X		x2=(ev->x+ev->width)/25+1;
X		x2= (x2>18 ? 18:x2);
X		y1=ev->y/25;
X		y2=(ev->y+ev->height)/25+1;
X		y2= (y2>18 ? 18:y2);
X		XPrintBoard(x1,y1,x2,y2,&board);
X	    } else if (W == Wtalk) initmesg();
X	    else if (W == Wtalk1) initmesg();
X	    else if (W == Wmesg) initmesg();
X	    else if (W == Wpass) B("Pass");
X	    else if (W == Wtally) B("Tally");
X	    else if (W == Wquit) B("Quit");
X	    else if (W == Wscore) B("Score");
X	    else if (W == Waccept) B("Accept");
X	    else if (W == Wdecline) B("Decline");
X	    else if (W == Wcancel) B("Cancel");
X	    else if (W == Wplay) B("Play");
X	    else if (W == Wexit) B("Exit");
X	    else if (W == Wswitch) B("Switch");
X	    else if (W == Wshow) B("Last");
X	    else if (W == Wresign) B("Resign");
X	    else if (W == Wsave) B("Save");
X	    else if (W == Wload) B("Load");
X	    else if (W == Wclear) B("Clear");
X}
X/*
X * $Log:	xexpose.c,v $
X * Revision 1.4  88/02/19  13:49:28  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:23:22  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:54:14  hale
X * handles new windows.
X * 
X */
END_OF_xexpose.c
if test 2226 -ne `wc -c <xexpose.c`; then
    echo shar: \"xexpose.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xinitloop.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xinitloop.c\"
else
echo shar: Extracting \"xinitloop.c\" \(2087 characters\)
sed "s/^X//" >xinitloop.c <<'END_OF_xinitloop.c'
X/*
X * $Header: xinitloop.c,v 1.4 88/02/19 13:49:35 hale Locked $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X
X#define winmode KeyPressed|ExposeWindow|ExposeRegion|ButtonPressed
XInitLoop()
X{
X	extern Window Wmain;
X
X	XSelectInput (Wtalk,ExposeWindow|ExposeRegion|KeyPressed);
X	XSelectInput (Wtalk1,ExposeWindow|ExposeRegion|KeyPressed);
X	XSelectInput (Wmesg,ExposeWindow|ExposeRegion|KeyPressed);
X
X
X	XSelectInput (Wboard,winmode);
X	XSelectInput (Waccept,winmode);
X	XSelectInput (Wdecline,winmode);
X	XSelectInput (Wscore,winmode);
X	XSelectInput (Wtally,winmode);
X	XSelectInput (Wquit,winmode);
X	XSelectInput (Wpass,winmode);
X	XSelectInput (Wcancel,winmode);
X	XSelectInput (Wplay,winmode);
X	XSelectInput (Wexit,winmode);
X	XSelectInput (Wswitch,winmode);
X	XSelectInput (Wshow,winmode);
X	XSelectInput (Wresign,winmode);
X	XSelectInput (Wsave,winmode);
X	XSelectInput (Wload,winmode);
X	XSelectInput (Wclear,winmode);
X
X	XMapWindow(Wmain);
X	XMapWindow(Wboard);
X	XMapWindow(Wtalk);
X	XMapWindow(Wtalk1);
X	XMapWindow(Wmesg);
X	XMapWindow(Wresign);
X	XMapWindow(Wsave);
X
X	SetStat(HANDICAP);
X}
X/*
X * $Log:	xinitloop.c,v $
X * Revision 1.4  88/02/19  13:49:35  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:23:26  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:54:42  hale
X * added logging.
X * 
X */
X
END_OF_xinitloop.c
if test 2087 -ne `wc -c <xinitloop.c`; then
    echo shar: \"xinitloop.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xloop.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xloop.c\"
else
echo shar: Extracting \"xloop.c\" \(1989 characters\)
sed "s/^X//" >xloop.c <<'END_OF_xloop.c'
X/*
X * $Header: xloop.c,v 1.3 88/02/19 13:49:42 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X#undef DEBUG
X#define DEBUG(m) 
X
XLoop()
X{
X    int mask=0,i,retry;
X
X    addmes("- GO  By Greg Hale");
X    addmes("- Set up handicap.");
X
X    while (!AreWe(EXIT)) {
X	do {
X			myturn = (!player && curplr) ||
X				(player && !curplr);
X			if (mask  == sockmask[1]) {
X				DEBUG(printf("Socket message received\n");)
X				myturn = !myturn;
X				DoOther();
X				myturn = !myturn;
X			}
X			while (i=XPending()) {
X				myturn = (!player && curplr) ||
X					(player && !curplr);
X				DEBUG(printf("#PENDING:%d\n",i);)
X				procev();
X			}
X
X		mask = sockmask[0] | sockmask[1];
X		DEBUG(printf("	SELECT on mask:%x\n",mask);)
X		if (AreWe(EXIT)) break;
X
X		if (AreWe(PLAY)) {
X			if (!curplr) SetBlkCur();
X			else SetWhtCur(); 
X		}
X
X
X	} while (select(32,&mask,0,0,0)!=0);
X    }
X}
X
X
X
Xprocev()
X{
X	XEvent *ev,_ev;
X	ev = &_ev;
X
X
X	while (XSetDisplay(dis), QLength()) {
X	    XNextEvent(ev);
X	    DEBUG(printf("EVENT TYPE:%d\n", ev->type);)
X	    
X	    switch (ev->type) {
X		    WHEN ButtonPressed: click(ev);
X		    WHEN KeyPressed: KeyPress(ev);
X		    WHEN ExposeWindow:
X		    case ExposeRegion: Expose(ev); 
X	    }
X	} 
X}
X
XNxtPlr()
X{
X	curplr = !curplr;
X}
X
X/*
X * $Log:	xloop.c,v $
X * Revision 1.3  88/02/19  13:49:42  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.2  88/02/13  12:54:54  hale
X * added logging.
X * 
X */
X
END_OF_xloop.c
if test 1989 -ne `wc -c <xloop.c`; then
    echo shar: \"xloop.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xmesg.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xmesg.c\"
else
echo shar: Extracting \"xmesg.c\" \(2371 characters\)
sed "s/^X//" >xmesg.c <<'END_OF_xmesg.c'
X/*
X * $Header: xmesg.c,v 1.2 88/02/13 12:54:58 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X
X#define FontWidth 8
X#define FD_INPUT 0
X
X#define B(w,txt,v) XText(w, 5,(v) * fi->height,txt,strlen(txt),fi->id,WhitePixel,BlackPixel)
X#define B1(w,txt,v,h) XText(w, 5 + h*FontWidth, (v) * fi->height,txt,strlen(txt),fi->id,WhitePixel,BlackPixel)
X
Xextern char *opponent;
X
Xint mesgx=0;
Xint mesgy=1;
X
X
Xint talkx=0;
Xint talky=1;
X
XWindowInfo talkinfo,talk1info;
X
Xstatic char mesgbuf[1000];
Xchar schar[2]=" ";
Xint cur= -1;
Xint curx=0;
Xint cury=1;
Xint mesflg;
X
X
Xint tcury;
X
Xinitmesg()
X{
X	char t[100];
X	sprintf(t,"-- Your messages (%s) --     ", (player ? "BLACK":"WHITE"));
X	B(Wtalk,t,0);
X	sprintf(t,"-- Opponent's messages (%s) --     ", (!player ? "BLACK":"WHITE"));
X	B(Wtalk1,t,0);
X	B(Wmesg,"-- Messages --     ",0);
X}
X
X
X
X
Xaddtalk(s)
Xchar *s;
X{
X	WindowInfo wi;
X	XQueryWindow(Wtalk1,&wi);
X	B(Wtalk1,s,tcury+1);
X	if(tcury++ == wi.height / fi->height -1) tcury=0;
X	B(Wtalk1,blanks,tcury+1);
X}
X
Xdomesg(c)
Xchar c;
X{
X	XQueryWindow(Wtalk,&talkinfo);
X	XQueryWindow(Wtalk1,&talk1info);
X	schar[0]=' ';
X	B1(Wtalk,schar,cury,curx);
X	if (c=='\b' || c=='\177') {
X		delchar();
X	} else if (c=='\n' || c=='\r') {
X		if(cur>=0) {
X			sendbuf();
X			curx=0;
X			if (cury++ == talkinfo.height / fi->height-1) cury=1;
X			B1(Wtalk,blanks,cury,curx);
X		}
X	} else {
X		addchar(c);
X	}
X	schar[0]='_';
X	B1(Wtalk,schar,cury,curx);
X}
X
Xaddchar(c)
Xchar c;
X{
X	schar[0]=c;
X	mesgbuf[++cur] = c;
X	B1(Wtalk,schar,cury,curx);
X	if (curx++ == talkinfo.width / FontWidth) {
X		curx=0;
X		if (cury++ == talkinfo.height/fi->height-1) cury=1;
X		B1(Wtalk,blanks,cury,curx);
X		sendbuf();
X	}
X}
X
Xdelchar()
X{
X	if (cur>=0 && curx>0) {
X		curx--;
X		cur--;
X		B1(Wtalk," ",cury,curx);
X	}
X}
X
Xsendbuf()
X{
X	mesgbuf[++cur] = '\0';
X	SEND(MMESSAGE);
X	SEND(mesgbuf);
X	cur= -1;
X}
X/*
X * $Log:	xmesg.c,v $
X * Revision 1.2  88/02/13  12:54:58  hale
X * added logging.
X * 
X */
X
END_OF_xmesg.c
if test 2371 -ne `wc -c <xmesg.c`; then
    echo shar: \"xmesg.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xwindow.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xwindow.c\"
else
echo shar: Extracting \"xwindow.c\" \(3069 characters\)
sed "s/^X//" >xwindow.c <<'END_OF_xwindow.c'
X/*
X * $Header: xwindow.c,v 1.4 88/02/19 13:49:55 hale Exp $
X */
X
X/*
X
X        Copyright 1987      Greg Hale
X
XPermission to use, copy, modify, and distribute this
Xsoftware and its documentation for any purpose and without
Xfee is hereby granted, provided that the above copyright
Xnotice appear in all copies and that both that copyright
Xnotice and this permission notice appear in supporting
Xdocumentation.  No representations are made about the
Xsuitability of this software for any purpose.  It is
Xprovided "as is" without express or implied warranty.
X
X*/
X
X
X#include "xgo.h"
X#include "xwin.h"
X#include "Xcursblk.h"
X#include "Xcurswht.h"
X#include "Xcursmsk.h"
X
X#define CW(x,y,wid,hgt) XCreateWindow(Wmain, x,y,wid,hgt, BORDERW, WhitePixmap, BlackPixmap)
X
Xstatic Bitmap curs[3];
Xstatic Cursor cursors[2];
XWindow Wmain;
X
XSetBlkCur()
X{
X	XDefineCursor(Wboard,cursors[1]);
X	XFlush();
X}
X
XSetWhtCur()
X{
X	XDefineCursor(Wboard,cursors[0]);
X	XFlush();
X}
X
XInitW()
X{
X	int x,y;
X	WindowInfo info;
X
X	/* initialize the cursor */
X	curs[0]= XStoreBitmap(25,25,Xcursmsk_bits);
X	curs[1]= XStoreBitmap(25,25,Xcursblk_bits);
X	curs[2]= XStoreBitmap(25,25,Xcurswht_bits);
X	cursors[0] = XStoreCursor(curs[1],curs[0],
X				Xcursblk_x_hot,Xcursblk_y_hot,
X				WhitePixel,BlackPixel,
X				GXcopy);
X	cursors[1] = XStoreCursor(curs[2],curs[0],
X				Xcursblk_x_hot,Xcursblk_y_hot,
X				WhitePixel,BlackPixel,
X				GXcopy);
X
X
X	
X	XQueryWindow(RootWindow,&info);
X
X	x= (info.width - (MEX+MEWID+BORDERW*2) ) /2;
X	y= (info.height - (19*25+BTNHGT+20) ) /2;
X
X	Wmain = XCreateWindow(RootWindow, x,y,
X		MEX+MEWID+BORDERW*2,
X		(19*25+BTNHGT+20),
X		BORDERW, WhitePixmap, BlackPixmap);
X
X	XStoreName (Wmain,"Go");
X	
X	Wboard =CW(BDX, BDY, BDWID, BDHGT);
X	Wtalk =CW(TAX, TAY, TAWID, TAHGT);
X	Wtalk1 =CW(TA1X, TA1Y, TA1WID, TA1HGT);
X	Wmesg =CW(MEX, MEY, MEWID, MEHGT);
X
X	/* permanant buttons */
X	Wpass =CW(BTN1X, BTNY, BTNWID, BTNHGT);
X	Wtally =CW(BTN2X, BTNY, BTNWID, BTNHGT);
X	Wshow =CW(BTN2X, BTNY, BTNWID, BTNHGT);
X	Wquit =CW(BTN3X, BTNY, BTNWID, BTNHGT);
X	Wscore =CW(BTN3X, BTNY, BTNWID, BTNHGT);
X	Wexit =CW(BTN4X, BTNY, BTNWID, BTNHGT);
X	Wresign =CW(BTN5X, BTNY, BTNWID, BTNHGT);
X	Wload =CW(BTN6X, BTNY, BTNWID, BTNHGT);
X	Wsave =CW(BTN7X, BTNY, BTNWID, BTNHGT);
X	Wclear =CW(BTN8X, BTNY, BTNWID, BTNHGT);
X
X	/* temporary buttions */
X	Waccept =CW(BTN1X, BTNY, BTNWID, BTNHGT);
X	Wdecline =CW(BTN2X, BTNY, BTNWID, BTNHGT);
X
X	Wcancel =CW(BTN1X, BTNY, BTNWID, BTNHGT);
X
X	Wplay =CW(BTN1X, BTNY, BTNWID, BTNHGT);
X	Wswitch =CW(BTN2X, BTNY, BTNWID, BTNHGT);
X	SetBlkCur();
X
X}
X
XEndWin()
X{
X}
X
X/*
X * $Log:	xwindow.c,v $
X * Revision 1.4  88/02/19  13:49:55  hale
X * Added io changes for loading games.
X * Load game is cleaned up.  Variable board
X * sizes and formats available in save game
X * as well as printed comments.
X * 
X * Revision 1.3  88/02/14  00:23:41  hale
X * Added load file option during game to restore game to starting
X * state.  Also, clear board operation.  Restoring game puts current
X * player in sync.  With the demo mode, this is invaluable.
X * 
X * Revision 1.2  88/02/13  12:55:39  hale
X * added logging.
X * 
X */
X
END_OF_xwindow.c
if test 3069 -ne `wc -c <xwindow.c`; then
    echo shar: \"xwindow.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