[comp.sources.x] v09i022: xmahjongg, Part02/05

jsy@poplar.cray.com (Jeff Young) (09/12/90)

Submitted-by: jsy@poplar.cray.com (Jeff Young)
Posting-number: Volume 9, Issue 22
Archive-name: xmahjongg/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
# If this archive is complete, you will see the following message at the end:
#		"End of archive 2 (of 5)."
#
# Contents:
#   xmahjongg.6 xmahjongg.mk icon.h patchlevel.h variables.h
#   xmahjongg.h COPYRIGHT Imakefile README.1 README.2 bridge wedges
#   default
#
# Wrapped by jsy@cray.com on Sun Sep  9 13:01:23 1990
#
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f xmahjongg.6 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xmahjongg.6\"
else
echo shar: Extracting \"xmahjongg.6\" \(5271 characters\)
sed "s/^X//" >xmahjongg.6 <<'END_OF_xmahjongg.6'
X.\"	Copyright 1990 Jeff S. Young
X.\"
X.\"	Permission is given to copy and distribute for non-profit purposes.
X.\"
X.TH XMAHJONGG 6 "27 June 1990"
X.SH NAME
Xxmahjongg \- X11R3 verion of the solitaire mahjongg game
X.SH SYNOPSIS
X.B xmahjongg
X[ \fB-b \fI###\fR ] [ \fB-n \fI###\fR ] [ \fB-r\fR ] [ \fB-s\fR ]
X[ \fB-d \fIdisplay\fR ] [ \fB-c\fR ] [ \fB-l \fIfile\fR ]
X[ \fB-p \fIname@machine\fR ] [ \fI...\fR ] [ \fB-p \fIname@machine\fR ]
X.SH DESCRIPTION
X.I Mah jongg
Xis an ancient chinese game usually played by four players with tiles similar
Xto dominos.  This is an X windows version for the solitaire game originally
Xseen on the PC and later ported to SunView.  It also has a new tournament 
Xoption.
X.SH THEORY OF PLAY
XThe object of the game is to remove all the tiles from the board.  Tiles are
Xremoved in by matching two identical tiles which have either an open left
Xedge or open right edge.  The only exception to this rule is that any open
X"flower" tile (bamboo, orchid, plum, or chrysanthemum) matches any other 
Xopen "flower" tile and any open "season" tile (spring, summer, autumn, or 
Xwinter) matches any other open "season" tile.
X.PP
XThe display has two distinct areas: the playing field and the control field.
X.PP
XThe bottom area is the playing field.  To remove a pair of tiles, click a mouse
Xbutton on a tile (which will light up) and then click a mouse button on the 
Xmatching tile.  At this point, both tiles will disappear from the board.  If 
Xafter selecting the first tile, you decide that you don't wish to play that 
Xtile, simply reclick the button on the tile.
X.PP
XThe top area is the control field.  The board number and the number of remaining
Xtiles are on the left side of the board.  The right side has some options 
Xfor controlling the game.  To select an option, click a mouse button on it.
X\fI      SAME \fR
XStart the same game again.  This option is disabled in tournament mode.
X\fI      NEW \fR
XStart a new game.
X\fI      DONE \fR
XCheck to see if you missed any matches.  When you think that you don't have any
Xmore matches left, clicking "DONE" will tell you the number of matches which 
Xyou missed.  If you missed some, you can continue play, but your score will
Xnot change.  The "DONE" field stays high-lighted to show that you have already 
Xtried this option.
X\fI      QUIT \fR
XExit the game.
X.SH OPTIONS
X.IP \fB\-b \fR
XStart the game with board number ###. Board numbers range from 1 to 99999.
X.IP \fB\-d \fR
XUse the given display name instead of the current default.
X.IP \fB\-n \fR
XNumber of games to play in tournament mode.  See below.
X.IP \fB\-r\fR
XReverse video mode.
X.IP \fB\-s\fR
XSetup mode.  See below.
X.IP \fB\-c\fR
XColor mode based on tile type.  Normally color is based on the level the piece
Xis on.
X.IP \fB\-l\fR
XUse a different layout file.  The default is the standard layout in the shape
Xof a pyramid.
X.IP \fB\-p \fR
XSet up a tournament with the specified player on the specified machine.
X.SH TOURNAMENT MODE
XUsing the [  \fI -p \fR ] parameter starts a tournament.  In this mode
Xseveral players can compete on a series of boards.  The players should agree
Xin advance on a starting board number.  The default tournament is three games,
Xalthough this can be changed with the [ \fI -n \fR ] parameter.  If another
Xplayer clicks "DONE" then, their score will be highlighted for that game.
XThe tournament winner is the player with the lowest total score over the series.
X.br
X   
X.br
XExample:
X.br
XThree users ('abc' on 'xyzzy', 'def' on 'plugh', and 'ghi' on 'plover') wish
Xto play a 5 game tournament starting with board 12345.
XHere are their command lines:
X.br
X   
X.br
X      'abc' types:    xmahjongg -b 12345 -n 5 -p def@plugh -p ghi@plover
X.br
X      'def' types:    xmahjongg -b 12345 -n 5 -p abc@xyzzy -p ghi@plover
X.br
X      'ghi' types:    xmahjongg -b 12345 -n 5 -p def@plugh -p abc@xyzzy
X.br
X   
X.br
XNote that the players can be in any order on the command line and that the
Xuser does not list his/her own name on the command line.
X.SH SETUP MODE
XUsing the [ \fB -s \fR ] parameter allows a user to configure his/her own
Xlayout.  If the [ \fB -l \fR ] parameter is used, then the output is written
Xinto the specified file, else the output is dumped to standard out.  In
Xsetup mode, the left button will create a tile position where specified.  
XAny other button will delete the specified tile position.  The "DONE" 
Xoption will dump the layout only if there are no more tiles to place.  The
X"NEW" option will clear the board to start designing a new layout.  The
X"SAME" option does not do anything.  "QUIT", as usual, quits.  The following
Xexample demonstrates setup mode:
X.br
X
X.br
X	xmahjongg -s -l test	(this will create a layout called 'test')
X.br
X	xmahjongg -l ./test	(this will play the just created layout)
X.br
X
X.br
X.SH FILES
X/usr/games/xmahjongg			executable
X.SH AUTHOR
XCopyright 1990 Jeff S. Young
X.br
X<jsy@cray.com>
X.br
X
X.br
XThe tiles themselves are copyright 1988 by Mark A. Holm 
X<tektronix!tessi!exc!markh>.  His copyright notice is included in the 
Xsource code.
X.SH BUGS
XDoesn't use the Xdefault information.
X.PP
XNo permanent score file.
X.PP
XYou cannot have the same user name for two different players in a tournament.
X.PP
XUses sockets for tournament mode.
X.PP
XDoesn't read the layout file in setup mode.  
END_OF_xmahjongg.6
if test 5271 -ne `wc -c <xmahjongg.6`; then
    echo shar: \"xmahjongg.6\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xmahjongg.mk -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xmahjongg.mk\"
else
echo shar: Extracting \"xmahjongg.mk\" \(853 characters\)
sed "s/^X//" >xmahjongg.mk <<'END_OF_xmahjongg.mk'
X#
X#*****************************************************************************
X#									      *
X#	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the   *
X#	copyright laws of the United States.			      	      *
X#									      *
X#*****************************************************************************
X#
X
X#
X#	makefile for xmahjongg
X#
XXINC	= /usr/include
XXLIB	= /usr/lib/libX11.a
XBIN	= /usr/bin/X11
XTMP	= /usr/lib/X11/xmahjongg
XCFLAGS	= -O -I$(XINC) -DGLOBAL=extern -DLAYOUT=\"$(TMP)\"
XBOARDS	= default bridge wedges
XOBJS	= xmahjongg.o draw.o event.o initial.o packet.o play.o random.o \
X	  sysdep.o variables.o
X
Xall:	xmahjongg
X
Xxmahjongg: $(OBJS)
X	   $(CC) $(CFLAGS) -o xmahjongg $(OBJS) $(XLIB)
X
Xinstall: all
X	 -mkdir $(TMP)
X	 cp $(BOARDS) $(TMP)
X	 cp xmahjongg $(BIN)
X	 chmod 711 $(BIN)/xmahjongg
Xclean: 
X	rm -f xmahjongg *.o
X
END_OF_xmahjongg.mk
if test 853 -ne `wc -c <xmahjongg.mk`; then
    echo shar: \"xmahjongg.mk\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f icon.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"icon.h\"
else
echo shar: Extracting \"icon.h\" \(3576 characters\)
sed "s/^X//" >icon.h <<'END_OF_icon.h'
X/*
X ******************************************************************************
X *									      *
X *	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the   *
X *	copyright laws of the United States.			      	      *
X *									      *
X ******************************************************************************
X */
X
Xunsigned char icon_tiles_bits[] = {
X   0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
X   0x00, 0xe0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0xfc, 0xff, 0x00,
X   0x06, 0x06, 0x00, 0x80, 0x00, 0x3e, 0xf3, 0x01, 0x0e, 0x07, 0x00, 0x80,
X   0x80, 0x07, 0x83, 0x07, 0x9c, 0x03, 0x00, 0x80, 0xc0, 0x01, 0x03, 0x0e,
X   0x98, 0x01, 0x00, 0x80, 0xc0, 0x03, 0x03, 0x0f, 0xf8, 0x01, 0x00, 0x80,
X   0x60, 0x07, 0x83, 0x1b, 0xf0, 0x00, 0x00, 0x80, 0x70, 0xce, 0xcf, 0x39,
X   0xf0, 0x10, 0x11, 0x91, 0x30, 0xfc, 0xff, 0x30, 0xf8, 0xb1, 0x29, 0x91,
X   0x30, 0x78, 0x78, 0x30, 0x98, 0x51, 0x45, 0x91, 0x38, 0x18, 0x60, 0x70,
X   0x9c, 0x13, 0x7d, 0x9f, 0x18, 0x1c, 0xe0, 0x60, 0x0e, 0x17, 0x45, 0x91,
X   0x18, 0x0c, 0xc0, 0x60, 0x06, 0x16, 0x45, 0x91, 0xf8, 0x0f, 0xc0, 0x7f,
X   0x00, 0x00, 0x00, 0x80, 0xf8, 0x0f, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x80,
X   0x18, 0x0c, 0xc0, 0x60, 0x98, 0x13, 0x39, 0x8e, 0x18, 0x1c, 0xe0, 0x60,
X   0x50, 0x34, 0x45, 0x91, 0x38, 0x18, 0x60, 0x70, 0x50, 0x54, 0x05, 0x81,
X   0x30, 0x78, 0x78, 0x30, 0x50, 0x54, 0x65, 0x99, 0x30, 0xfc, 0xff, 0x30,
X   0x52, 0x94, 0x45, 0x91, 0x70, 0xce, 0xcf, 0x39, 0x9e, 0x13, 0x39, 0x8e,
X   0x60, 0x07, 0x83, 0x1b, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x03, 0x03, 0x0f,
X   0x00, 0x00, 0x00, 0x80, 0xc0, 0x01, 0x03, 0x0e, 0x00, 0x00, 0x00, 0x80,
X   0x80, 0x07, 0x83, 0x07, 0x00, 0x00, 0x00, 0x80, 0x00, 0x3e, 0xf3, 0x01,
X   0x00, 0x00, 0x00, 0x80, 0x00, 0xfc, 0xff, 0x00, 0x00, 0x00, 0x00, 0x80,
X   0x00, 0xe0, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
X   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x00, 0xff, 0xff, 0x03,
X   0x00, 0xe0, 0x03, 0x80, 0x00, 0xff, 0xff, 0x03, 0x00, 0x38, 0x03, 0x80,
X   0x00, 0x70, 0x38, 0x00, 0x00, 0x0e, 0x0f, 0x80, 0x00, 0x70, 0x38, 0x00,
X   0x00, 0x83, 0x0f, 0x80, 0x00, 0x70, 0x38, 0x00, 0x00, 0x71, 0x00, 0x80,
X   0x00, 0x70, 0x38, 0x00, 0x80, 0x0f, 0x00, 0x80, 0x00, 0x70, 0x38, 0x00,
X   0xf0, 0x80, 0x01, 0x80, 0x00, 0x70, 0x38, 0x00, 0x00, 0xfc, 0x03, 0x80,
X   0x00, 0x70, 0x38, 0x00, 0x00, 0x2e, 0x03, 0x80, 0x00, 0x70, 0x38, 0x00,
X   0x00, 0x23, 0x03, 0x80, 0x00, 0x70, 0x38, 0x00, 0x00, 0xf3, 0x03, 0x80,
X   0x00, 0x70, 0x38, 0x00, 0x00, 0x3f, 0x03, 0x80, 0x00, 0x70, 0x38, 0x00,
X   0x00, 0x23, 0x03, 0x80, 0x00, 0xff, 0xff, 0x03, 0x00, 0xfb, 0x03, 0x80,
X   0x00, 0xff, 0xff, 0x03, 0x00, 0x2f, 0x03, 0x80, 0x00, 0x70, 0x38, 0x00,
X   0x00, 0x23, 0xfe, 0x83, 0x00, 0x70, 0x38, 0x00, 0x00, 0xf3, 0xe3, 0x8f,
X   0x00, 0x70, 0x38, 0x00, 0x00, 0x3f, 0x02, 0x8f, 0x00, 0x70, 0x38, 0x00,
X   0xc0, 0x07, 0x06, 0x8e, 0x00, 0x70, 0x38, 0x00, 0x70, 0xe0, 0x0f, 0x9e,
X   0x00, 0x70, 0x38, 0x00, 0x1e, 0x78, 0x0c, 0x8e, 0x00, 0x70, 0x38, 0x00,
X   0x0c, 0x1f, 0x08, 0x8f, 0x00, 0x70, 0x38, 0x00, 0x9c, 0x07, 0x80, 0x87,
X   0x00, 0x70, 0x38, 0x00, 0x18, 0x83, 0xc1, 0x83, 0x00, 0x70, 0x38, 0x00,
X   0x38, 0x00, 0xe7, 0x81, 0x00, 0x70, 0x38, 0x00, 0x30, 0x00, 0xfc, 0x80,
X   0x00, 0xff, 0xff, 0x03, 0x00, 0x00, 0x70, 0x80, 0x00, 0xff, 0xff, 0x03,
X   0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00};
END_OF_icon.h
if test 3576 -ne `wc -c <icon.h`; then
    echo shar: \"icon.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f patchlevel.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"patchlevel.h\"
else
echo shar: Extracting \"patchlevel.h\" \(358 characters\)
sed "s/^X//" >patchlevel.h <<'END_OF_patchlevel.h'
X/*
X ******************************************************************************
X *									      *
X *	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the   *
X *	copyright laws of the United States.			      	      *
X *									      *
X ******************************************************************************
X */
X#define	PATCHLEVEL 0
END_OF_patchlevel.h
if test 358 -ne `wc -c <patchlevel.h`; then
    echo shar: \"patchlevel.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f variables.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"variables.h\"
else
echo shar: Extracting \"variables.h\" \(2009 characters\)
sed "s/^X//" >variables.h <<'END_OF_variables.h'
X/*
X ******************************************************************************
X *									      *
X *	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the   *
X *	copyright laws of the United States.			      	      *
X *									      *
X ******************************************************************************
X */
X
Xextern	int	optind;
Xextern	int	opterr;
Xextern	char	*optarg;
X
XGLOBAL	int	maxfds;
XGLOBAL	int	playfds;
XGLOBAL	int	num_games;
XGLOBAL	int	done_count;
XGLOBAL	int	setup_flag;
XGLOBAL	int	tourn_flag;
XGLOBAL	int	color_type;
XGLOBAL	int	num_players;
XGLOBAL	int	iconic_start;
XGLOBAL	int	keep_playing;
XGLOBAL	int	reverse_video;
XGLOBAL	int	tiles_remaining;
XGLOBAL	int	tile_data[TILES];
XGLOBAL	long	seed;
XGLOBAL	long	buffer[256];
XGLOBAL	char	*layout;
XGLOBAL	char	*tile_font;
XGLOBAL	char	*display_name;
XGLOBAL	Tile	*flink;
XGLOBAL	Tile	*blink;
XGLOBAL	Tile	*tile1p;
XGLOBAL	Tile	*tile2p;
XGLOBAL	Tile	*order[TILES];
XGLOBAL	Tile	tiles[ROWS][COLS][LEVS];
XGLOBAL	Ulong	fore_colors[LEVS];
XGLOBAL	Ulong	back_colors[LEVS];
XGLOBAL	Player	player[MAX_PLAYERS];
XGLOBAL	Player	*mypp;
XGLOBAL	Player	*pp;
XGLOBAL	Packet	packet;
X
XGLOBAL	int	x_coor;
XGLOBAL	int	y_coor;
XGLOBAL	int	BorderColor;
X
XGLOBAL	int		XGameFD;
XGLOBAL	int		XGameDepth;
XGLOBAL	int		XGameScreen;
XGLOBAL	GC		XGameBorderGC;
XGLOBAL	GC		XGameTextGC[2];
XGLOBAL	GC		XGameOtherGC[2];
XGLOBAL	GC		XGameTileGC[LEVS][2];
XGLOBAL	Ulong		XGameGrey;
XGLOBAL	Ulong		XGameBlack;
XGLOBAL	Ulong		XGameWhite;
XGLOBAL	Cursor		XGameCursor;
XGLOBAL	Pixmap		XGameIcon;
XGLOBAL	Pixmap		XGamePixmap;
XGLOBAL	Window		XGameWindow;
XGLOBAL	Window		XGameNewWindow;
XGLOBAL	Window		XGameDoneWindow;
XGLOBAL	Window		XGameQuitWindow;
XGLOBAL	Window		XGameSameWindow;
XGLOBAL	Window		XGamePlayWindow;
XGLOBAL	Window		XGameCountWindow;
XGLOBAL	XEvent		XGameEvent;
XGLOBAL	XPoint		XGamePoint[12];
XGLOBAL	Colormap 	XGameColormap;
XGLOBAL	XSizeHints	XGameHints;
XGLOBAL	Display		*XGameDisplay;
XGLOBAL	Visual		*XGameVisual;
XGLOBAL	XFontStruct 	*XGameTextFont;
XGLOBAL	XFontStruct 	*XGameTileFont;
END_OF_variables.h
if test 2009 -ne `wc -c <variables.h`; then
    echo shar: \"variables.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f xmahjongg.h -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"xmahjongg.h\"
else
echo shar: Extracting \"xmahjongg.h\" \(3427 characters\)
sed "s/^X//" >xmahjongg.h <<'END_OF_xmahjongg.h'
X/*
X ******************************************************************************
X *									      *
X *	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the   *
X *	copyright laws of the United States.			      	      *
X *									      *
X ******************************************************************************
X */
X
X/*
X *	Include file for xmahjongg
X */
X
X/*
X *	Path used for layout files
X */
X#define	LAYOUT		"/home/poplar1/jsy/tmp/xmahjongg"
X
X/*
X *	Fundamental definitions
X */
Xtypedef unsigned char	Uchar;
Xtypedef unsigned long	Ulong;
X
X#define	TILES		144
X
X#define ROWS		15
X#define COLS		29
X#define LEVS		7
X
X#define	TRUE		1
X#define	FALSE		0
X
X#define FREE		0
X#define	USED		1
X
X/*
X *	Dimensions for boxes, tiles and options
X */
X#define	TILE_SIDE	64
X
X#define	ICON_WIDTH	64
X#define	ICON_HEIGHT	64
X
X#define	PLAY_WIDTH	1000
X#define	PLAY_HEIGHT	616
X
X#define	COUNT_WIDTH	192
X#define	COUNT_HEIGHT	64
X
X#define	SHADE_WIDTH	4
X#define	SHADE_HEIGHT	64
X
X#define	OPTION_WIDTH	64
X#define	OPTION_HEIGHT	32
X
X#define WINDOW_WIDTH	1000
X#define WINDOW_HEIGHT	752
X
X#define BORDER_WIDTH	2
X
X/*
X *	Upper left coordinates for items
X */
X#define X_TILE		10
X#define Y_TILE		40
X
X#define X_PLAY		-2
X#define Y_PLAY		178
X
X#define X_DONE		800
X#define Y_DONE		100
X
X#define X_SAME		800
X#define Y_SAME		30
X
X#define X_QUIT		900
X#define Y_QUIT		100
X
X#define X_NEW		900
X#define Y_NEW		30
X
X#define	X_COPY		800
X#define	Y_COPY		150
X
X#define	X_RIGHTS	800
X#define	Y_RIGHTS	162
X
X#define	X_COUNT		55
X#define	Y_COUNT		100
X
X#define	X_BOARD		345
X#define	Y_BOARD		40
X
X#define	X_NAMES		260
X#define	Y_NAMES		55
X
X#define	X_SCORE		345
X#define	Y_SCORE		55
X
X#define in_bounds(x,y)	((0 <= x) && (x < ROWS) && (0 <= y) && (y < COLS))
X
X/*
X *	Tile structure
X */
Xtypedef	struct tile	Tile;
X
Xstruct tile {
X	int	x;
X	int	y;
X	int	row;
X	int	col;
X	int	lev;
X	int	data;
X	int	type;
X	int	init;
X	int	state;
X	long	value;
X	Tile	*flink;
X	Tile	*blink;
X};
X
X#define	INDEX_NUMBER		0x01
X#define	INDEX_BAMBOO		0x11
X#define	INDEX_CIRCLE		0x21
X#define	INDEX_IDEOGRAPH		0x31
X#define	INDEX_DIRECTION		0x41
X#define	INDEX_PLANT		0x51
X#define	INDEX_SEASON		0x61
X#define	INDEX_DRAGON		0x71
X
X#define	INDEX_DONE		0x5a
X#define	INDEX_NEW		0x5b
X#define	INDEX_QUIT		0x5c
X#define	INDEX_SAME		0x5d
X
X#define	INDEX_A			0x66
X#define	INDEX_G			0x67
X#define	INDEX_H			0x68
X#define	INDEX_J			0x69
X#define	INDEX_M			0x6a
X#define	INDEX_N			0x6b
X#define	INDEX_O			0x6c
X#define	INDEX_X			0x6d
X
X/*
X *	Tournament mode variables and structures
X */
X#define	XPORT		3657		/* port value for tournaments */
X#define	MAX_PLAYERS	5
X#define MAX_BOARDS	7
X#define	HOSTNAMELEN	256
X
Xtypedef	struct player	Player;
X
Xstruct player {
X	char	name[12];
X	char	machine[HOSTNAMELEN];
X	long	x;
X	long	y;
X	long	fd;
X	long	type;
X	long	port;
X	long	done;
X	long	quit;
X	long	total;
X	long	tiles[MAX_BOARDS];
X	long	board[MAX_BOARDS];
X};
X
Xtypedef struct packet	Packet;
X
Xstruct packet {
X	short	type;
X	short	port;
X	short	extra;
X	short	tiles;
X	long	board;
X	char	name[12];
X};
X
X#define	GAME_START	1
X#define	GAME_PLAY	2
X#define	GAME_DONE	3
X#define	GAME_QUIT	4
X
X/*
X *	X Window stuff
X */
X#define TEXT_FONT	"6x10"
X#define TILE_FONT	"xmahjongg"
X#define XGameEvents	ButtonPressMask | ExposureMask | StructureNotifyMask
X
X/*
X *	Error messages
X */
X#define	BAD_USERNAME	"invalid user@machine syntax"
X#define	BAD_SEED	"-b not allowed with -s"
X#define	BAD_GAMES	"-n not allowed with -s"
X#define	BAD_TOURN	"-p not allowed with -s"
X#define	BAD_COLOR	"-c not allowed with -s"
END_OF_xmahjongg.h
if test 3427 -ne `wc -c <xmahjongg.h`; then
    echo shar: \"xmahjongg.h\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f COPYRIGHT -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"COPYRIGHT\"
else
echo shar: Extracting \"COPYRIGHT\" \(1073 characters\)
sed "s/^X//" >COPYRIGHT <<'END_OF_COPYRIGHT'
X/*
X * Copyright 1990 Jeff S. Young
X *
X * Permission to use, copy, modify, and distribute this software and its
X * documentation for any purpose and without fee is hereby granted, provided
X * that the above copyright notice appear in all copies, that both the above
X * copyright notice and this permission notice appear in supporting documen-
X * tation, and that the original copyright notices on the game boards are
X * displayed in their original format and clarity.  Permission to sell this
X * software is not NOT granted without written permission from the author.
X * Permission to include this software free with other software packages in
X * NOT granted without written permission from the author.
X *
X * This distribution is publicly available, but is NOT in the public domain.
X *
X * I make no representations about the suitability of this software for any
X * purpose.  It is provided "as is" without express or implied warranty.
X *
X * Author:  Jeff S. Young
X *          Cray Research, Inc.
X *	    655F Loan Oak Drive
X *	    Eagan, MN  55121
X *
X *	    jsy@cray.com
X */
END_OF_COPYRIGHT
if test 1073 -ne `wc -c <COPYRIGHT`; then
    echo shar: \"COPYRIGHT\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f Imakefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Imakefile\"
else
echo shar: Extracting \"Imakefile\" \(387 characters\)
sed "s/^X//" >Imakefile <<'END_OF_Imakefile'
X# 
X#	xmahjongg - Mahjongg game
X# 
X#	Copyright (c) 1990 by Jeff S. Young.  All rights reserved under the 
X#	copyright laws of the United States.
X# 
XLOCAL_LIBRARIES = $(XLIB) 
XSRCS	= xmahjongg.c draw.c event.c initial.c packet.c play.c random.c sysdep.c variables.c
XOBJS	= xmahjongg.o draw.o event.o initial.o packet.o play.o random.o sysdep.o variables.o
X
XComplexProgramTarget(xmahjongg)
END_OF_Imakefile
if test 387 -ne `wc -c <Imakefile`; then
    echo shar: \"Imakefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README.1 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README.1\"
else
echo shar: Extracting \"README.1\" \(2024 characters\)
sed "s/^X//" >README.1 <<'END_OF_README.1'
X
X/*
X * Copyright 1989 Jeff S. Young
X */
X
XThis program is very easy to get up and running.  You only have to run the
Xmake and install it in your favorite directory.  We have played this game on
XSUN systems (3 and 4) and microVaxes, so that is should work almost anywhere.
XUnfortunately, I wrote this game to learn X11 and it shows.  I will clean
Xit up when I come out with the color version (very soon).
X
XI would appreciate a copy of all modifications to the source so that I can
Xput out a new release when enough bugs are found.
X
XThe file 'xmahjongg.mk' is a very simple makefile for those of us who don't
Xunderstand imake.  Just change the first few lines to accomodate your system.
X
XRemember that Mark A. Holm has the original copyright on the look of the tiles.
XSee his README file which is included below.
X
XEnjoy!
X
X					Jeff S. Young
X
X--------------------------------------------------------------------------------
X
XMAHJONGG Version 1.0
X
XCopyright 1988 Mark A. Holm
X
XPermission is given to copy and distribute for non-profit purposes.
X
XThis game will operate on any Sun hardware that I know of with either
Xa monochrome or a color bit mapped tube running Sun 3.2 UNIX or later.
XMost of the development was done on a Sun 100U running Sun 3.5.
X
XPlease Note!! The automagic screen type determination will not recognize
Xall screen types unless compiled with <sys/fbio.h> from a 3.5 OS. If
Xcompiled with 3.2 not all monochrome types are recognized.
X
XINSTALLATION INSTRUCTIONS:
X
X1.	Unpack this kit in an empty directory and edit the Makefile to
X	set MANLOC and DESTDIR to the appropriate locations.
X
X2.	run 'make install'.  
X
XI have distributed the tiles as a compressed .o file to save on file
Xsizes and to preserve the artistic license of the game. If you would
Xlike the source to the icons and the patches to iconedit so you can
Xmodify them send a request (and possibly a small donation ;^) to the 
Xaddress below.
X
XIf you have any questions or problems/bug reports, send them to me:
X
XMark A. Holm
Xtektronix!tessi!exc!markh
END_OF_README.1
if test 2024 -ne `wc -c <README.1`; then
    echo shar: \"README.1\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f README.2 -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README.2\"
else
echo shar: Extracting \"README.2\" \(3290 characters\)
sed "s/^X//" >README.2 <<'END_OF_README.2'
X
X
X/*
X * Copyright 1990 Jeff S. Young
X */
X
XThis is version 2 of the game xmahjongg.  It has been almost totally rewrit-
Xten.  I have run this program on SUN systems (3 and 4) and Michael Campanella
Xhas provided VMS help for xmahjongg.
X
XXmahjongg has 2 new features which will make life enjoyable:
X	1) we now have COLOR (well its about time)
X	2) we now have different board layouts
XSee the man page for information on these features
X
XTo get the game up quickly, you only need to do the following:
X	1) in xmahjongg.mk change the variable BIN to a directory where
X	   the executable will reside.
X	2) in xmahjongg.mk change the variable TMP to a directory where
X	   the layout files (default, bridge, and wedges) will reside.
X	3) cat x.bdf.1 x.bdf.2 x.bdf.3 > xmahjongg.bdf
X	4) create a font out of the xmahjongg.bdf file (see below)
X	5) make sure that the directory called TMP exists
X	6) run make -f xmahjongg.mk install
X	7) play a game
X
XTo create a font you need to convert the bdf file to an snf file (on SUNs
Xat least) or a pcf file (on DECstations).  To do this you need to run bdftosnf
Xor bdftopcf.  If you don't have these programs, look for an archive site that
Xdoes.  Next run a mkfontdir after moving the snf or pcf file into the correct
Xfont directory for your site.  This will give you a usable font.  Remember that
Xyou need to reboot your server or do an "xset +fp font_path" and a
X"xset fp rehash".  For those of you without in depth knowledge, the new snf
Xfile must be in a directory with other snf files only or in a directory by
Xitself.  This will allow the mkfontdir program to correctly make the font
Xdatabase for the given directory.
X
XThe layout files are a generalization of the board layout.  The default is
Xthe standard "pyramid".  You can create you own layouts.  See the man page
Xon how to do this.
X
XI would appreciate hearing about new layouts and any bugs which are found.
XI will post a patch when enough data comes in.
X
XRemember that Mark A. Holm has the original copyright on the look of the tiles.
XSee his README file which is included below.
X
XEnjoy!
X
XJeff S. Young
Xjsy@cray.com
X
X--------------------------------------------------------------------------------
X
XMAHJONGG Version 1.0
X
XCopyright 1988 Mark A. Holm
X
XPermission is given to copy and distribute for non-profit purposes.
X
XThis game will operate on any Sun hardware that I know of with either
Xa monochrome or a color bit mapped tube running Sun 3.2 UNIX or later.
XMost of the development was done on a Sun 100U running Sun 3.5.
X
XPlease Note!! The automagic screen type determination will not recognize
Xall screen types unless compiled with <sys/fbio.h> from a 3.5 OS. If
Xcompiled with 3.2 not all monochrome types are recognized.
X
XINSTALLATION INSTRUCTIONS:
X
X1.	Unpack this kit in an empty directory and edit the Makefile to
X	set MANLOC and DESTDIR to the appropriate locations.
X
X2.	run 'make install'.  
X
XI have distributed the tiles as a compressed .o file to save on file
Xsizes and to preserve the artistic license of the game. If you would
Xlike the source to the icons and the patches to iconedit so you can
Xmodify them send a request (and possibly a small donation ;^) to the 
Xaddress below.
X
XIf you have any questions or problems/bug reports, send them to me:
X
XMark A. Holm
Xtektronix!tessi!exc!markh
END_OF_README.2
if test 3290 -ne `wc -c <README.2`; then
    echo shar: \"README.2\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f bridge -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"bridge\"
