[unix-pc.sources] mahjongg game for 3B1, 1 of 2

thad@cup.portal.com (Thad P Floryan) (01/01/91)

Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site portal.UUcp
Path: portal!uunet!tektronix!tekgen!tekred!games
From: games@tekred.TEK.COM
Newsgroups: comp.sources.games
Subject: v05i061:  mahjongg-pc - mahjongg for the AT&T unixpc, Part01/02
Message-ID: <2991@tekred.TEK.COM>
Date: 31 Aug 88 19:09:17 GMT
Date-Received: 1 Sep 88 12:34:13 GMT
Sender: news@tekred.TEK.COM
Lines: 2313
Approved: billr@saab.CNA.TEK.COM
Portal-Origin: Usenet
Portal-Type: text
Portal-Location: 1054.3.601.1

Submitted by: Tom Tkacik <umix.cc.umich.edu!mcf!rphroy!tkacik>
Comp.sources.games: Volume 5, Issue 61
Archive-name: mahjongg-pc/Part01

	[[From the author: This is a port/rewrite of Mark Holm's Mahjongg
	  for the AT&T unixpc.  It is posted with his permission.]]

#! /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 1 (of 2)."
# Contents:  README MANIFEST Makefile event.c mahjongg.6 mahjongg.c
#   mahjongg.h tiles tiles.c tiles/autumn tiles/bam5 tiles/bam6
#   tiles/bamboo tiles/blank tiles/north tiles/orchid tiles/south
#   tiles/spring tiles/summer tiles/winter window.c
# Wrapped by billr@saab on Wed Aug 31 12:04:39 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(892 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XThis is a version of the Mahjongg game ported to the UNIXPC.
XIt came from the version by Mark Holm for the Sun, and
Xhas been modified/re-written/ported for/to the UNIXPC by Tom Tkacik.
X
XThe manual is in mahjongg.6.  It has been my attempt to recreate
Xthe Sun version as faithfully as possible, so if you have played that
Xversion, you should not have to read the manual.
X
XIf you have any problems with this version do not complain to Mark.
XPlease address all questions to me (...!rphroy!tetnix!tet).
X
XI do not like the borders on the standard windows, so I made my own.
XThe only problem is not having the move and resize icons.
XIf anyone can figure out how they might be implemented, I would
Xlike to hear about it.
X
XAll of the code, except for window.c, retains the copyrights of Mark Holm.
XYou may use window.c any way you see fit.
X
XType make, and have fun.
X
XTom Tkacik
X...!rphroy!tetnix!tet
END_OF_FILE
if test 892 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1757 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	This shipping list
X Makefile                   1	
X README                     1	
X event.c                    1	
X mahjongg.6                 1	
X mahjongg.c                 1	
X mahjongg.h                 1	
X tiles                      1	
X tiles.c                    1	
X tiles/B                    2	
X tiles/C                    2	
X tiles/F                    2	
X tiles/autumn               1	
X tiles/bam1                 2	
X tiles/bam2                 2	
X tiles/bam3                 2	
X tiles/bam4                 2	
X tiles/bam5                 1	
X tiles/bam6                 1	
X tiles/bam7                 2	
X tiles/bam8                 2	
X tiles/bam9                 2	
X tiles/bamboo               1	
X tiles/blank                1	
X tiles/cha1                 2	
X tiles/cha2                 2	
X tiles/cha3                 2	
X tiles/cha4                 2	
X tiles/cha5                 2	
X tiles/cha6                 2	
X tiles/cha7                 2	
X tiles/cha8                 2	
X tiles/cha9                 2	
X tiles/dot1                 2	
X tiles/dot2                 2	
X tiles/dot3                 2	
X tiles/dot4                 2	
X tiles/dot5                 2	
X tiles/dot6                 2	
X tiles/dot7                 2	
X tiles/dot8                 2	
X tiles/dot9                 2	
X tiles/east                 2	
X tiles/mum                  2	
X tiles/north                1	
X tiles/orchid               1	
X tiles/plum                 2	
X tiles/south                1	
X tiles/spring               1	
X tiles/summer               1	
X tiles/west                 2	
X tiles/winter               1	
X window.c                   1	
END_OF_FILE
if test 1757 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(613 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# This makefile uses the shared libraries
X# just type make
X#
X
XLDFLAGS = -s
XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile
XBIN = /usr/games
XMANDIR = /usr/man/man6
XLINT = lint -x
X
XSRC = mahjongg.c window.c tiles.c event.c
XOBJ = mahjongg.o window.o tiles.o event.o
X
Xall:	mahjongg
X
Xmahjongg:	$(OBJ)
X	$(LD) $(LDFLAGS) $(OBJ) $(SHAREDLIB) -o mahjongg
X
Xinstall: mahjongg
X	cp mahjongg $(BIN)/mahjongg
X	rm mahjongg
X#	cp mahjongg.6 $(MANDIR)/mahjongg.6
X
Xclean:
X	rm -f *.o core
X
Xlint:
X	$(LINT) $(SRC)
X
Xwindow.o : window.c mahjongg.h
Xmahjongg.o : mahjongg.c mahjongg.h
Xtiles.o : tiles.c mahjongg.h
Xevent.o : event.c mahjongg.h
X
END_OF_FILE
if test 613 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'event.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'event.c'\"
else
echo shar: Extracting \"'event.c'\" \(8397 characters\)
sed "s/^X//" >'event.c' <<'END_OF_FILE'
X/*
X *	This program contains much of the code from the original
X *	 Sun version of mahjongg, written by Mark Holm, which was
X *	 inspired by the PC version.
X *
X *	This version of Mahjongg was modified/re-written/ported
X *	 for/to the AT&T UNIXPC    by Thomas Tkacik
X *                                 ...rphroy!tetnix!tet.
X *
X *	Any problems or comments should be addressed to Tom Tkacik
X *	 and not Mark Holm, who had nothing to do with this version
X *	 and will not be able to help you.
X *
X */
X
X/*
X *	Copyright 1988, Mark Holm
X *			Exceptions
X *
X *	Permission is given to copy and distribute for non-profit purposes.
X *
X */
X
X/*      This file has the event handlers for the background and
X *       tiles in the play panel
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/mouse.h>
X#include "mahjongg.h"
X
Xint	undo_tiles[NUMTILES][2];
Xint	undo_count = 0;
Xint	help_mode = FALSE;
Xint	query_mode = FALSE;
Xint	tile_count;
Xint	selected[2];
X
X
X/*******************************************/
X
X/*
X * help the user -- show matching tiles
X */
X
Xhelp_proc()
X{
X	int         i;
X	static int  parse[2] = { 0, 0 };
X
X	if(selected[0] == -1) { /* find all pairs of matching tiles */
X
X	     /* if not in help mode, initialize search */
X
X		if(!(help_mode)) {
X			help_mode = TRUE;
X			parse[0] = 143;
X			parse[1] = 142;
X		}
X
X	     /* look for a free tile */
X
X		for(; parse[0] >= 0; parse[0]--) {
X			if(!((tiles[parse[0]].top_free && 
X		 	     (tiles[parse[0]].left_free ||
X			      tiles[parse[0]].right_free) &&
X			   (!(tiles[parse[0]].removed))))) {
X
X				continue; /* not available -- try another */
X			}
X
X		     /* found a free tile */
X		     /* check for a matching second tile */
X
X			for(; parse[1] >= 0; parse[1]--) {
X				if((tiles[parse[0]].value ==
X						tiles[parse[1]].value) &&
X				   (parse[0] != parse[1]) &&
X			    	   (tiles[parse[1]].top_free &&
X			           (tiles[parse[1]].left_free ||
X						tiles[parse[1]].right_free) &&
X			    	 (!(tiles[parse[1]].removed)))) {
X
X			    	     /* Found a match -- show them */
X
X			    		selected[0] = parse[0];
X			    		selected[1] = parse[1];
X			    		preview_tile(selected[0]);
X			    		preview_tile(selected[1]);
X
X				     /* does he need more help */
X
X			    		wcmd(wn,"Show next move? [Y] [] [N]");
X
X				     /* prepare for next help */
X
X			    		parse[1]--;
X			    		return;
X				}
X			}
X
X		     /* no matching tile was found */
X		     /* look for the next free tile */
X
X		     /* going around again */
X
X			parse[1] = parse[0] - 2;
X
X		}
X
X	     /* we found all matching tiles -- beep and leave help mode */
X
X		help_mode = FALSE;
X		window_bell();
X		wcmd(wn,"");
X
X	} else {  /* user selected one tile -- look for a match */
X
X	    /* deselect previous choice if there was one */
X	    /* and cancel preview of it */
X
X		if (selected[1] != -1) {
X			preview_tile(selected[1]);
X			selected[1] = -1;
X		}
X
X
X	     /* if not in query mode then start the search */
X	     /* otherwise, continue from last tile */
X
X		if (!query_mode) {
X			query_mode = TRUE;
X			parse[0] = 143;
X		}
X
X
X		for(i = parse[0]; i >= 0; i--) {
X
X		     /* is this a match */
X
X			if ((tiles[i].value == tiles[selected[0]].value) &&
X			    (i != selected[0]) &&
X			    (tiles[i].top_free &&
X			    (tiles[i].left_free || tiles[i].right_free) &&
X			  (!(tiles[i].removed)))) {
X
X			     /* yes, we found one */
X			     /* show it */
X
X				selected[1] = i;
X				preview_tile(selected[1]);
X
X			     /* does he want to remove them */
X
X				wcmd(wn, "Please confirm. [Y] [NEXT] [N]");
X
X			     /* return to sender */
X
X				parse[0] = i - 1;
X				return;
X		    	}
X		}
X
X	     /* oops! could not find a match -- stop search */
X
X		query_mode = FALSE;
X		preview_tile(selected[0]);
X		selected[0]= -1;
X		wcmd(wn, "");
X		window_bell();
X
X    	}
X}
X
X/*
X * remove (or restore) selected tiles
X */
X
Xremove_tiles(REMOVE)
Xboolean	REMOVE;
X{
X	int	data[2];
X	int	i;
X
X	if (REMOVE) {   /* get tiles to be removed */
X
X		data[0] = selected[0];
X		data[1] = selected[1];
X
X	} else { 	/* or those to be replaced */
X
X		data[0] = undo_tiles[undo_count][0];
X		data[1] = undo_tiles[undo_count][1];
X
X	}
X
X     /* adjust adjacent tiles */
X
X	for(i = 0; i < 2 && tiles[data[0]].left_next[i] != -1; i++)
X		tiles[tiles[data[0]].left_next[i]].right_free = REMOVE;
X
X	for(i = 0; i < 2 && tiles[data[1]].left_next[i] != -1; i++)
X		tiles[tiles[data[1]].left_next[i]].right_free = REMOVE;
X
X	for(i = 0; i < 2 && tiles[data[0]].right_next[i] != -1; i++)
X		tiles[tiles[data[0]].right_next[i]].left_free = REMOVE;
X
X	for(i = 0; i < 2 && tiles[data[1]].right_next[i] != -1; i++)
X		tiles[tiles[data[1]].right_next[i]].left_free = REMOVE;
X
X     /* adjust covered tiles */
X
X	for(i = 0; i < 4 && tiles[data[0]].covered[i] != -1; i++)
X		tiles[tiles[data[0]].covered[i]].top_free = REMOVE;
X
X	for(i = 0; i < 4 && tiles[data[1]].covered[i] != -1; i++)
X		tiles[tiles[data[1]].covered[i]].top_free = REMOVE;
X
X     /* set removed flags */
X
X	tiles[data[0]].removed = REMOVE;
X	tiles[data[1]].removed = REMOVE;
X
X     /* remove confirm message */
X
X	wcmd(wn, "");
X
X	if (REMOVE) {
X
X	     /* turn off preview */
X
X		preview_tile(selected[0]);
X		preview_tile(selected[1]);
X
X	} else {
X
X	     /* turn off preview of any selected tiles */
X
X		if(selected[0] != -1) {
X			preview_tile(selected[0]);
X		}
X
X		if(selected[1] != -1) {
X			preview_tile(selected[1]);
X		}
X	}
X
X     /* fix tile counter */
X
X	tile_count += (REMOVE) ? -2 : 2;
X
X	if (REMOVE) {
X
X	     /* update undo_count */
X
X		undo_count++;
X
X	     /* update removed array */
X
X		undo_tiles[undo_count][0] = selected[0];
X		undo_tiles[undo_count][1] = selected[1];
X
X	     /* check for clean board and congrat them */
X
X		if(tile_count == 0) 
X			wcmd(wn, "Congratulations!! Press 'SAME' 'NEW'");
X
X	} else { /* decrement undo_count */
X		undo_tiles[undo_count][0] = -1;
X		undo_tiles[undo_count][1] = -1;
X		undo_count--;
X	}
X
X     /* deselect tiles */
X     /* we will redisplay the playing field so no need to unpreview */
X
X	selected[0] = -1;
X	selected[1] = -1;
X
X     /* show the corrected playing field */
X
X	draw_tiles();
X}
X
X/*
X * perform secondary mouse actions 
X */
X
Xplay_back_proc(button)
Xint		button;
X{
X
X	if ((button == MBUTM) && (selected[0] != -1) && !help_mode) {
X
X	     /* he wants to be shown a matching tile */
X
X		help_proc();
X
X	} else {
X
X		query_mode = FALSE;
X
X		if (selected[1] != -1) { /* doing confirm  or next help */
X
X			switch (button) {
X
X			case MBUTL:
X				if (help_mode) {
X
X				     /* cancel preview of selected tiles */
X
X					preview_tile(selected[0]);
X					preview_tile(selected[1]);
X
X				     /* Clean up selected's variables */
X
X					selected[0] = -1;
X					selected[1] = -1;
X
X				    /* do next help */
X
X					help_proc();
X
X				} else {
X
X				     /* confirmed selection. remove them */
X
X					remove_tiles(TRUE);
X
X				}
X				break;
X
X			case MBUTR:
X
X			     /* refused selection */
X
X			     /* cancel preview of selected tiles */
X
X				preview_tile(selected[0]);
X				preview_tile(selected[1]);
X
X			     /* Clean up selected's variables */
X
X				selected[0] = -1;
X				selected[1] = -1;
X
X			     /* remove confirm message */
X
X				wcmd(wn, "");
X
X			     /* if in help mode toggle out */
X
X				if (help_mode)
X					help_mode = FALSE; 
X
X				break;
X			}
X		}
X    	}
X}
X
X/*
X * perform mouse action
X */
X
Xplay_event_proc(i, button)
Xint	i;
Xint	button;
X{
X     /* check to see if in help_mode */
X
X	if (help_mode || query_mode) {
X		play_back_proc(button);
X		return;
X	}
X
X     /* check to see if just confirming */
X
X	if (selected[1] != -1) {
X		play_back_proc(button);
X		return;
X	}
X
X	switch(button) {
X
X	case MBUTL: 
X
X	     /* Left button down begin selection */
X
X	     /* if no tile is selected then just ignore it */
X		if (i == -1)
X			return;
X
X		if (selected[0] == -1) {
X
X		     /* select first tile of pair */
X
X			selected[0] = i;
X			preview_tile(selected[0]);
X
X		} else if (selected[0] == i) {
X
X		     /* deselect first tile */
X
X			preview_tile(selected[0]);
X			selected[0] = -1;
X
X		} else if(tiles[selected[0]].value == tiles[i].value) {
X
X		     /* select second tile */
X
X			selected[1] = i;
X			preview_tile(selected[1]);
X			wcmd(wn, "Please confirm. [Y] [] [N]");
X		
X		} else {
X
X		     /* illegal move -- beep at them */
X
X			window_bell();
X		}
X
X		break;
X
X	case MBUTM:
X		if (selected[0] != -1) {
X
X		     /* request for help */
X
X			help_proc();
X		}
X
X		break;
X
X		/* and all else shall pass */
X	}
X}
X
X/*
X * undo the last move -- may be called repeatedly
X */
X
Xundo_proc()
X{
X	if(undo_count < 0)
X		window_bell();
X	else
X		remove_tiles(FALSE);
X}
X
END_OF_FILE
if test 8397 -ne `wc -c <'event.c'`; then
    echo shar: \"'event.c'\" unpacked with wrong size!
fi
# end of 'event.c'
fi
if test -f 'mahjongg.6' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mahjongg.6'\"
else
echo shar: Extracting \"'mahjongg.6'\" \(3498 characters\)
sed "s/^X//" >'mahjongg.6' <<'END_OF_FILE'
X.\"	Copyright 1988 Mark A. Holm
X.\"
X.\"	Permission is given to copy and distribute for non-profit purposes.
X.\"
X.TH MAHJONGG 6 "1 August 1988"
X.SH NAME
Xmahjongg \- Solitaire game using mahjongg tiles
X.SH SYNOPSIS
X.B /usr/games/mahjongg
X[ \fB-n \fI###\fR ]
X.SH DESCRIPTION
X.I Mah jongg
Xis an ancient chinese game whose origins are supposed to date back around
X3000 years. It is typically a four player game with similarities to most
Xpopular card games. This version is a solitaire game using the mahjongg
Xtiles.
XIt has been ported to the UNIXPC from the SUN version, which was
Xinspired by a version originally seen on a PC. 
X.SH THEORY OF PLAY
XThe object of the game is to remove all the tiles from the board in matching
Xpairs. Tiles match only if they are identical. Exceptions are the flower
Xand season tiles. Any season tile will match any other season tile and any
Xflower tile will match any other flower tile. Tiles may be removed from the
Xboard only if they have either a left or a right edge open and they do not hav
e
Xa tile covering them.
X.PP
XThe display is divided into three areas:  the play area, which shows the
Xtiles, the control window, which shows the
Xnumber of tiles remaining and the game control buttons.  As tiles are removed
Xthe "Tiles Remaining" count will be updated and play related messages and
Xmouse button defintions will 
Xbe shown just above the control buttons.
X.PP
XTiles are selected by placing the mouse icon on a tile and pressing the left
Xbutton. To deselect a tile simply repress the left button while on the tile.
XAny time an invalid selection is made, any previous selections for that turn
Xare cleared.
XAfter selecting a pair of tiles, you will be asked to confirm your choice.
XPress the left mouse button to confirm or the right mouse button to cancel.
X.SH HELP FEATURES
XTwo help features are currently implemented. By selecting the "help" button
Xwhen no tiles are selected, you will be shown all available
Xtile combinations. To see each combination press the left mouse button until
Xno more moves are shown. To cancel "help" press the
Xright mouse button. If you have selected a tile, pressing the middle mouse
Xbutton, or selecting the "help" button, will find the 
Xfirst matching tile (if any) starting at the top of the pile and working down.
XIf a match is found, you will be asked to confirm and the pair will be
Xremoved from the board.
XIf an alternate match is available pressing the middle mouse button
Xlabeled "NEXT" will show it.
X.SH UNDO
XSince some people tend to be a little faster on the mouse then they should be,
Xthe undo feature was implemented. The "undo" button replaces the previous
Xpair that was removed from board. You can continue to press undo until you
Xget back to a new board.
X.SH NEW and SAME
XSelecting the "new board" button restarts the game with a new
Xboard. Selecting the "same board" button restarts the game using the same boar
d.
XEither button may be used at any time during the game.
X.SH OPTIONS
X.IP \fB\-n \fI###\fR
XStart with board number ###. Boards through 65536 are available.
X.SH DIAGNOSTICS
X.SH FILES
X/usr/games/mahjongg			executable
X.SH AUTHOR
XCopyright 1988 Mark A. Holm
X.br
X<tektronix!tessi!exc!markh>
X.sp
XPorted to the UNIXPC by Thomas Tkacik
X.br
X<rphroy!tetnix!tet>
X.SH BUGS
XBoard number is not checked very close. If you put something wierd in, you 
Xdeserve everthing you get.
X.PP
XNo score file. It is up to you to keep track of who did how well on what board
.
X.PP
XNot as pretty as the SUN version, especially in color.
END_OF_FILE
if test 3498 -ne `wc -c <'mahjongg.6'`; then
    echo shar: \"'mahjongg.6'\" unpacked with wrong size!
fi
# end of 'mahjongg.6'
fi
if test -f 'mahjongg.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mahjongg.c'\"
else
echo shar: Extracting \"'mahjongg.c'\" \(11012 characters\)
sed "s/^X//" >'mahjongg.c' <<'END_OF_FILE'
X/*
X *	This program contains much of the code from the original
X *	 Sun version of mahjongg, written by Mark Holm, which was
X *	 inspired by the PC version.
X *
X *	This version of Mahjongg was modified/re-written/ported
X *	 for/to the AT&T UNIXPC    by Thomas Tkacik
X *                                 ...rphroy!tetnix!tet.
X *
X *	Any problems or comments should be addressed to Tom Tkacik
X *	 and not Mark Holm, who had nothing to do with this version
X *	 and will not be able to help you.
X *
X */
X
X/*
X *	Copyright 1988, Mark Holm
X *			Exceptions
X *
X *	Permission is given to copy and distribute for non-profit purposes.
X *
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <termio.h>
X#include <sys/signal.h>
X#include <tam.h>
X#include <sys/font.h>
X#include <sys/mouse.h>
X#include "mahjongg.h"
X
Xvoid srand48();
Xlong lrand48();
Xdouble drand48();
Xlong time();
Xlong atol();
Xvoid exit();
X
X/* number used to generate the current board */
Xlong board;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	int c, errflg = 0;
X	extern int optind;
X	extern char *optarg;
X
X	initrandom();
X
X     /* parse arguments --  -n # is the only allowed argument */
X
X	while((c = getopt(argc, argv, "n:")) != EOF) {
X		switch(c) {
X			case 'n':
X				board = atol(optarg);
X				srand48(board);
X				break;
X			default:
X				errflg = 1;
X		}
X	}
X	if(errflg == 1) {
X		fprintf(stderr, "Usage: mahjongg [-n #]\n");
X		exit(1);
X	}
X			
X
X	initwindow();
X
X	initmouse();
X
X	start_game();
X	wcmd(wn, "starting new game");
X
X	dispatch();
X
X	leave();
X}
X
X/*
X * get an initial random number from the process id
X */
X
Xinitrandom()
X{
X	long time();
X
X
X	srand48(getpid() + time((long *)0));
X
X     /* let board be the first number in the random sequence */
X     /*  this will vary more than (getpid+time) does */
X
X	board = (lrand48())>>15;
X	srand48(board);
X}
X
X/*
X * read input and call appropriate routines
X */
X
Xdispatch()
X{
X	int c;
X
X	for(;;) {
X		c = wgetc(wn);
X		switch(c) {
X			case F1:
X				help();
X				break;
X			case F2:
X				start_game();
X				break;
X			case F3:
X				new();
X				break;
X			case F4:
X				undo_proc();
X				break;
X			case F5:
X				quit();
X				return;
X				break;
X			case Mouse:
X				domouse();
X				break;
X			default:
X			     /* ignore all other input */
X				break;
X		}
X	}
X}
X
X/*
X * start a new game
X */
X
Xnew()
X{
X     /* use only the high 16 significant bits of board */
X
X	board = (lrand48())>>15;
X
X	start_game();
X
X	wcmd(wn, "starting new game");
X}
X
X/*
X * play the game with the current board number
X */
X
Xstart_game()
X{
X	srand48(board);
X
X	tile_count = 144;
X
X     /* set the tiles up for randomizing */
X
X	initmahjongg();
X
X	draw_tiles();
X
X	wcmd(wn, "replaying same game");
X	wprompt(wn, "");
X}
X
X/*
X * when the help button is pushed
X */
X
Xhelp()
X{
X	if((selected[0] != -1) && !help_mode) {
X
X	     /* in query mode */
X
X		help_proc();
X	} else {
X
X	     /* not in query mode */
X
X		query_mode = FALSE;
X
X	     /* cancel preview of selected tiles */
X	 
X		preview_tile(selected[0]);
X		preview_tile(selected[1]);
X
X	     /* Clean up selected's variables */
X
X		selected[0] = -1;
X		selected[1] = -1;
X
X	     /* do next help */
X
X		help_proc();
X	}
X}
X
X/*
X * when the quit button is pushed
X */
X
Xquit()
X{
X	wcmd(wn, "quit");
X	wprompt(wn, " ");
X}
X
X/*
X * when one of the mouse buttons is pushed
X */
X
Xdomouse()
X{
X	int i;
X	int x, y, buttons, reason;
X
X	wreadmouse(wn, &x, &y, &buttons, &reason);
X
X     /* see if the mouse is in a free tile */
X
X	for(i = NUMTILES-1; i >= 0; i--) {
X	    	if((x >= tiles[i].x_pos) &&
X		   (x <  tiles[i].x_pos + TILE_X) &&
X		   (y >= tiles[i].y_pos) &&
X		   (y <  tiles[i].y_pos + TILE_Y) &&
X		   (tiles[i].removed == FALSE) &&
X		   (tiles[i].top_free == TRUE) &&
X		   ((tiles[i].left_free == TRUE) ||
X		    (tiles[i].right_free == TRUE))) {
X			break;
X		}
X	}
X
X    /* i will equal -1 if not on a legal tile */
X	play_event_proc(i, buttons);
X}
X
X/*
X * initialize the mahjongg tiles
X */
X
Xinitmahjongg()
X{
X	int i, j;
X
X	selected[0] = -1;
X	selected[1] = -1;
X	undo_count  = -1;
X
X	wcmd(wn,"Building board. Please Wait.");
X
X     /* set up tiles for shuffling */
X
X	for(i = 0, j = 0; i < 34; i+=1, j+=4) {
X		tiles[j].value = i;
X		tiles[j].image = images[i];
X		tiles[j+1].value = i;
X		tiles[j+1].image = images[i];
X		tiles[j+2].value = i;
X		tiles[j+2].image = images[i];
X		tiles[j+3].value = i;
X		tiles[j+3].image = images[i];
X	}
X
X     /* now the one of a kind tiles */
X
X	for(i = 34, j = 136; i < 36; i+=1, j+=4) {
X		tiles[j].value = i;
X		tiles[j].image = images[j-136+34];
X		tiles[j+1].value = i;
X		tiles[j+1].image = images[j-136+34 + 1];
X		tiles[j+2].value = i;
X		tiles[j+2].image = images[j-136+34 + 2];
X		tiles[j+3].value = i;
X		tiles[j+3].image = images[j-136+34 + 3];
X	}
X
X     /* shuffle tiles */
X
X	for(i = NUMTILES-1; i > 0 ; i--) {
X		Tile temp;
X
X	     /* a random integer between 0 and i */
X
X		j = drand48() * (i+1);
X
X	     /* swap tiles */
X
X		temp = tiles[i];
X		tiles[i] = tiles[j];
X		tiles[j] = temp;
X	}
X
X	position_tiles();
X}
X
X/*
X * give each tile a position on the playing board 
X */
X
Xposition_tiles()
X{
X	int i, j;
X	int x_pos, y_pos;
X
X     /* give each tile a position on the board */
X
X     /* ROW 1 */
X	x_pos = X_OFF2;
X	y_pos = Y_OFF1;
X	for(i = 0; i < 12; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[0].left_free = TRUE;
X	tiles[0].left_next[0] = -1;
X	tiles[11].right_free = TRUE;
X	tiles[11].right_next[0] = -1;
X
X     /* ROW 2 */
X	x_pos = X_OFF4;
X	y_pos = Y_OFF2;
X	for(i = 12; i < 20; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[12].left_free = TRUE;
X	tiles[12].left_next[0] = -1;
X	tiles[19].right_free = TRUE;
X	tiles[19].right_next[0] = -1;
X
X     /* ROW 3 */
X	x_pos = X_OFF3;
X	y_pos = Y_OFF3;
X	for(i = 20; i < 30; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[20].left_free = TRUE;
X	tiles[20].left_next[0] = -1;
X	tiles[29].right_free = TRUE;
X	tiles[29].right_next[0] = -1;
X
X     /* ROW 4 1/2  Left side */
X	x_pos = X_OFF1;
X	y_pos = Y_OFF45;
X	init_tile(30, x_pos, y_pos);
X	tiles[30].left_free = TRUE;
X	tiles[30].left_next[0] = -1;
X	tiles[30].right_next[1] = 43;
X
X     /* ROW 4 */
X	x_pos = X_OFF2;
X	y_pos = Y_OFF4;
X	for(i = 31; i < 43; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[42].right_next[0] = 55;
X
X     /* ROW 5 */
X	x_pos = X_OFF2;
X	y_pos = Y_OFF5;
X	for(i = 43; i < 55; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[43].left_next[0] = 30;
X
X     /* ROW 4 1/2  Right side */
X	x_pos = X_OFF14;
X	y_pos = Y_OFF45;
X	for(i = 55; i < 57; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[55].left_next[1] = 42;
X	tiles[56].right_free = TRUE;
X	tiles[56].right_next[0] = -1;
X
X     /* ROW 6 */
X	x_pos = X_OFF3;
X	y_pos = Y_OFF6;
X	for(i = 57; i < 67; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[57].left_free = TRUE;
X	tiles[57].left_next[0] = -1;
X	tiles[66].right_free = TRUE;
X	tiles[66].right_next[0] = -1;
X
X     /* ROW 7 */
X	x_pos = X_OFF4;
X	y_pos = Y_OFF7;
X	for(i = 67; i < 75; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[67].left_free = TRUE;
X	tiles[67].left_next[0] = -1;
X	tiles[74].right_free = TRUE;
X	tiles[74].right_next[0] = -1;
X
X     /* ROW 8 */
X	x_pos = X_OFF2;
X	y_pos = Y_OFF8;
X	for(i = 75; i < 87; i++) {
X		init_tile(i, x_pos, y_pos);
X		x_pos += TILE_X;
X	}
X	tiles[75].left_free = TRUE;
X	tiles[75].left_next[0] = -1;
X	tiles[86].right_free = TRUE;
X	tiles[86].right_next[0] = -1;
X
X     /* LEVEL 2 */
X	x_pos = X_OFF5 + X_OFFL2;
X	y_pos = Y_OFF2 + Y_OFFL2;
X	for(i = 87; i < 123; i+=6) {
X		for(j = 0; j < 6; j++) {
X			init_tile(i+j, x_pos, y_pos);
X			x_pos += TILE_X;
X		}
X		x_pos = X_OFF5 + X_OFFL2;
X		y_pos += TILE_Y;
X		tiles[i].left_free = TRUE;
X		tiles[i].left_next[0] = -1;
X		tiles[i+5].right_free = TRUE;
X		tiles[i+5].right_next[0] = -1;
X	}
X
X     /* LEVEL 3 */
X	x_pos = X_OFF6 + X_OFFL3;
X	y_pos = Y_OFF3 + Y_OFFL3;
X	for(i = 123; i < 139; i+=4) {
X		for(j = 0; j < 4; j++) {
X			init_tile(i+j, x_pos, y_pos);
X			x_pos += TILE_X;
X		}
X		x_pos = X_OFF6 + X_OFFL3;
X		y_pos += TILE_Y;
X		tiles[i].left_free = TRUE;
X		tiles[i].left_next[0] = -1;
X		tiles[i+3].right_free = TRUE;
X		tiles[i+3].right_next[0] = -1;
X	}
X
X     /* LEVEL 4 */
X	x_pos = X_OFF7 + X_OFFL4;
X	y_pos = Y_OFF4 + Y_OFFL4;
X	for(i = 139; i < 143; i+=2) {
X		for(j = 0; j < 2; j++) {
X			init_tile(i+j, x_pos, y_pos);
X			x_pos += TILE_X;
X		}
X		x_pos = X_OFF7 + X_OFFL4;
X		y_pos += TILE_Y;
X		tiles[i].left_free = TRUE;
X		tiles[i].left_next[0] = -1;
X		tiles[i+1].right_free = TRUE;
X		tiles[i+1].right_next[0] = -1;
X	}
X	tiles[139].top_free = FALSE;
X	tiles[140].top_free = FALSE;
X	tiles[141].top_free = FALSE;
X	tiles[142].top_free = FALSE;
X
X     /* LEVEL 5 */
X	x_pos = X_OFF75 + X_OFFL5;
X	y_pos = Y_OFF45 + Y_OFFL5;
X	init_tile(143, x_pos, y_pos);
X	tiles[143].left_free = TRUE;
X	tiles[143].left_next[0] = -1;
X	tiles[143].right_free = TRUE;
X	tiles[143].right_next[0] = -1;
X	tiles[143].covered[0] = 139;
X	tiles[143].covered[1] = 140;
X	tiles[143].covered[2] = 141;
X	tiles[143].covered[3] = 142;
X
X     /* this code copied verbatim from Mark Holm's Mahjongg */
X     /* set top_free flags  and covered pointers */
X
X	for(i = 87, j = 13; i < 143; i++, j++) {
X		tiles[i].covered[0] = j;
X		tiles[j].top_free = FALSE;
X		switch(j) {
X			case 97:
X			case 103:
X			case 109:
X			case 129:
X				 j += 2;
X				 break;
X			case 18:
X			case 64:
X				 j += 3;
X				 break;
X			case 27:
X			case 39:
X				 j += 6;
X				 break;
X			case 51:
X				 j += 7;
X				 break;
X			case 73:
X				 j += 20;
X				 break;
X			case 115:
X				 j += 12;
X				 break;
X		}
X	}
X}
X
X/*
X * give tile i its default initial values
X */
X
Xinit_tile(i, x_pos, y_pos)
Xint i;
Xint x_pos, y_pos;
X{
X	tiles[i].x_pos = x_pos;
X	tiles[i].y_pos = y_pos;
X	tiles[i].left_free = FALSE;
X	tiles[i].right_free = FALSE;
X	tiles[i].top_free = TRUE;
X	tiles[i].left_next[0] = i - 1;
X	tiles[i].left_next[1] = -1;
X	tiles[i].right_next[0] = i + 1;
X	tiles[i].right_next[1] = -1;
X	tiles[i].covered[0] = -1;
X	tiles[i].covered[1] = -1;
X	tiles[i].covered[2] = -1;
X	tiles[i].covered[3] = -1;
X	tiles[i].removed = FALSE;
X}
X
X/*
X * draw the tiles on the playing field
X */
X
Xdraw_tiles()
X{
X	int i = 0;
X	wgoto(wn, 1, 23);
X	wprintf(wn, "Tiles Remaining: %3d", tile_count);
X	wgoto(wn, 1, 53);
X	wprintf(wn, "Board Number: %5ld", board);
X
X     /* clear the playing field */
X
X	wrastop(wn, 0, 0, 0, 0, 0, 0,
X		X_OFF1, Y_OFF1, 14*TILE_X+TILE_W, 7*TILE_Y+TILE_H,
X		SRCPAT, DSTSRC, patblack);
X
X     /* place tiles */
X
X	for(i = 0; i < NUMTILES; i++) {
X		if(tiles[i].removed == TRUE)
X			continue;
X		
X		if((i >= 139) || (tiles[i].top_free == TRUE)) {
X
X		     /* show the tile */
X
X			wrastop(wn, tiles[i].image, 6, 0, 0, 0, 0,
X				tiles[i].x_pos, tiles[i].y_pos, 
X				TILE_W, TILE_H, SRCSRC, DSTSRC, 0); 
X		} else {
X
X		     /* draw a blank tile -- do not show hidden tiles */
X			
X			wrastop(wn, blank, 6, 0, 0, 0, 0,
X				tiles[i].x_pos, tiles[i].y_pos, 
X				TILE_W, TILE_H, SRCSRC, DSTSRC, 0);
X		}
X	}
X}
X
X/*
X * highlight a tile -- if already highlighted, turn it off
X */
X
Xpreview_tile(i)
Xint i;
X{
X	wrastop(wn, 0, 0, 0, 0, 0, 0,
X		tiles[i].x_pos+1, tiles[i].y_pos+1,
X		TILE_X-1, TILE_Y-1, SRCPAT, DSTXOR, patwhite);
X}
X
X/*
X * beep at the user
X */
X
Xwindow_bell()
X{
X	wprintf(wn, "\007");
X}
X
END_OF_FILE
if test 11012 -ne `wc -c <'mahjongg.c'`; then
    echo shar: \"'mahjongg.c'\" unpacked with wrong size!
fi
# end of 'mahjongg.c'
fi
if test -f 'mahjongg.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mahjongg.h'\"
else
echo shar: Extracting \"'mahjongg.h'\" \(2971 characters\)
sed "s/^X//" >'mahjongg.h' <<'END_OF_FILE'
X/*
X *	This program contains much of the code from the original
X *	 Sun version of mahjongg, written by Mark Holm, which was
X *	 inspired by the PC version.
X *
X *	This version of Mahjongg was modified/re-written/ported
X *	 for/to the AT&T UNIXPC    by Thomas Tkacik
X *                                 ...rphroy!tetnix!tet.
X *
X *	Any problems or comments should be addressed to Tom Tkacik
X *	 and not Mark Holm, who had nothing to do with this version
X *	 and will not be able to help you.
X *
X */
X
X/*
X *	Copyright 1988, Mark Holm
X *			Exceptions
X *
X *	Permission is given to copy and distribute for non-profit purposes.
X *
X */
X
X#define  ROWS       23
X#define  COLS       75
X#define  WINDOW_X   2
X#define  WINDOW_Y   2
X
X/* TILE size and offsets */
X#define  TILE_W  48
X#define  TILE_H  32
X#define  TILE_X  42
X#define  TILE_Y  28
X
X/* TILE offset on playing board */
X#define  X_OFF1  20
X#define  X_OFF2  (X_OFF1 + TILE_X)
X#define  X_OFF3  (X_OFF2 + TILE_X)
X#define  X_OFF4  (X_OFF3 + TILE_X)
X#define  X_OFF5  (X_OFF4 + TILE_X)
X#define  X_OFF6  (X_OFF5 + TILE_X)
X#define  X_OFF7  (X_OFF6 + TILE_X)
X#define  X_OFF75 (X_OFF7 + (TILE_X/2))
X#define  X_OFF8  (X_OFF7 + TILE_X)
X#define  X_OFF9  (X_OFF8 + TILE_X)
X#define  X_OFF10  (X_OFF9 + TILE_X)
X#define  X_OFF11  (X_OFF10 + TILE_X)
X#define  X_OFF12  (X_OFF11 + TILE_X)
X#define  X_OFF13  (X_OFF12 + TILE_X)
X#define  X_OFF14  (X_OFF13 + TILE_X)
X#define  X_OFF15  (X_OFF14 + TILE_X)
X
X#define  Y_OFF1  35
X#define  Y_OFF2  (Y_OFF1 + TILE_Y)
X#define  Y_OFF3  (Y_OFF2 + TILE_Y)
X#define  Y_OFF4  (Y_OFF3 + TILE_Y)
X#define  Y_OFF45 (Y_OFF4 + (TILE_Y/2))
X#define  Y_OFF5  (Y_OFF4 + TILE_Y)
X#define  Y_OFF6  (Y_OFF5 + TILE_Y)
X#define  Y_OFF7  (Y_OFF6 + TILE_Y)
X#define  Y_OFF8  (Y_OFF7 + TILE_Y)
X
X/* offsets due to being on a different level */
X#define  X_OFFL2  (TILE_X - TILE_W)
X#define  X_OFFL3  ((TILE_X - TILE_W) * 2)
X#define  X_OFFL4  ((TILE_X - TILE_W) * 3)
X#define  X_OFFL5  ((TILE_X - TILE_W) * 4)
X
X#define  Y_OFFL2  (TILE_Y - TILE_H)
X#define  Y_OFFL3  ((TILE_Y - TILE_H) * 2)
X#define  Y_OFFL4  ((TILE_Y - TILE_H) * 3)
X#define  Y_OFFL5  ((TILE_Y - TILE_H) * 4)
X
X/* more TILE data */
X#define  IMAGESIZE 96
X#define  NUMIMAGES 42
X#define  NUMTILES  144
X
X#define TRUE  1
X#define FALSE 0
X
Xtypedef char boolean;
X
X/* define a tile */
Xtypedef struct {
X	unsigned short *image;
X	int value;
X	int x_pos;
X	int y_pos;
X	boolean left_free;
X	boolean right_free;
X	boolean top_free;
X	int left_next[2];
X	int right_next[2];
X	int covered[4];
X	boolean removed;
X} Tile;
X
X/* window discriptor */
Xextern int wn;
X
X/* tile image definitions */
Xextern unsigned short images[42][96];
X
X/* blank tile definition */
Xextern unsigned short blank[96];
X
X/* the 144 playing tiles */
Xextern Tile tiles[NUMTILES];
X
X/* built-in pattern used for wrastop() */
Xextern unsigned short patwhite[];
Xextern unsigned short patblack[];
X
Xextern int	tile_count;
Xextern int	selected[2];
Xextern int	undo_tiles[144][2];
Xextern int	undo_count;
Xextern int	help_mode;
Xextern int	query_mode;
END_OF_FILE
if test 2971 -ne `wc -c <'mahjongg.h'`; then
    echo shar: \"'mahjongg.h'\" unpacked with wrong size!
fi
# end of 'mahjongg.h'
fi
if test ! -d 'tiles' ; then
    echo shar: Creating directory \"'tiles'\"
    mkdir 'tiles'
fi
if test -f 'tiles.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles.c'\"
else
echo shar: Extracting \"'tiles.c'\" \(2471 characters\)
sed "s/^X//" >'tiles.c' <<'END_OF_FILE'
X/*
X *	This program contains much of the code from the original
X *	 Sun version of mahjongg, written by Mark Holm, which was
X *	 inspired by the PC version.
X *
X *	This version of Mahjongg was modified/re-written/ported
X *	 for/to the AT&T UNIXPC    by Thomas Tkacik
X *                                 ...rphroy!tetnix!tet.
X *
X *	Any problems or comments should be addressed to Tom Tkacik
X *	 and not Mark Holm, who had nothing to do with this version
X *	 and will not be able to help you.
X *
X *	The icons for this version were also done by Tom Tkacik,
X *	 and though they are an attempt to look like those developed
X *	 by Dorothy Robinson, they cannot compare with the originals.
X *
X *	The following acknowledgements are for those, superior, tiles
X *	 and not the copies that you see here.
X */
X
X/*
X *	Copyright 1988, Mark Holm
X *			Exceptions
X *
X *	Acknowledgments to Dorothy Robinson for her artistic
X *	 abilities in drawing the icons and to Jim Batch for
X *	 technical support and graphical concepts (which I abandoned in favor
X *       of the easy way out).
X *
X *	Permission is given to copy and distribute for non-profit purposes.
X *
X */
X
X#include "mahjongg.h"
X
X/* the 144 tiles */
XTile tiles[NUMTILES];
X
Xunsigned short blank[96] = {
X#include "tiles/blank"
X};
X
X/* the 42 rastor images */
Xunsigned short images[42][96] = {
X	  {
X#include "tiles/bam1"
X	},{
X#include "tiles/bam2"
X	},{
X#include "tiles/bam3"
X	},{
X#include "tiles/bam4"
X	},{
X#include "tiles/bam5"
X	},{
X#include "tiles/bam6"
X	},{
X#include "tiles/bam7"
X	},{
X#include "tiles/bam8"
X	},{
X#include "tiles/bam9"
X	},{
X#include "tiles/cha1"
X	},{
X#include "tiles/cha2"
X	},{
X#include "tiles/cha3"
X	},{
X#include "tiles/cha4"
X	},{
X#include "tiles/cha5"
X	},{
X#include "tiles/cha6"
X	},{
X#include "tiles/cha7"
X	},{
X#include "tiles/cha8"
X	},{
X#include "tiles/cha9"
X	},{
X#include "tiles/dot1"
X	},{
X#include "tiles/dot2"
X	},{
X#include "tiles/dot3"
X	},{
X#include "tiles/dot4"
X	},{
X#include "tiles/dot5"
X	},{
X#include "tiles/dot6"
X	},{
X#include "tiles/dot7"
X	},{
X#include "tiles/dot8"
X	},{
X#include "tiles/dot9"
X	},{
X#include "tiles/B"
X	},{
X#include "tiles/C"
X	},{
X#include "tiles/F"
X	},{
X#include "tiles/north"
X	},{
X#include "tiles/east"
X	},{
X#include "tiles/south"
X	},{
X#include "tiles/west"
X	},{
X#include "tiles/plum"
X	},{
X#include "tiles/orchid"
X	},{
X#include "tiles/bamboo"
X	},{
X#include "tiles/mum"
X	},{
X#include "tiles/autumn"
X	},{
X#include "tiles/summer"
X	},{
X#include "tiles/spring"
X	},{
X#include "tiles/winter"
X	}
X};
END_OF_FILE
if test 2471 -ne `wc -c <'tiles.c'`; then
    echo shar: \"'tiles.c'\" unpacked with wrong size!
fi
# end of 'tiles.c'
fi
if test -f 'tiles/autumn' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/autumn'\"
else
echo shar: Extracting \"'tiles/autumn'\" \(976 characters\)
sed "s/^X//" >'tiles/autumn' <<'END_OF_FILE'
X/*  array autumn contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x0000,	0x2c00,	
X	0x0001,	0x0000,	0xd400,	
X	0xe001,	0x001f,	0xac00,	
X	0x1e1d,	0x0008,	0x5400,	
X	0x01e1,	0x0fc4,	0xac00,	
X	0x0e41,	0x3038,	0x5400,	
X	0x7081,	0xc000,	0xac00,	
X	0x0081,	0xe007,	0x5401,	
X	0x0081,	0x1038,	0xac00,	
X	0x0881,	0xe380,	0x5400,	
X	0x1441,	0x0c00,	0xac03,	
X	0x1441,	0x6003,	0x5402,	
X	0x35c1,	0x8187,	0xac05,	
X	0x4601,	0x7245,	0x5407,	
X	0x8401,	0x9c49,	0xac0f,	
X	0x8001,	0x0851,	0x5418,	
X	0x0001,	0x0060,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x4441,	0x145f,	0x5445,	
X	0x44a1,	0xb444,	0xac4d,	
X	0x4511,	0x5444,	0x5455,	
X	0x45f1,	0x5444,	0xac65,	
X	0x4511,	0x1444,	0x5445,	
X	0x3911,	0x1384,	0xac45,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/autumn'`; then
    echo shar: \"'tiles/autumn'\" unpacked with wrong size!
fi
# end of 'tiles/autumn'
fi
if test -f 'tiles/bam5' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/bam5'\"
else
echo shar: Extracting \"'tiles/bam5'\" \(974 characters\)
sed "s/^X//" >'tiles/bam5' <<'END_OF_FILE'
X/*  array bam5 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x00f8,	0x2c00,	
X	0x0001,	0x0008,	0xd400,	
X	0x7c01,	0xf008,	0xac01,	
X	0x2801,	0xa078,	0x5400,	
X	0x2801,	0xa080,	0xac00,	
X	0x2801,	0xa080,	0x5400,	
X	0x7c01,	0xf078,	0xac01,	
X	0x2801,	0xa000,	0x5400,	
X	0x2801,	0xa0f8,	0xac00,	
X	0x2801,	0xa050,	0x5400,	
X	0x7c01,	0xf050,	0xac01,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x00f8,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x7c01,	0xf050,	0xac01,	
X	0x2801,	0xa050,	0x5400,	
X	0x2801,	0xa0f8,	0xac00,	
X	0x2801,	0xa000,	0x5400,	
X	0x7c01,	0xf000,	0xac01,	
X	0x2801,	0xa000,	0x5400,	
X	0x2801,	0xa000,	0xac00,	
X	0x2801,	0xa000,	0x5400,	
X	0x7c01,	0xf000,	0xac01,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 974 -ne `wc -c <'tiles/bam5'`; then
    echo shar: \"'tiles/bam5'\" unpacked with wrong size!
fi
# end of 'tiles/bam5'
fi
if test -f 'tiles/bam6' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/bam6'\"
else
echo shar: Extracting \"'tiles/bam6'\" \(974 characters\)
sed "s/^X//" >'tiles/bam6' <<'END_OF_FILE'
X/*  array bam6 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0071,	0x0000,	0x2c00,	
X	0x0089,	0x0000,	0xd400,	
X	0x7c09,	0xc1f0,	0xac07,	
X	0x2879,	0x80a0,	0x5402,	
X	0x2889,	0x80a0,	0xac02,	
X	0x2889,	0x80a0,	0x5402,	
X	0x7c71,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 974 -ne `wc -c <'tiles/bam6'`; then
    echo shar: \"'tiles/bam6'\" unpacked with wrong size!
fi
# end of 'tiles/bam6'
fi
if test -f 'tiles/bamboo' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/bamboo'\"
else
echo shar: Extracting \"'tiles/bamboo'\" \(976 characters\)
sed "s/^X//" >'tiles/bamboo' <<'END_OF_FILE'
X/*  array bamboo contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x07e0,	0x2c00,	
X	0x0c01,	0x1ffc,	0xd400,	
X	0x1e01,	0x3ffe,	0xac00,	
X	0x7e01,	0x7ffe,	0x5400,	
X	0x7f01,	0xf3ff,	0xac00,	
X	0x7f81,	0xe3ff,	0x5401,	
X	0xbde1,	0x03bf,	0xac00,	
X	0x9cf1,	0x031f,	0x55f0,	
X	0xce01,	0x008b,	0xacfe,	
X	0xe601,	0x0391,	0x543f,	
X	0x0001,	0x8250,	0xac1f,	
X	0x0001,	0x8420,	0x54fe,	
X	0x8839,	0x8728,	0xadff,	
X	0x9449,	0xc9cd,	0x55fe,	
X	0xa279,	0x484a,	0xadba,	
X	0xbe89,	0xc84a,	0x553b,	
X	0xa289,	0x5e88,	0xac31,	
X	0xa279,	0x7188,	0x5421,	
X	0x0001,	0x2080,	0xac01,	
X	0x1c39,	0xe087,	0x5400,	
X	0xa249,	0x4088,	0xac00,	
X	0xa279,	0x5c88,	0x5400,	
X	0xa289,	0x6388,	0xac00,	
X	0xa289,	0x0008,	0x5400,	
X	0x1c79,	0x0007,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/bamboo'`; then
    echo shar: \"'tiles/bamboo'\" unpacked with wrong size!
fi
# end of 'tiles/bamboo'
fi
if test -f 'tiles/blank' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/blank'\"
else
echo shar: Extracting \"'tiles/blank'\" \(975 characters\)
sed "s/^X//" >'tiles/blank' <<'END_OF_FILE'
X/*  array blank contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x0000,	0x2c00,	
X	0x0001,	0x0000,	0xd400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0020,	0x5400,	
X	0x0001,	0x0070,	0xac00,	
X	0x0001,	0x0020,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 975 -ne `wc -c <'tiles/blank'`; then
    echo shar: \"'tiles/blank'\" unpacked with wrong size!
fi
# end of 'tiles/blank'
fi
if test -f 'tiles/north' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/north'\"
else
echo shar: Extracting \"'tiles/north'\" \(975 characters\)
sed "s/^X//" >'tiles/north' <<'END_OF_FILE'
X/*  array north contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0319,	0x0000,	0x2c00,	
X	0x0339,	0x0000,	0xd400,	
X	0x0379,	0x0000,	0xac00,	
X	0x03d9,	0x1000,	0x5400,	
X	0x0399,	0x1802,	0xac00,	
X	0x0319,	0x3c07,	0x5400,	
X	0xc319,	0x7f0f,	0xac00,	
X	0x0001,	0x3c03,	0x5400,	
X	0x0001,	0x1803,	0xac00,	
X	0x1f01,	0x1803,	0x5400,	
X	0x3e01,	0x1803,	0xac18,	
X	0x3e01,	0x1803,	0x541c,	
X	0x0001,	0x1803,	0xac1e,	
X	0x0001,	0xf803,	0x540f,	
X	0x0001,	0xf8f3,	0xac03,	
X	0x8701,	0x181f,	0x5400,	
X	0xff01,	0x1803,	0xac00,	
X	0x3e01,	0x1803,	0x5400,	
X	0x0001,	0x3803,	0xac1c,	
X	0x8001,	0xf001,	0x541f,	
X	0x8001,	0xe001,	0xac0f,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 975 -ne `wc -c <'tiles/north'`; then
    echo shar: \"'tiles/north'\" unpacked with wrong size!
fi
# end of 'tiles/north'
fi
if test -f 'tiles/orchid' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/orchid'\"
else
echo shar: Extracting \"'tiles/orchid'\" \(976 characters\)
sed "s/^X//" >'tiles/orchid' <<'END_OF_FILE'
X/*  array orchid contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x7301,	0xba4c,	0x2c03,	
X	0x9481,	0x9252,	0xd404,	
X	0x7481,	0x93c2,	0xac04,	
X	0x5481,	0x9252,	0x5404,	
X	0x9301,	0xba4c,	0xac03,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x001c,	0xac06,	
X	0x7021,	0x0022,	0x5403,	
X	0x8861,	0x0022,	0xac01,	
X	0x1041,	0x80f3,	0x543d,	
X	0xe0c1,	0xc10e,	0xac07,	
X	0x1181,	0xe21b,	0x5400,	
X	0x8b21,	0xb9f1,	0xac30,	
X	0x7661,	0xcc11,	0x541c,	
X	0x0d81,	0xc613,	0xac06,	
X	0x1319,	0x438d,	0x54e2,	
X	0xa461,	0x60c1,	0xac38,	
X	0xc8c1,	0x2060,	0x540c,	
X	0xb301,	0x3031,	0xac06,	
X	0x6601,	0x1813,	0x5403,	
X	0x5801,	0xce12,	0xac01,	
X	0x9001,	0x730c,	0x5400,	
X	0x6001,	0x1900,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/orchid'`; then
    echo shar: \"'tiles/orchid'\" unpacked with wrong size!
fi
# end of 'tiles/orchid'
fi
if test -f 'tiles/south' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/south'\"
else
echo shar: Extracting \"'tiles/south'\" \(975 characters\)
sed "s/^X//" >'tiles/south' <<'END_OF_FILE'
X/*  array south contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x00f1,	0x0030,	0x2c00,	
X	0x0199,	0x00e0,	0xd400,	
X	0x0019,	0x03e0,	0xac00,	
X	0x00f1,	0x01c0,	0x5400,	
X	0x0181,	0x00c0,	0xac00,	
X	0x0199,	0x00c0,	0x5400,	
X	0x00f1,	0x3cc0,	0xac00,	
X	0x0001,	0x07f8,	0x5400,	
X	0x0001,	0x00ce,	0xac00,	
X	0x0001,	0x00c0,	0x5400,	
X	0xc001,	0xc0c0,	0xac00,	
X	0x8001,	0xffe3,	0x5400,	
X	0x0001,	0xe0fe,	0xac03,	
X	0x8001,	0xa01f,	0x5407,	
X	0xe001,	0x1e01,	0xac0e,	
X	0x0001,	0x07f0,	0x541c,	
X	0x0001,	0x60dc,	0xac38,	
X	0x0001,	0x3cc0,	0x541c,	
X	0x1801,	0x07c0,	0xac0e,	
X	0x7001,	0xb1fc,	0x5407,	
X	0xe001,	0xe0cf,	0xac01,	
X	0xc001,	0x00c1,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 975 -ne `wc -c <'tiles/south'`; then
    echo shar: \"'tiles/south'\" unpacked with wrong size!
fi
# end of 'tiles/south'
fi
if test -f 'tiles/spring' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/spring'\"
else
echo shar: Extracting \"'tiles/spring'\" \(976 characters\)
sed "s/^X//" >'tiles/spring' <<'END_OF_FILE'
X/*  array spring contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x006e,	0x2c10,	
X	0x0001,	0x0033,	0xd418,	
X	0x0001,	0xc011,	0xac0d,	
X	0x0001,	0x6009,	0x5406,	
X	0x0001,	0x200e,	0xac01,	
X	0x3801,	0xe004,	0x5400,	
X	0xcc01,	0x3782,	0xacdc,	
X	0x8401,	0x1841,	0x5466,	
X	0x4801,	0x0640,	0xac32,	
X	0x6001,	0x0180,	0x541e,	
X	0x1bc1,	0x1cef,	0xac07,	
X	0x8c61,	0xe238,	0x5401,	
X	0x8641,	0x710e,	0xac00,	
X	0x0301,	0x0d01,	0x5400,	
X	0xc0c1,	0x0300,	0xac00,	
X	0x3861,	0x00c0,	0x5400,	
X	0x0c01,	0x003c,	0xac00,	
X	0x8001,	0x0007,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x79e1,	0x173e,	0x5439,	
X	0x8a11,	0x3242,	0xac45,	
X	0x8861,	0x5242,	0x5405,	
X	0x7981,	0x923e,	0xac65,	
X	0x0a11,	0x1232,	0x5445,	
X	0x09e1,	0x1762,	0xac39,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/spring'`; then
    echo shar: \"'tiles/spring'\" unpacked with wrong size!
fi
# end of 'tiles/spring'
fi
if test -f 'tiles/summer' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/summer'\"
else
echo shar: Extracting \"'tiles/summer'\" \(976 characters\)
sed "s/^X//" >'tiles/summer' <<'END_OF_FILE'
X/*  array summer contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0xe001,	0x001f,	0x1c00,	
X	0xc001,	0xf870,	0x2c01,	
X	0x1e01,	0x8cc3,	0xd400,	
X	0x6181,	0x8286,	0xac00,	
X	0xe0c1,	0x62fe,	0x5418,	
X	0x9e41,	0x9383,	0xac1f,	
X	0xf3e1,	0xc600,	0x5411,	
X	0x6061,	0x7c00,	0xac18,	
X	0x3f01,	0x0800,	0x540c,	
X	0x21c1,	0x0800,	0xac07,	
X	0x3c61,	0xf800,	0x5401,	
X	0x6631,	0x1c00,	0xac00,	
X	0xf311,	0xe600,	0x5401,	
X	0x9991,	0x0783,	0xac07,	
X	0x88d1,	0x0cff,	0x541c,	
X	0x4871,	0x38c4,	0xac07,	
X	0x9861,	0xe38c,	0x5401,	
X	0xb001,	0x0639,	0xac00,	
X	0xe001,	0x1fe3,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x44f1,	0xf451,	0x547d,	
X	0x4509,	0x16db,	0xac84,	
X	0x4431,	0x7555,	0x5484,	
X	0x44c1,	0x1555,	0xac7c,	
X	0x4509,	0x1451,	0x5464,	
X	0x38f1,	0xf451,	0xacc5,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/summer'`; then
    echo shar: \"'tiles/summer'\" unpacked with wrong size!
fi
# end of 'tiles/summer'
fi
if test -f 'tiles/winter' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'tiles/winter'\"
else
echo shar: Extracting \"'tiles/winter'\" \(976 characters\)
sed "s/^X//" >'tiles/winter' <<'END_OF_FILE'
X/*  array winter contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0070,	0x1c00,	
X	0x0001,	0x0070,	0x2c00,	
X	0x1c01,	0xc421,	0xd401,	
X	0x1c01,	0xc2fa,	0xac01,	
X	0x3001,	0x6525,	0x5400,	
X	0xc001,	0x19fc,	0xac00,	
X	0x2c01,	0xa623,	0x5401,	
X	0x7001,	0x7525,	0xac00,	
X	0x9001,	0x48f8,	0x5400,	
X	0xffc1,	0xffff,	0xac1f,	
X	0x91c1,	0x48f8,	0x541c,	
X	0x7001,	0x7525,	0xac00,	
X	0x2c01,	0xa623,	0x5401,	
X	0xc001,	0x19fc,	0xac00,	
X	0x3001,	0x6525,	0x5400,	
X	0x1c01,	0xc2fa,	0xac01,	
X	0x1c01,	0xc421,	0x5401,	
X	0x0001,	0x0070,	0xac00,	
X	0x0001,	0x0070,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x7d11,	0xf7d1,	0x543d,	
X	0x1111,	0x1113,	0xac44,	
X	0x1151,	0x7115,	0x5444,	
X	0x1151,	0x1119,	0xac3c,	
X	0x11b1,	0x1111,	0x5424,	
X	0x7d11,	0xf111,	0xac45,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
END_OF_FILE
if test 976 -ne `wc -c <'tiles/winter'`; then
    echo shar: \"'tiles/winter'\" unpacked with wrong size!
fi
# end of 'tiles/winter'
fi
if test -f 'window.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'window.c'\"
else
echo shar: Extracting \"'window.c'\" \(3934 characters\)
sed "s/^X//" >'window.c' <<'END_OF_FILE'
X/*
X *	This code was written by Thomas Tkacik and contains
X *	 absolutely no code from Mark Holm's Mahjongg program.
X *
X *	Do with it as you wish.
X */
X
X#include <stdio.h>
X#include <fcntl.h>
X#include <termio.h>
X#include <sys/signal.h>
X#include <tam.h>
X#include <sys/font.h>
X#include "mahjongg.h"
X
X#define  SIDEBORDER 6
X#define  TOPBORDER  4
X
Xint (*signal())();
X
X/* window discriptor */
Xint wn;
X
X/* window width and height */
Xint win_width, win_height;
X
Xstruct icon stick = {
X	0,
X	{ 16, 11, -8, -5, 0, 0, 0 },
X	{ 0xfc00, 0x8200, 0x9980, 0x8040, 0x4120, 0x37d8,
X	  0x0904, 0x0402, 0x0332, 0x0082, 0x007e }
X};
X
Xstruct umdata mouse = { MSDOWN, SIDEBORDER, TOPBORDER, 0, 0, &stick };
X
Xint reborder(), leave();
X
X/*  window routines */
X
X/*
X * initialize window and draw initial borders
X */
X
Xinitwindow()
X{
X     /* start with a clean window */
X     /*  this needs to be done because winit() uses the */
X     /*  current window first, so we open a new one     */
X	(void)close(0);
X	(void)close(1);
X	(void)close(2);
X	wn = open("/dev/window", O_RDWR );
X	(void)dup(wn);
X	(void)dup(wn);
X
X     /* initialize the tam routines */
X	winit();
X
X     /* can only be run on the unixpc screen */
X	if(iswind()==0) {
X		(void)fprintf(stderr, "must use bitmapped screen\n");
X		wexit(1);
X	}
X
X     /* open the mahjongg window */
X	if((wn = wcreate(WINDOW_Y, WINDOW_X, ROWS, COLS, NBORDER)) == -1) {
X		(void)fprintf(stderr, "could not open window  wn = %d\n",wn);
X		wexit(1);
X	}
X
X     /* draw the initial border around the playing region */
X	initborder();
X
X     /* draw line separating playing area and text area */
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 0, 28,
X		win_width, 1, SRCPAT, DSTSRC, patwhite);
X
X     /* set up function keys */
X	wslk(wn, 0, "   HELP    SAME      NEW         UNDO     QUIT",
X		    "           BOARD    BOARD");
X	wuser(wn, "mahjongg");
X
X     /* allow mouse inputs in 8 bit mode */
X	keypad(0,1);
X
X     /* turn off the cursor */
X	wputs(wn,"\033[=1C");
X	wgoto(wn, 1, 4);
X	wputs(wn, "MAHJONGG");
X
X     /* catch the signals */
X	(void)signal(SIGHUP,  leave);
X	(void)signal(SIGINT,  leave);
X	(void)signal(SIGQUIT, leave);
X	(void)signal(SIGWIND, reborder);
X}
X
X/*
X * draw the initial border around the playing window
X */
X
Xinitborder()
X{
X	struct uwdata win;
X
X     /* determine the initial window size in pixels */
X	(void)ioctl(wn, WIOCGETD, &win);
X
X     /* save the size so that everyone can use it */
X	win_width  = win.uw_width;
X	win_height = win.uw_height;
X
X     /* draw the border in the screen image */ 
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 0, 0,
X		win_width, TOPBORDER, SRCPAT, DSTSRC, patwhite);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 0, win_height-TOPBORDER,
X		win_width, TOPBORDER, SRCPAT, DSTSRC, patwhite);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 0, 0,
X		SIDEBORDER, win_height, SRCPAT, DSTSRC, patwhite);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, win_width-SIDEBORDER, 0,
X		SIDEBORDER, win_height, SRCPAT, DSTSRC, patwhite);
X}
X
X/*
X * catch SIGWIND -- draw border as forground or background
X */
X
Xreborder()
X{
X	unsigned short *pat;
X	struct uwdata win;
X
X     /* determine if the window is on top */
X	(void)ioctl(wn, WIOCGETD, &win);
X
X     /* if current window then add border interior  else remove it */
X	pat = (win.uw_uflags & KBDWIN) ? patwhite : patblack;
X
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 1, 1,
X		win_width-2, TOPBORDER-2, SRCPAT, DSTSRC, pat);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 1, win_height-TOPBORDER+1,
X		win_width-2, TOPBORDER-2, SRCPAT, DSTSRC, pat);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, 1, 1,
X		SIDEBORDER-2, win_height-2, SRCPAT, DSTSRC, pat);
X	wrastop(wn, 0, 0, 0, 0, 0, 0, win_width-SIDEBORDER+1, 1,
X		SIDEBORDER-2, win_height-2, SRCPAT, DSTSRC, pat);
X
X     /* reset signal trap */
X	(void) signal(SIGWIND, reborder);
X}
X
X/*
X * initialize the mouse to send mouse reports
X */
X
Xinitmouse()
X{
X	mouse.um_w = win_width-SIDEBORDER-1;
X	mouse.um_h = win_height-TOPBORDER-1;
X
X	wsetmouse(wn, &mouse);
X}
X
X/*
X * SIGINT, SIGQUIT -- close windows and cleanup
X */
X
Xleave()
X{
X	wdelete(wn);
X	wexit(0);
X}
END_OF_FILE
if test 3934 -ne `wc -c <'window.c'`; then
    echo shar: \"'window.c'\" unpacked with wrong size!
fi
# end of 'window.c'
fi
echo shar: End of archive 1 \(of 2\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked both 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