[comp.sources.3b1] v01i015: Mahjongg for the 3b1, Part01/02

tkacik@kyzyl.mi.org (Tom Tkacik) (03/18/91)

Submitted-by: tkacik@kyzyl.mi.org (Tom Tkacik)
Posting-number: Volume 1, Issue 15
Archive-name: mahjongg/part01


This version of mahjongg is being posted to be properly archived.
The only real change is that it now displays inverse video.

This is a version of the Mahjongg game ported to the UNIXPC.
It came from the version by Mark Holm for the Sun, and
has been modified/re-written/ported for/to the UNIXPC by Tom Tkacik.

The manual is in mahjongg.6.  It has been my attempt to recreate
the Sun version as faithfully as possible, so if you have played that
version, you should not have to read the manual.

If you have any problems with this version do not complain to Mark.
Please address all questions to me (tkacik@kyzyl.mi.org).

I do not like the borders on the standard windows, so I made my own.
The only problem is not having the move and resize icons.
If anyone can figure out how they might be implemented, I would
like to hear about it.

All of the code, except for window.c, retains the copyrights of Mark Holm.
You may use window.c any way you see fit.

Type make, and have fun.

Tom Tkacik
tkacik@kyzyl.mi.org

#! /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:  MANIFEST Makefile README bamboo.c dot.c event.c mahjongg.6
#   mahjongg.h tiles.c window.c
# Wrapped by dave@galaxia on Wed Mar 13 21:44:26 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(499 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                   1	
X Makefile                   1	
X README                     1	
X bamboo.c                   1	
X character.c                2	
X dot.c                      1	
X event.c                    1	
X mahjongg.6                 1	
X mahjongg.c                 2	
X mahjongg.h                 1	
X other.c                    2	
X tiles.c                    1	
X window.c                   1	
END_OF_FILE
if test 499 -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'\" \(1463 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# Tom's generic makefile
X#
X# This makefile uses the shared libraries
X# just type make
X#
X
X# program name
XNAME = mahjongg
X
X# Program specific flags
X# To make background color tiles the default comment the next line
XDFLAGS = -DINVERSE_VIDEO
X
X# program source and object files
XHDR = mahjongg.h
XSRC = mahjongg.c window.c tiles.c event.c bamboo.c character.c dot.c other.c
XOBJ = mahjongg.o window.o tiles.o event.o bamboo.o character.o dot.o other.o
X
X# Uncomment the next two lines if you want to use GCC
X#CC = gcc
X#GNULIB = /usr/local/lib/gcc-gnulib
X
XCFLAGS = -O $(DFLAGS)
XLDFLAGS = -s
XSHAREDLIB = /lib/crt0s.o /lib/shlib.ifile
XBIN = /usr/games
XMANDIR = /usr/man/man6
XLINT = lint -xbp
X
Xall: $(NAME)
X
X$(NAME):	$(OBJ)
X	$(LD) $(LDFLAGS) -o $(NAME) $(SHAREDLIB) $(OBJ) $(GNULIB)
X
Xinstall: $(NAME)
X	cp $(NAME) $(BIN)/$(NAME)
X	chgrp bin $(BIN)/$(NAME)
X	chown bin $(BIN)/$(NAME)
X	cp $(NAME).6 $(MANDIR)/$(NAME).6
X
Xclean:
X	rm -f *.o Makefile~ core $(NAME).sh* $(NAME)
X
Xshar:
X	shar -s 50000 -h $(NAME).sh README Makefile $(HDR) $(SRC)
X
Xlint:
X	$(LINT) $(SRC)
X
X# requires gcc to build the dependencies
Xdepend:
X	cp Makefile Makefile~
X	sed -e "/^#######/q" Makefile~ > Makefile
X	gcc -MM $(SRC) >> Makefile
X	
X######### Source file dependencies - do not touch ##########
Xmahjongg.o : mahjongg.c mahjongg.h 
Xwindow.o : window.c mahjongg.h 
Xtiles.o : tiles.c mahjongg.h 
Xevent.o : event.c mahjongg.h 
Xbamboo.o : bamboo.c 
Xcharacter.o : character.c 
Xdot.o : dot.c 
Xother.o : other.c 
END_OF_FILE
if test 1463 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(888 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 (tkacik@kyzyl.mi.org).
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
Xtkacik@kyzyl.mi.org
END_OF_FILE
if test 888 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'bamboo.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bamboo.c'\"
else
echo shar: Extracting \"'bamboo.c'\" \(9080 characters\)
sed "s/^X//" >'bamboo.c' <<'END_OF_FILE'
X/*  array bam1 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam1[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x0000,	0x2c00,	
X	0x0001,	0x0000,	0xd404,	
X	0x0001,	0x0000,	0xac06,	
X	0x3c31,	0x0000,	0x5404,	
X	0x42c1,	0x0000,	0xac04,	
X	0x8d01,	0x0000,	0x5404,	
X	0xc2f1,	0x0000,	0xac04,	
X	0x7c01,	0x0007,	0x540e,	
X	0x2001,	0x0038,	0xac00,	
X	0x9001,	0x01c7,	0x5400,	
X	0x5001,	0x0638,	0xac00,	
X	0xd001,	0x1bc4,	0x5400,	
X	0x2001,	0x24f9,	0xac00,	
X	0xc001,	0xd800,	0x5400,	
X	0x0001,	0xb7ff,	0xac03,	
X	0x0001,	0x4067,	0x540d,	
X	0x0001,	0x8021,	0xac3a,	
X	0x8001,	0x0790,	0x54fd,	
X	0xc001,	0x00f8,	0xac06,	
X	0xf801,	0x000f,	0x5404,	
X	0x0f01,	0x0000,	0xac00,	
X	0x01e1,	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,	
X};
X
X/*  array bam2 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam2[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0071,	0x0000,	0x2c00,	
X	0x0089,	0x0000,	0xd400,	
X	0x0081,	0x00f8,	0xac00,	
X	0x0071,	0x0050,	0x5400,	
X	0x0009,	0x0050,	0xac00,	
X	0x0009,	0x0050,	0x5400,	
X	0x00f9,	0x00f8,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x0050,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x00f8,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x00f8,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x0050,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x00f8,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x0050,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x00f8,	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,	
X};
X
X/*  array bam3 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam3[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0071,	0x0000,	0x2c00,	
X	0x0089,	0x0000,	0xd400,	
X	0x0081,	0x00f8,	0xac00,	
X	0x0071,	0x0050,	0x5400,	
X	0x0081,	0x0050,	0xac00,	
X	0x0089,	0x0050,	0x5400,	
X	0x0071,	0x00f8,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x0050,	0xac00,	
X	0x0001,	0x0050,	0x5400,	
X	0x0001,	0x00f8,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xf801,	0xf800,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0x5001,	0x5000,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0xf801,	0xf800,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0x5001,	0x5000,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0xf801,	0xf800,	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,	
X};
X
X/*  array bam4 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam4[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0081,	0x0000,	0x2c00,	
X	0x00c1,	0x0000,	0xd400,	
X	0xf8a1,	0xf800,	0xac00,	
X	0x5091,	0x5000,	0x5400,	
X	0x5089,	0x5000,	0xac00,	
X	0x51f9,	0x5000,	0x5400,	
X	0xf881,	0xf800,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0x5001,	0x5000,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0xf801,	0xf800,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xf801,	0xf800,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0x5001,	0x5000,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0xf801,	0xf800,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0x5001,	0x5000,	0xac00,	
X	0x5001,	0x5000,	0x5400,	
X	0xf801,	0xf800,	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,	
X};
X
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.  */
Xunsigned short bam5[32][3] = {
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,	
X};
X
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.  */
Xunsigned short bam6[32][3] = {
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,	
X};
X
X/*  array bam7 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam7[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x00f9,	0x0000,	0x2c00,	
X	0x0081,	0x01f0,	0xd400,	
X	0x0081,	0x00a0,	0xac00,	
X	0x0041,	0x00a0,	0x5400,	
X	0x0021,	0x01f0,	0xac00,	
X	0x0021,	0x00a0,	0x5400,	
X	0x0021,	0x00a0,	0xac00,	
X	0x0001,	0x01f0,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x0001,	0x0000,	0xac00,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array bam8 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam8[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0001,	0x0000,	0x2c00,	
X	0x0001,	0x0000,	0xd400,	
X	0xcf81,	0x9800,	0xac0f,	
X	0x3501,	0x6603,	0x5405,	
X	0xc501,	0x1f8f,	0xac05,	
X	0x0501,	0x0673,	0x5405,	
X	0x0f81,	0x8124,	0xac0f,	
X	0x0501,	0x00f8,	0x5405,	
X	0x0501,	0x0000,	0xac05,	
X	0x0501,	0x0070,	0x5405,	
X	0x0f81,	0x8088,	0xac0f,	
X	0x0001,	0x0088,	0x5400,	
X	0x0001,	0x0070,	0xac00,	
X	0x0001,	0x0088,	0x5400,	
X	0x0f81,	0x8088,	0xac0f,	
X	0x0501,	0x0070,	0x5405,	
X	0x0501,	0x0000,	0xac05,	
X	0x0501,	0x00f8,	0x5405,	
X	0x0f81,	0x8124,	0xac0f,	
X	0x0501,	0x0673,	0x5405,	
X	0xc501,	0x1f8f,	0xac05,	
X	0x3501,	0x6603,	0x5405,	
X	0xcf81,	0x9800,	0xac0f,	
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,	
X};
X
X/*  array bam9 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short bam9[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0071,	0x0000,	0x2c00,	
X	0x7c89,	0xc1f0,	0xd407,	
X	0x2889,	0x80a0,	0xac02,	
X	0x28f1,	0x80a0,	0x5402,	
X	0x7c81,	0xc1f0,	0xac07,	
X	0x2889,	0x80a0,	0x5402,	
X	0x2871,	0x80a0,	0xac02,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x0001,	0x0000,	0xac00,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x0001,	0x0000,	0xac00,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x2801,	0x80a0,	0xac02,	
X	0x2801,	0x80a0,	0x5402,	
X	0x7c01,	0xc1f0,	0xac07,	
X	0x2801,	0x80a0,	0x5402,	
X	0x2801,	0x80a0,	0xac02,	
X	0x7c01,	0xc1f0,	0x5407,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
END_OF_FILE
if test 9080 -ne `wc -c <'bamboo.c'`; then
    echo shar: \"'bamboo.c'\" unpacked with wrong size!
fi
# end of 'bamboo.c'
fi
if test -f 'dot.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dot.c'\"
else
echo shar: Extracting \"'dot.c'\" \(9080 characters\)
sed "s/^X//" >'dot.c' <<'END_OF_FILE'
X/*  array dot1 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot1[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0011,	0x0000,	0x2c00,	
X	0x0019,	0x1ffc,	0xd400,	
X	0x8011,	0xf087,	0xac00,	
X	0xe011,	0x8ff8,	0x5403,	
X	0x3811,	0x788f,	0xac0e,	
X	0xcc11,	0xe083,	0x5419,	
X	0x6639,	0x1084,	0xac33,	
X	0x3301,	0x0ff8,	0x5466,	
X	0x7901,	0x0c18,	0xac4f,	
X	0xc981,	0xd005,	0x54c9,	
X	0x0c81,	0x61c3,	0xac98,	
X	0x0481,	0x4631,	0x5490,	
X	0xff81,	0xc491,	0xacff,	
X	0x0481,	0x4631,	0x5490,	
X	0x0c81,	0x61c3,	0xac98,	
X	0xc981,	0xd005,	0x54c9,	
X	0x7901,	0x0c18,	0xac4f,	
X	0x3301,	0x0ff8,	0x5466,	
X	0x6601,	0x1084,	0xac33,	
X	0xcc01,	0xe083,	0x5419,	
X	0x3801,	0x788f,	0xac0e,	
X	0xe001,	0x8ff8,	0x5403,	
X	0x8001,	0xf087,	0xac00,	
X	0x0001,	0x1ffc,	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,	
X};
X
X/*  array dot2 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot2[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x07fe,	0x1c00,	
X	0x8071,	0x1c03,	0x2c00,	
X	0xc089,	0x31f8,	0xd400,	
X	0x6081,	0x670e,	0xac00,	
X	0x2071,	0x4c63,	0x5400,	
X	0x2009,	0x4999,	0xac00,	
X	0x2009,	0x4909,	0x5400,	
X	0x20f9,	0x4999,	0xac00,	
X	0x2001,	0x4c63,	0x5400,	
X	0x6001,	0x670e,	0xac00,	
X	0xc001,	0x31f8,	0x5400,	
X	0x8001,	0x1c03,	0xac00,	
X	0x0001,	0x07fe,	0x5400,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x07fe,	0x5400,	
X	0x8001,	0x1c03,	0xac00,	
X	0xc001,	0x31f8,	0x5400,	
X	0x6001,	0x670e,	0xac00,	
X	0x2001,	0x4c63,	0x5400,	
X	0x2001,	0x4999,	0xac00,	
X	0x2001,	0x4909,	0x5400,	
X	0x2001,	0x4999,	0xac00,	
X	0x2001,	0x4c63,	0x5400,	
X	0x6001,	0x670e,	0xac00,	
X	0xc001,	0x31f8,	0x5400,	
X	0x8001,	0x1c03,	0xac00,	
X	0x0001,	0x07fe,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot3 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot3[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0xc000,	0x1c1f,	
X	0x0071,	0x7000,	0x2c70,	
X	0x0089,	0x9800,	0xd4cf,	
X	0x0081,	0x6c00,	0xadb0,	
X	0x0071,	0x2400,	0x5522,	
X	0x0081,	0x2400,	0xad25,	
X	0x0089,	0x2400,	0x5522,	
X	0x0071,	0x6c00,	0xadb0,	
X	0x0001,	0x99fc,	0x54cf,	
X	0x0001,	0x7707,	0xac70,	
X	0x8001,	0xccf9,	0x541f,	
X	0xc001,	0x1b06,	0xac00,	
X	0x4001,	0x1222,	0x5400,	
X	0x4001,	0x1252,	0xac00,	
X	0x4001,	0x1222,	0x5400,	
X	0xc001,	0x1b06,	0xac00,	
X	0x9fc1,	0x0cf9,	0x5400,	
X	0x7071,	0x0707,	0xac00,	
X	0xcf99,	0x01fc,	0x5400,	
X	0xb06d,	0x0001,	0xac00,	
X	0x2225,	0x0001,	0x5400,	
X	0x2525,	0x0001,	0xac00,	
X	0x2225,	0x0001,	0x5400,	
X	0xb06d,	0x0001,	0xac00,	
X	0xcf99,	0x0000,	0x5400,	
X	0x7071,	0x0000,	0xac00,	
X	0x1fc1,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot4 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot4[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x0041,	0x0000,	0x2c00,	
X	0xe061,	0xe00f,	0xd40f,	
X	0x3851,	0x3838,	0xac38,	
X	0xcc49,	0xcc67,	0x5467,	
X	0x3645,	0x36d8,	0xacd8,	
X	0x12fd,	0x1291,	0x5491,	
X	0x9241,	0x9292,	0xac92,	
X	0x1201,	0x1291,	0x5491,	
X	0x3601,	0x36d8,	0xacd8,	
X	0xcc01,	0xcc67,	0x5467,	
X	0x3801,	0x3838,	0xac38,	
X	0xe001,	0xe00f,	0x540f,	
X	0x0001,	0x0000,	0xac00,	
X	0xe001,	0xe00f,	0x540f,	
X	0x3801,	0x3838,	0xac38,	
X	0xcc01,	0xcc67,	0x5467,	
X	0x3601,	0x36d8,	0xacd8,	
X	0x1201,	0x1291,	0x5491,	
X	0x9201,	0x9292,	0xac92,	
X	0x1201,	0x1291,	0x5491,	
X	0x3601,	0x36d8,	0xacd8,	
X	0xcc01,	0xcc67,	0x5467,	
X	0x3801,	0x3838,	0xac38,	
X	0xe001,	0xe00f,	0x540f,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot5 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot5[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x0000,	0x1c00,	
X	0x00f9,	0x0000,	0x2c00,	
X	0xf809,	0x8003,	0xd43f,	
X	0x4c09,	0xc006,	0xac64,	
X	0xb679,	0x600d,	0x54db,	
X	0x1281,	0x2009,	0xac91,	
X	0x4a81,	0xa00a,	0x54a4,	
X	0x1279,	0x2009,	0xac91,	
X	0xb601,	0x600d,	0x54db,	
X	0x4c01,	0xcfe6,	0xac64,	
X	0xf801,	0x9933,	0x543f,	
X	0x0001,	0x36d8,	0xac00,	
X	0x0001,	0x2448,	0x5400,	
X	0x0001,	0x2928,	0xac00,	
X	0x0001,	0x2448,	0x5400,	
X	0x0001,	0x36d8,	0xac00,	
X	0xf801,	0x9933,	0x543f,	
X	0x4c01,	0xcfe6,	0xac64,	
X	0xb601,	0x600d,	0x54db,	
X	0x1201,	0x2009,	0xac91,	
X	0x4a01,	0xa00a,	0x54a4,	
X	0x1201,	0x2009,	0xac91,	
X	0xb601,	0x6009,	0x54db,	
X	0x4c01,	0xc006,	0xac64,	
X	0xf801,	0x8003,	0x543f,	
X	0x0001,	0x0000,	0xac00,	
X	0x0001,	0x0000,	0x5400,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot6 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot6[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0xf801,	0xf803,	0x1c03,	
X	0x4c71,	0x4c06,	0x2c06,	
X	0xb689,	0xb609,	0xd40d,	
X	0x1209,	0x1209,	0xac09,	
X	0x4a79,	0x4a0a,	0x540a,	
X	0x1289,	0x1209,	0xac09,	
X	0xb689,	0xb60d,	0x540d,	
X	0x4c71,	0x4c06,	0xac06,	
X	0xf801,	0xf803,	0x5403,	
X	0xf801,	0xf803,	0xac03,	
X	0x4c01,	0x4c06,	0x5406,	
X	0xb601,	0xb60d,	0xac0d,	
X	0x1201,	0x1209,	0x5409,	
X	0x4a01,	0x4a0a,	0xac0a,	
X	0x1201,	0x1209,	0x5409,	
X	0xb601,	0xb60d,	0xac0d,	
X	0x4c01,	0x4c06,	0x5406,	
X	0xf801,	0xf803,	0xac03,	
X	0xf801,	0xf803,	0x5403,	
X	0x4c01,	0x4c06,	0xac06,	
X	0xb601,	0xf60d,	0x540d,	
X	0x1201,	0x1209,	0xac09,	
X	0x4a01,	0x4a0a,	0x540a,	
X	0x1201,	0x1209,	0xac09,	
X	0xb601,	0xb60d,	0x540d,	
X	0x4c01,	0x4c06,	0xac06,	
X	0xf801,	0xf803,	0x5403,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot7 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot7[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0x0001,	0x07f0,	0x1c00,	
X	0x00f9,	0x0c98,	0x2c00,	
X	0x0081,	0x1b6c,	0xd400,	
X	0x0081,	0x1224,	0xac00,	
X	0x0041,	0x1494,	0x5400,	
X	0x0021,	0x1224,	0xac00,	
X	0x0021,	0x1b6c,	0x5400,	
X	0x0021,	0x0c98,	0xac00,	
X	0x0001,	0x07f0,	0x5400,	
X	0x7f01,	0x07f0,	0xac7f,	
X	0xc981,	0x8c98,	0x54c9,	
X	0xb6c1,	0xdb6d,	0xadb6,	
X	0x2241,	0x5225,	0x5522,	
X	0x4941,	0x5495,	0xad49,	
X	0x2241,	0x5225,	0x5522,	
X	0xb6c1,	0xdb6d,	0xadb6,	
X	0xc981,	0x8c98,	0x54c9,	
X	0x7f01,	0x07f0,	0xac7f,	
X	0x7f01,	0x07f0,	0x547f,	
X	0xc981,	0x8c98,	0xacc9,	
X	0xb6c1,	0xdb6d,	0x55b6,	
X	0x2241,	0x5225,	0xad22,	
X	0x4941,	0x5495,	0x5549,	
X	0x2241,	0x5225,	0xad22,	
X	0xb6c1,	0xdb6d,	0x55b6,	
X	0xc981,	0x8c98,	0xacc9,	
X	0x7f01,	0x07f0,	0x547f,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot8 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot8[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0xfc01,	0x0fe1,	0x1c7f,	
X	0x2639,	0x9933,	0x2cc9,	
X	0xdb45,	0xf6de,	0xd5b6,	
X	0x8945,	0x644c,	0xad22,	
X	0x2539,	0x692d,	0x5549,	
X	0x8945,	0x644c,	0xad22,	
X	0xdb45,	0xf6de,	0x55b6,	
X	0x2639,	0x9933,	0xacc9,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0xfc01,	0x0001,	0xac7f,	
X	0x2601,	0x8003,	0x54c9,	
X	0xdb01,	0xc006,	0xadb6,	
X	0x8901,	0x4004,	0x5522,	
X	0x2501,	0x4005,	0xad49,	
X	0x8901,	0x4004,	0x5522,	
X	0xdb01,	0xc006,	0xadb6,	
X	0x2601,	0x8003,	0x54c9,	
X	0xfc01,	0x0001,	0xac7f,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0x2601,	0x9933,	0xacc9,	
X	0xdb01,	0xf6de,	0x55b6,	
X	0x8901,	0x644c,	0xad22,	
X	0x2501,	0x692d,	0x5549,	
X	0x8901,	0x644c,	0xad22,	
X	0xdb01,	0xf6de,	0x55b6,	
X	0x2601,	0x9933,	0xacc9,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
X
X/*  array dot9 contains a picture 48 pixels wide and 32 pixels high.
X    for wrastop calls use srcwidth = 6, width = 48, and height = 32.  */
Xunsigned short dot9[32][3] = {
X	0xffff,	0xffff,	0x07ff,	
X	0xfc01,	0x0fe1,	0x1c7f,	
X	0x2639,	0x9933,	0x2cc9,	
X	0xdb45,	0xf6de,	0xd5b6,	
X	0x8945,	0x644c,	0xad22,	
X	0x2579,	0x692d,	0x5549,	
X	0x8941,	0x644c,	0xad22,	
X	0xdb45,	0xf6de,	0x55b6,	
X	0x2639,	0x9933,	0xacc9,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0xfc01,	0x0fe1,	0xac7f,	
X	0x2601,	0x9933,	0x54c9,	
X	0xdb01,	0xf6de,	0xadb6,	
X	0x8901,	0x644c,	0x5522,	
X	0x2501,	0x692d,	0xad49,	
X	0x8901,	0x644c,	0x5522,	
X	0xdb01,	0xf6de,	0xadb6,	
X	0x2601,	0x9933,	0x54c9,	
X	0xfc01,	0x0fe1,	0xac7f,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0x2601,	0x9933,	0xacc9,	
X	0xdb01,	0xf6de,	0x55b6,	
X	0x8901,	0x644c,	0xad22,	
X	0x2501,	0x692d,	0x5549,	
X	0x8901,	0x644c,	0xad22,	
X	0xdb01,	0xf6de,	0x55b6,	
X	0x2601,	0x9933,	0xacc9,	
X	0xfc01,	0x0fe1,	0x547f,	
X	0xffff,	0xffff,	0xafff,	
X	0xaaab,	0xaaaa,	0x5aaa,	
X	0x555c,	0x5555,	0xb555,	
X	0xaab0,	0xaaaa,	0xeaaa,	
X};
END_OF_FILE
if test 9080 -ne `wc -c <'dot.c'`; then
    echo shar: \"'dot.c'\" unpacked with wrong size!
fi
# end of 'dot.c'
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'\" \(8296 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 *                                 tkacik@kyzyl.mi.org
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 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 8296 -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 have
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 board.
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.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'mahjongg.h'\"
else
echo shar: Extracting \"'mahjongg.h'\" \(4402 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 *                                 tkacik@kyzyl.mi.org
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/* individual tiles */
Xextern unsigned short bam1[32][3];
Xextern unsigned short bam2[32][3];
Xextern unsigned short bam3[32][3];
Xextern unsigned short bam4[32][3];
Xextern unsigned short bam5[32][3];
Xextern unsigned short bam6[32][3];
Xextern unsigned short bam7[32][3];
Xextern unsigned short bam8[32][3];
Xextern unsigned short bam9[32][3];
Xextern unsigned short cha1[32][3];
Xextern unsigned short cha2[32][3];
Xextern unsigned short cha3[32][3];
Xextern unsigned short cha4[32][3];
Xextern unsigned short cha5[32][3];
Xextern unsigned short cha6[32][3];
Xextern unsigned short cha7[32][3];
Xextern unsigned short cha8[32][3];
Xextern unsigned short cha9[32][3];
Xextern unsigned short dot1[32][3];
Xextern unsigned short dot2[32][3];
Xextern unsigned short dot3[32][3];
Xextern unsigned short dot4[32][3];
Xextern unsigned short dot5[32][3];
Xextern unsigned short dot6[32][3];
Xextern unsigned short dot7[32][3];
Xextern unsigned short dot8[32][3];
Xextern unsigned short dot9[32][3];
Xextern unsigned short B[32][3];
Xextern unsigned short C[32][3];
Xextern unsigned short F[32][3];
Xextern unsigned short north[32][3];
Xextern unsigned short east[32][3];
Xextern unsigned short south[32][3];
Xextern unsigned short west[32][3];
Xextern unsigned short plum[32][3];
Xextern unsigned short orchid[32][3];
Xextern unsigned short bamboo[32][3];
Xextern unsigned short mum[32][3];
Xextern unsigned short autumn[32][3];
Xextern unsigned short summer[32][3];
Xextern unsigned short spring[32][3];
Xextern unsigned short winter[32][3];
X
X/* tile image definitions */
Xextern unsigned short *images[42];
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 4402 -ne `wc -c <'mahjongg.h'`; then
    echo shar: \"'mahjongg.h'\" unpacked with wrong size!
fi
# end of 'mahjongg.h'
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'\" \(1660 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 *                                 tkacik@kyzyl.mi.org
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
X/* the 42 rastor images */
Xunsigned short *images[42] = {
X	bam1[0], bam2[0], bam3[0], bam4[0], bam5[0],
X	bam6[0], bam7[0], bam8[0], bam9[0],
X	cha1[0], cha2[0], cha3[0], cha4[0], cha5[0],
X	cha6[0], cha7[0], cha8[0], cha9[0],
X	dot1[0], dot2[0], dot3[0], dot4[0], dot5[0],
X	dot6[0], dot7[0], dot8[0], dot9[0],
X	B[0], C[0], F[0],
X	north[0], east[0], south[0], west[0],
X	plum[0], orchid[0], bamboo[0], mum[0],
X	autumn[0], summer[0], spring[0], winter[0]
X};
END_OF_FILE
if test 1660 -ne `wc -c <'tiles.c'`; then
    echo shar: \"'tiles.c'\" unpacked with wrong size!
fi
# end of 'tiles.c'
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
-- 
David H. Brierley
Home: dave@galaxia.newport.ri.us; Work: dhb@quahog.ssd.ray.com
Send comp.sources.3b1 submissions to comp-sources-3b1@galaxia.newport.ri.us
%% Can I be excused, my brain is full. **