else
echo shar: Extracting \"bridge\" \(2674 characters\)
sed "s/^X//" >bridge <<'END_OF_bridge'
X#
X#	bridge layout for Xmahjongg
X#
X#-----------------------------------------------------------------------------#
X	 0	 1	 0
X	 2	 1	 0
X	 4	 1	 0
X	 6	 1	 0
X	 8	 1	 0
X	10	 1	 0
X	12	 1	 0
X	14	 1	 0
X	 0	 1	 1
X	 2	 1	 1
X	 4	 1	 1
X	 6	 1	 1
X	 8	 1	 1
X	10	 1	 1
X	12	 1	 1
X	14	 1	 1
X	 0	 1	 2
X	 2	 1	 2
X	 4	 1	 2
X	 6	 1	 2
X	 8	 1	 2
X	10	 1	 2
X	12	 1	 2
X	14	 1	 2
X	 0	 1	 3
X	 2	 1	 3
X	 4	 1	 3
X	 6	 1	 3
X	 8	 1	 3
X	10	 1	 3
X	12	 1	 3
X	14	 1	 3
X#-----------------------------------------------------------------------------#
X	 0	27	 0
X	 2	27	 0
X	 4	27	 0
X	 6	27	 0
X	 8	27	 0
X	10	27	 0
X	12	27	 0
X	14	27	 0
X	 0	27	 1
X	 2	27	 1
X	 4	27	 1
X	 6	27	 1
X	 8	27	 1
X	10	27	 1
X	12	27	 1
X	14	27	 1
X	 0	27	 2
X	 2	27	 2
X	 4	27	 2
X	 6	27	 2
X	 8	27	 2
X	10	27	 2
X	12	27	 2
X	14	27	 2
X	 0	27	 3
X	 2	27	 3
X	 4	27	 3
X	 6	27	 3
X	 8	27	 3
X	10	27	 3
X	12	27	 3
X	14	27	 3
X#-----------------------------------------------------------------------------#
X	 2	 3	 0
X	 4	 3	 0
X	 6	 3	 0
X	 8	 3	 0
X	10	 3	 0
X	12	 3	 0
X	 2	 3	 1
X	 4	 3	 1
X	 6	 3	 1
X	 8	 3	 1
X	10	 3	 1
X	12	 3	 1
X	 2	 3	 2
X	 4	 3	 2
X	 6	 3	 2
X	 8	 3	 2
X	10	 3	 2
X	12	 3	 2
X#-----------------------------------------------------------------------------#
X	 2	25	 0
X	 4	25	 0
X	 6	25	 0
X	 8	25	 0
X	10	25	 0
X	12	25	 0
X	 2	25	 1
X	 4	25	 1
X	 6	25	 1
X	 8	25	 1
X	10	25	 1
X	12	25	 1
X	 2	25	 2
X	 4	25	 2
X	 6	25	 2
X	 8	25	 2
X	10	25	 2
X	12	25	 2
X#-----------------------------------------------------------------------------#
X	 4	 5	 0
X	 6	 5	 0
X	 8	 5	 0
X	10	 5	 0
X	 4	 5	 1
X	 6	 5	 1
X	 8	 5	 1
X	10	 5	 1
X#-----------------------------------------------------------------------------#
X	 4	23	 0
X	 6	23	 0
X	 8	23	 0
X	10	23	 0
X	 4	23	 1
X	 6	23	 1
X	 8	23	 1
X	10	23	 1
X#-----------------------------------------------------------------------------#
X	 6	 7	 0
X	 8	 7	 0
X#-----------------------------------------------------------------------------#
X	 6	21	 0
X	 8	21	 0
X#-----------------------------------------------------------------------------#
X	 7	 9	 0
X	 7	11	 0
X	 7	13	 0
X	 7	15	 0
X	 7	17	 0
X	 7	19	 0
X#-----------------------------------------------------------------------------#
X	 7	10	 1
X	 7	12	 1
X	 7	14	 1
X	 7	16	 1
X	 7	18	 1
X#-----------------------------------------------------------------------------#
X	 7	11	 2
X	 7	13	 2
X	 7	15	 2
X	 7	17	 2
X#-----------------------------------------------------------------------------#
X	 7	12	 3
X	 7	14	 3
X	 7	16	 3
X#-----------------------------------------------------------------------------#
X	 7	13	 4
X	 7	15	 4
X#-----------------------------------------------------------------------------#
X	 7	14	 5
X#-----------------------------------------------------------------------------#
X	 5	13	 0
X	 5	15	 0
X	 9	14	 0
END_OF_bridge
if test 2674 -ne `wc -c <bridge`; then
    echo shar: \"bridge\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f wedges -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"wedges\"
else
echo shar: Extracting \"wedges\" \(2050 characters\)
sed "s/^X//" >wedges <<'END_OF_wedges'
X#
X#	wedges layout for xmahjongg
X#
X  0   24    0
X  0   22    0
X  0   20    0
X  2   22    0
X  6   26    0
X  0   18    0
X  2   20    0
X  8   26    0
X  0   16    0
X  2   18    0
X  4   20    0
X  8   24    0
X 10   26    0
X  0   14    0
X  2   16    0
X  4   18    0
X 10   24    0
X 12   26    0
X  0   12    0
X  2   14    0
X  4   16    0
X  6   18    0
X 10   22    0
X 12   24    0
X  0   10    0
X  2   12    0
X  4   14    0
X  6   16    0
X 12   22    0
X  0    8    0
X  2   10    0
X  4   12    0
X  6   14    0
X  8   16    0
X 12   20    0
X  0    6    0
X  2    8    0
X  4   10    0
X  6   12    0
X  8   14    0
X  0    4    0
X  2    6    0
X  4    8    0
X  6   10    0
X  8   12    0
X 10   14    0
X 12   14    0
X 14   16    0
X 14   14    0
X 14   12    0
X  6    2    0
X  8    4    0
X 10    6    0
X 12    8    0
X  8    2    0
X 10    4    0
X 12    6    0
X 10    2    0
X 12    4    0
X 12    2    0
X  0   22    1
X  0   20    1
X  0   18    1
X  2   20    1
X  8   26    1
X  0   16    1
X  2   18    1
X 10   26    1
X  0   14    1
X  2   16    1
X  4   18    1
X 10   24    1
X 12   26    1
X  0   12    1
X  2   14    1
X  4   16    1
X 12   24    1
X  0   10    1
X  2   12    1
X  4   14    1
X  6   16    1
X 12   22    1
X  0    8    1
X  2   10    1
X  4   12    1
X  6   14    1
X  0    6    1
X  2    8    1
X  4   10    1
X  6   12    1
X  8   14    1
X 14   15    1
X 14   13    1
X  8    2    1
X 10    4    1
X 12    6    1
X 10    2    1
X 12    4    1
X 12    2    1
X  0   20    2
X  0   18    2
X  2   20    2
X  0   16    2
X  2   18    2
X 10   26    2
X  0   14    2
X  2   16    2
X  4   18    2
X 12   26    2
X  0   12    2
X  2   14    2
X  4   16    2
X 12   24    2
X  0   10    2
X  2   12    2
X  4   14    2
X  6   16    2
X  0    8    2
X  2   10    2
X  4   12    2
X  6   14    2
X 14   14    2
X 10    2    2
X 12    4    2
X 12    2    2
X  0   18    3
X  0   16    3
X  2   18    3
X  0   14    3
X  2   16    3
X 12   26    3
X  0   12    3
X  2   14    3
X  4   16    3
X  0   10    3
X  2   12    3
X  4   14    3
X 12    2    3
X  0   16    4
X  0   14    4
X  2   16    4
X  0   12    4
X  2   14    4
X  0   14    5
END_OF_wedges
if test 2050 -ne `wc -c <wedges`; then
    echo shar: \"wedges\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f default -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"default\"
else
echo shar: Extracting \"default\" \(1875 characters\)
sed "s/^X//" >default <<'END_OF_default'
X#
X#	default layout for Xmahjongg
X#
X#-----------------------------------------------------------------------------#
X	 0	 2	 0
X	 0	 4	 0
X	 0	 6	 0
X	 0	 8	 0
X	 0	10	 0
X	 0	12	 0
X	 0	14	 0
X	 0	16	 0
X	 0	18	 0
X	 0	20	 0
X	 0	22	 0
X	 0	24	 0
X	 2	 6	 0
X	 2	 8	 0
X	 2	10	 0
X	 2	12	 0
X	 2	14	 0
X	 2	16	 0
X	 2	18	 0
X	 2	20	 0
X	 4	 4	 0
X	 4	 6	 0
X	 4	 8	 0
X	 4	10	 0
X	 4	12	 0
X	 4	14	 0
X	 4	16	 0
X	 4	18	 0
X	 4	20	 0
X	 4	22	 0
X	 6	 2	 0
X	 6	 4	 0
X	 6	 6	 0
X	 6	 8	 0
X	 6	10	 0
X	 6	12	 0
X	 6	14	 0
X	 6	16	 0
X	 6	18	 0
X	 6	20	 0
X	 6	22	 0
X	 6	24	 0
X	 7	 0	 0
X	 7	26	 0
X	 7	28	 0
X	 8	 2	 0
X	 8	 4	 0
X	 8	 6	 0
X	 8	 8	 0
X	 8	10	 0
X	 8	12	 0
X	 8	14	 0
X	 8	16	 0
X	 8	18	 0
X	 8	20	 0
X	 8	22	 0
X	 8	24	 0
X	10	 4	 0
X	10	 6	 0
X	10	 8	 0
X	10	10	 0
X	10	12	 0
X	10	14	 0
X	10	16	 0
X	10	18	 0
X	10	20	 0
X	10	22	 0
X	12	 6	 0
X	12	 8	 0
X	12	10	 0
X	12	12	 0
X	12	14	 0
X	12	16	 0
X	12	18	 0
X	12	20	 0
X	14	 2	 0
X	14	 4	 0
X	14	 6	 0
X	14	 8	 0
X	14	10	 0
X	14	12	 0
X	14	14	 0
X	14	16	 0
X	14	18	 0
X	14	20	 0
X	14	22	 0
X	14	24	 0
X#-----------------------------------------------------------------------------#
X	 2	 8	 1
X	 2	10	 1
X	 2	12	 1
X	 2	14	 1
X	 2	16	 1
X	 2	18	 1
X	 4	 8	 1
X	 4	10	 1
X	 4	12	 1
X	 4	14	 1
X	 4	16	 1
X	 4	18	 1
X	 6	 8	 1
X	 6	10	 1
X	 6	12	 1
X	 6	14	 1
X	 6	16	 1
X	 6	18	 1
X	 8	 8	 1
X	 8	10	 1
X	 8	12	 1
X	 8	14	 1
X	 8	16	 1
X	 8	18	 1
X	10	 8	 1
X	10	10	 1
X	10	12	 1
X	10	14	 1
X	10	16	 1
X	10	18	 1
X	12	 8	 1
X	12	10	 1
X	12	12	 1
X	12	14	 1
X	12	16	 1
X	12	18	 1
X#-----------------------------------------------------------------------------#
X	 4	10	 2
X	 4	12	 2
X	 4	14	 2
X	 4	16	 2
X	 6	10	 2
X	 6	12	 2
X	 6	14	 2
X	 6	16	 2
X	 8	10	 2
X	 8	12	 2
X	 8	14	 2
X	 8	16	 2
X	10	10	 2
X	10	12	 2
X	10	14	 2
X	10	16	 2
X#-----------------------------------------------------------------------------#
X	 6	12	 3
X	 6	14	 3
X	 8	12	 3
X	 8	14	 3
X#-----------------------------------------------------------------------------#
X	 7	13	 4
END_OF_default
if test 1875 -ne `wc -c <default`; then
    echo shar: \"default\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 2 \(of 5\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 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

dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.