games@tekred.TEK.COM (06/21/88)
Submitted by: cvedc!opus!markh (Mark Holm)
Comp.sources.games: Volume 4, Issue 50
Archive-name: mahjongg2/Part01
[OK, as they say: "You asked for it, now you're going to get it!"
There was a large number of you requesting the source for the
mahjongg tiles, so here it is. This version of mahjongg.c has
a few patches applied to it and should completely replace the
old one. Note that this is in 38 parts spread out over several
days. -br]
#! /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 38)."
# Contents: README MANIFEST icons.c mahjongg.c tiles tiles/bandw
# tiles/bandw/mahjongg.cursor tiles/rdrunner
# Wrapped by billr@saab on Fri Jun 17 11:58:24 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(1133 characters\)
sed "s/^X//" >README <<'END_OF_README'
XMAHJONGG Version 1.0
X
XCopyright 1988 Mark A. Holm
X
XPermission is given to copy and distribute for non-profit purposes.
X
XThis game will operate on any Sun hardware that I know of with either
Xa monochrome or a color bit mapped tube running Sun 3.2 UNIX or later.
XMost of the development was done on a Sun 100U running Sun 3.5.
X
XPlease Note!! The automagic screen type determination will not recognize
Xall screen types unless compiled with <sys/fbio.h> from a 3.5 OS. If
Xcompiled with 3.2 not all monochrome types are recognized. Also note that I did
Xnot have enough time or alternate screen types to check out the 386.
X
XINSTALLATION INSTRUCTIONS:
X
X1. Unpack this kit in an empty directory and edit the Makefile to
X set MANLOC and DESTDIR to the appropriate locations. Define
X TARGET as RDRUNNER, if you're on a 386i. If it's a SPARC,
X you're on your own.
X
X2. run 'make install'.
X
XIf you would like the patches to iconedit so you can modify the
Xicons, send a request (and possibly a small donation ;^) to the
Xaddress below.
X
XIf you have any questions or problems/bug reports, send them to me:
X
XMark A. Holm
Xtektronix!tessi!exc!markh
END_OF_README
if test 1133 -ne `wc -c <README`; then
echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f MANIFEST -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"MANIFEST\"
else
echo shar: Extracting \"MANIFEST\" \(5441 characters\)
sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
X File Name Archive # Description
X-----------------------------------------------------------
X MANIFEST 1
X MANIFEST.BAK 4
X Makefile 23
X Makefile.net 2
X README 1
X READ_ME 4
X color.h 3
X event.c 2
X icons.c 1
X mahjongg.6 5
X mahjongg.c 1
X mahjongg.h 3
X mahjongg.icon 23
X tiles 1
X tiles/0 38
X tiles/1 37
X tiles/2 36
X tiles/3 36
X tiles/4 35
X tiles/5 35
X tiles/6 36
X tiles/7 35
X tiles/8 37
X tiles/9 37
X tiles/bam1 32
X tiles/bam2 33
X tiles/bam3 33
X tiles/bam4 33
X tiles/bam5 34
X tiles/bam6 34
X tiles/bam7 32
X tiles/bam8 32
X tiles/bam9 34
X tiles/bandw 1
X tiles/bandw/0 22
X tiles/bandw/1 22
X tiles/bandw/2 22
X tiles/bandw/3 23
X tiles/bandw/4 21
X tiles/bandw/5 20
X tiles/bandw/6 21
X tiles/bandw/7 21
X tiles/bandw/8 20
X tiles/bandw/9 20
X tiles/bandw/bam1 17
X tiles/bandw/bam2 19
X tiles/bandw/bam3 19
X tiles/bandw/bam4 19
X tiles/bandw/bam5 18
X tiles/bandw/bam6 18
X tiles/bandw/bam7 18
X tiles/bandw/bam8 17
X tiles/bandw/bam9 17
X tiles/bandw/blank 15
X tiles/bandw/c_east 8
X tiles/bandw/c_north 7
X tiles/bandw/c_south 8
X tiles/bandw/c_west 8
X tiles/bandw/char1 15
X tiles/bandw/char2 12
X tiles/bandw/char3 11
X tiles/bandw/char4 14
X tiles/bandw/char5 13
X tiles/bandw/char6 13
X tiles/bandw/char7 12
X tiles/bandw/char8 11
X tiles/bandw/char9 15
X tiles/bandw/circ1 9
X tiles/bandw/circ2 10
X tiles/bandw/circ3 11
X tiles/bandw/circ4 16
X tiles/bandw/circ5 10
X tiles/bandw/circ6 12
X tiles/bandw/circ7 14
X tiles/bandw/circ8 10
X tiles/bandw/circ9 13
X tiles/bandw/d_green 7
X tiles/bandw/d_red 14
X tiles/bandw/d_white 7
X tiles/bandw/f_bam 16
X tiles/bandw/f_mum 16
X tiles/bandw/f_orch 9
X tiles/bandw/f_plum 9
X tiles/bandw/mahjongg.cursor 1
X tiles/bandw/s_autumn 6
X tiles/bandw/s_spring 5
X tiles/bandw/s_summer 6
X tiles/bandw/s_winter 6
X tiles/blank 31
X tiles/c_east 23
X tiles/c_north 22
X tiles/c_south 22
X tiles/c_west 24
X tiles/char1 29
X tiles/char2 31
X tiles/char3 31
X tiles/char4 30
X tiles/char5 30
X tiles/char6 30
X tiles/char7 29
X tiles/char8 29
X tiles/char9 26
X tiles/circ1 28
X tiles/circ2 28
X tiles/circ3 28
X tiles/circ4 27
X tiles/circ5 27
X tiles/circ6 27
X tiles/circ7 26
X tiles/circ8 26
X tiles/circ9 25
X tiles/d_green 22
X tiles/d_red 24
X tiles/d_white 23
X tiles/f_bam 25
X tiles/f_mum 25
X tiles/f_orch 23
X tiles/f_plum 24
X tiles/mahjongg.icon 17
X tiles/rdrunner 1
X tiles/rdrunner/0 20
X tiles/rdrunner/1 19
X tiles/rdrunner/2 19
X tiles/rdrunner/3 19
X tiles/rdrunner/4 18
X tiles/rdrunner/5 18
X tiles/rdrunner/6 18
X tiles/rdrunner/7 17
X tiles/rdrunner/8 17
X tiles/rdrunner/9 20
X tiles/rdrunner/bam1 16
X tiles/rdrunner/bam2 14
X tiles/rdrunner/bam3 15
X tiles/rdrunner/bam4 15
X tiles/rdrunner/bam5 14
X tiles/rdrunner/bam6 16
X tiles/rdrunner/bam7 15
X tiles/rdrunner/bam8 14
X tiles/rdrunner/bam9 16
X tiles/rdrunner/blank 8
X tiles/rdrunner/c_east 5
X tiles/rdrunner/c_north 4
X tiles/rdrunner/c_south 4
X tiles/rdrunner/c_west 6
X tiles/rdrunner/char1 8
X tiles/rdrunner/char2 7
X tiles/rdrunner/char3 7
X tiles/rdrunner/char4 9
X tiles/rdrunner/char5 13
X tiles/rdrunner/char6 13
X tiles/rdrunner/char7 12
X tiles/rdrunner/char8 13
X tiles/rdrunner/char9 12
X tiles/rdrunner/circ1 7
X tiles/rdrunner/circ2 12
X tiles/rdrunner/circ3 11
X tiles/rdrunner/circ4 11
X tiles/rdrunner/circ5 11
X tiles/rdrunner/circ6 10
X tiles/rdrunner/circ7 6
X tiles/rdrunner/circ8 10
X tiles/rdrunner/circ9 10
X tiles/rdrunner/d_green 5
X tiles/rdrunner/d_red 9
X tiles/rdrunner/d_white 4
X tiles/rdrunner/f_bam 9
X tiles/rdrunner/f_mum 8
X tiles/rdrunner/f_orch 5
X tiles/rdrunner/f_plum 6
X tiles/rdrunner/mahjongg.icon 2
X tiles/rdrunner/s_autumn 3
X tiles/rdrunner/s_spring 3
X tiles/rdrunner/s_summer 3
X tiles/rdrunner/s_winter 2
X tiles/s_autumn 21
X tiles/s_spring 21
X tiles/s_summer 20
X tiles/s_winter 21
END_OF_MANIFEST
if test 5441 -ne `wc -c <MANIFEST`; then
echo shar: \"MANIFEST\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f icons.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"icons.c\"
else
echo shar: Extracting \"icons.c\" \(15768 characters\)
sed "s/^X//" >icons.c <<'END_OF_icons.c'
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/* This is the file for building the icon images for the */
X/* tiles both color and b/w. */
X
X#include <sys/types.h>
X#include <pixrect/pixrect.h>
X#include <suntool/sunview.h>
X
X/* color frame closed icon */
X
Xstatic short icon_cimage[] = {
X#include "tiles/mahjongg.icon"
X};
Xmpr_static(cicon_image, 64, 64, 8, icon_cimage);
X
X/* cursor icons */
X
Xshort stick_image[] = {
X#include "tiles/bandw/mahjongg.cursor"
X};
Xmpr_static(stick, 16, 16, 1, stick_image);
X
Xstatic short wait_image[] = {
X#include <images/hglass.cursor>
X};
Xmpr_static(wait, 16, 16, 1, wait_image);
X
Xstatic short confirm_image[] = {
X#include <images/confirm.pr>
X};
Xmpr_static(confirm, 16, 16, 1, confirm_image);
X
X/* Number tiles (color) */
X
Xstatic short NUM0_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/0"
X#else
X#include "tiles/0"
X#endif RDRUNNER
X};
Xmpr_static(cNUM0, 64, 64, 8, NUM0_cimage);
X
Xstatic short NUM1_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/1"
X#else
X#include "tiles/1"
X#endif RDRUNNER
X};
Xmpr_static(cNUM1, 64, 64, 8, NUM1_cimage);
X
Xstatic short NUM2_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/2"
X#else
X#include "tiles/2"
X#endif RDRUNNER
X};
Xmpr_static(cNUM2, 64, 64, 8, NUM2_cimage);
X
Xstatic short NUM3_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/3"
X#else
X#include "tiles/3"
X#endif RDRUNNER
X};
Xmpr_static(cNUM3, 64, 64, 8, NUM3_cimage);
X
Xstatic short NUM4_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/4"
X#else
X#include "tiles/4"
X#endif RDRUNNER
X};
Xmpr_static(cNUM4, 64, 64, 8, NUM4_cimage);
X
Xstatic short NUM5_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/5"
X#else
X#include "tiles/5"
X#endif RDRUNNER
X};
Xmpr_static(cNUM5, 64, 64, 8, NUM5_cimage);
X
Xstatic short NUM6_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/6"
X#else
X#include "tiles/6"
X#endif RDRUNNER
X};
Xmpr_static(cNUM6, 64, 64, 8, NUM6_cimage);
X
Xstatic short NUM7_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/7"
X#else
X#include "tiles/7"
X#endif RDRUNNER
X};
Xmpr_static(cNUM7, 64, 64, 8, NUM7_cimage);
X
Xstatic short NUM8_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/8"
X#else
X#include "tiles/8"
X#endif RDRUNNER
X};
Xmpr_static(cNUM8, 64, 64, 8, NUM8_cimage);
X
Xstatic short NUM9_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/9"
X#else
X#include "tiles/9"
X#endif RDRUNNER
X};
Xmpr_static(cNUM9, 64, 64, 8, NUM9_cimage);
X
X/* Number tiles (B/W) */
X
Xstatic short NUM0_image[] = {
X#include "tiles/bandw/0"
X};
Xmpr_static(NUM0, 64, 64, 1, NUM0_image);
X
Xstatic short NUM1_image[] = {
X#include "tiles/bandw/1"
X};
Xmpr_static(NUM1, 64, 64, 1, NUM1_image);
X
Xstatic short NUM2_image[] = {
X#include "tiles/bandw/2"
X};
Xmpr_static(NUM2, 64, 64, 1, NUM2_image);
X
Xstatic short NUM3_image[] = {
X#include "tiles/bandw/3"
X};
Xmpr_static(NUM3, 64, 64, 1, NUM3_image);
X
Xstatic short NUM4_image[] = {
X#include "tiles/bandw/4"
X};
Xmpr_static(NUM4, 64, 64, 1, NUM4_image);
X
Xstatic short NUM5_image[] = {
X#include "tiles/bandw/5"
X};
Xmpr_static(NUM5, 64, 64, 1, NUM5_image);
X
Xstatic short NUM6_image[] = {
X#include "tiles/bandw/6"
X};
Xmpr_static(NUM6, 64, 64, 1, NUM6_image);
X
Xstatic short NUM7_image[] = {
X#include "tiles/bandw/7"
X};
Xmpr_static(NUM7, 64, 64, 1, NUM7_image);
X
Xstatic short NUM8_image[] = {
X#include "tiles/bandw/8"
X};
Xmpr_static(NUM8, 64, 64, 1, NUM8_image);
X
Xstatic short NUM9_image[] = {
X#include "tiles/bandw/9"
X};
Xmpr_static(NUM9, 64, 64, 1, NUM9_image);
X
X/* Playing Tiles (color) */
X
Xstatic short BLANK_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/blank"
X#else
X#include "tiles/blank"
X#endif RDRUNNER
X};
Xmpr_static(cBLANK, 64, 64, 8, BLANK_cimage);
X
Xstatic short BAM1_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam1"
X#else
X#include "tiles/bam1"
X#endif RDRUNNER
X};
Xmpr_static(cBAM1, 64, 64, 8, BAM1_cimage);
X
Xstatic short BAM2_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam2"
X#else
X#include "tiles/bam2"
X#endif RDRUNNER
X};
Xmpr_static(cBAM2, 64, 64, 8, BAM2_cimage);
X
Xstatic short BAM3_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam3"
X#else
X#include "tiles/bam3"
X#endif RDRUNNER
X};
Xmpr_static(cBAM3, 64, 64, 8, BAM3_cimage);
X
Xstatic short BAM4_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam4"
X#else
X#include "tiles/bam4"
X#endif RDRUNNER
X};
Xmpr_static(cBAM4, 64, 64, 8, BAM4_cimage);
X
Xstatic short BAM5_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam5"
X#else
X#include "tiles/bam5"
X#endif RDRUNNER
X};
Xmpr_static(cBAM5, 64, 64, 8, BAM5_cimage);
X
Xstatic short BAM6_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam6"
X#else
X#include "tiles/bam6"
X#endif RDRUNNER
X};
Xmpr_static(cBAM6, 64, 64, 8, BAM6_cimage);
X
Xstatic short BAM7_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam7"
X#else
X#include "tiles/bam7"
X#endif RDRUNNER
X};
Xmpr_static(cBAM7, 64, 64, 8, BAM7_cimage);
X
Xstatic short BAM8_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam8"
X#else
X#include "tiles/bam8"
X#endif RDRUNNER
X};
Xmpr_static(cBAM8, 64, 64, 8, BAM8_cimage);
X
Xstatic short BAM9_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/bam9"
X#else
X#include "tiles/bam9"
X#endif RDRUNNER
X};
Xmpr_static(cBAM9, 64, 64, 8, BAM9_cimage);
X
Xstatic short DOT1_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ1"
X#else
X#include "tiles/circ1"
X#endif RDRUNNER
X};
Xmpr_static(cDOT1, 64, 64, 8, DOT1_cimage);
X
Xstatic short DOT2_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ2"
X#else
X#include "tiles/circ2"
X#endif RDRUNNER
X};
Xmpr_static(cDOT2, 64, 64, 8, DOT2_cimage);
X
Xstatic short DOT3_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ3"
X#else
X#include "tiles/circ3"
X#endif RDRUNNER
X};
Xmpr_static(cDOT3, 64, 64, 8, DOT3_cimage);
X
Xstatic short DOT4_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ4"
X#else
X#include "tiles/circ4"
X#endif RDRUNNER
X};
Xmpr_static(cDOT4, 64, 64, 8, DOT4_cimage);
X
Xstatic short DOT5_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ5"
X#else
X#include "tiles/circ5"
X#endif RDRUNNER
X};
Xmpr_static(cDOT5, 64, 64, 8, DOT5_cimage);
X
Xstatic short DOT6_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ6"
X#else
X#include "tiles/circ6"
X#endif RDRUNNER
X};
Xmpr_static(cDOT6, 64, 64, 8, DOT6_cimage);
X
Xstatic short DOT7_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ7"
X#else
X#include "tiles/circ7"
X#endif RDRUNNER
X};
Xmpr_static(cDOT7, 64, 64, 8, DOT7_cimage);
X
Xstatic short DOT8_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ8"
X#else
X#include "tiles/circ8"
X#endif RDRUNNER
X};
Xmpr_static(cDOT8, 64, 64, 8, DOT8_cimage);
X
Xstatic short DOT9_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/circ9"
X#else
X#include "tiles/circ9"
X#endif RDRUNNER
X};
Xmpr_static(cDOT9, 64, 64, 8, DOT9_cimage);
X
Xstatic short CHA1_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char1"
X#else
X#include "tiles/char1"
X#endif RDRUNNER
X};
Xmpr_static(cCHA1, 64, 64, 8, CHA1_cimage);
X
Xstatic short CHA2_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char2"
X#else
X#include "tiles/char2"
X#endif RDRUNNER
X};
Xmpr_static(cCHA2, 64, 64, 8, CHA2_cimage);
X
Xstatic short CHA3_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char3"
X#else
X#include "tiles/char3"
X#endif RDRUNNER
X};
Xmpr_static(cCHA3, 64, 64, 8, CHA3_cimage);
X
Xstatic short CHA4_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char4"
X#else
X#include "tiles/char4"
X#endif RDRUNNER
X};
Xmpr_static(cCHA4, 64, 64, 8, CHA4_cimage);
X
Xstatic short CHA5_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char5"
X#else
X#include "tiles/char5"
X#endif RDRUNNER
X};
Xmpr_static(cCHA5, 64, 64, 8, CHA5_cimage);
X
Xstatic short CHA6_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char6"
X#else
X#include "tiles/char6"
X#endif RDRUNNER
X};
Xmpr_static(cCHA6, 64, 64, 8, CHA6_cimage);
X
Xstatic short CHA7_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char7"
X#else
X#include "tiles/char7"
X#endif RDRUNNER
X};
Xmpr_static(cCHA7, 64, 64, 8, CHA7_cimage);
X
Xstatic short CHA8_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char8"
X#else
X#include "tiles/char8"
X#endif RDRUNNER
X};
Xmpr_static(cCHA8, 64, 64, 8, CHA8_cimage);
X
Xstatic short CHA9_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/char9"
X#else
X#include "tiles/char9"
X#endif RDRUNNER
X};
Xmpr_static(cCHA9, 64, 64, 8, CHA9_cimage);
X
Xstatic short EAST_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/c_east"
X#else
X#include "tiles/c_east"
X#endif RDRUNNER
X};
Xmpr_static(cEAST, 64, 64, 8, EAST_cimage);
X
Xstatic short WEST_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/c_west"
X#else
X#include "tiles/c_west"
X#endif RDRUNNER
X};
Xmpr_static(cWEST, 64, 64, 8, WEST_cimage);
X
Xstatic short SOUT_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/c_south"
X#else
X#include "tiles/c_south"
X#endif RDRUNNER
X};
Xmpr_static(cSOUT, 64, 64, 8, SOUT_cimage);
X
Xstatic short NORT_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/c_north"
X#else
X#include "tiles/c_north"
X#endif RDRUNNER
X};
Xmpr_static(cNORT, 64, 64, 8, NORT_cimage);
X
Xstatic short GRED_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/d_green"
X#else
X#include "tiles/d_green"
X#endif RDRUNNER
X};
Xmpr_static(cGRED, 64, 64, 8, GRED_cimage);
X
Xstatic short REDD_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/d_red"
X#else
X#include "tiles/d_red"
X#endif RDRUNNER
X};
Xmpr_static(cREDD, 64, 64, 8, REDD_cimage);
X
Xstatic short WHTD_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/d_white"
X#else
X#include "tiles/d_white"
X#endif RDRUNNER
X};
Xmpr_static(cWHTD, 64, 64, 8, WHTD_cimage);
X
Xstatic short AUT_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/s_autumn"
X#else
X#include "tiles/s_autumn"
X#endif RDRUNNER
X};
Xmpr_static( cAUT, 64, 64, 8, AUT_cimage);
X
Xstatic short SPR_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/s_spring"
X#else
X#include "tiles/s_spring"
X#endif RDRUNNER
X};
Xmpr_static( cSPR, 64, 64, 8, SPR_cimage);
X
Xstatic short SUM_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/s_summer"
X#else
X#include "tiles/s_summer"
X#endif RDRUNNER
X};
Xmpr_static( cSUM, 64, 64, 8, SUM_cimage);
X
Xstatic short WIN_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/s_winter"
X#else
X#include "tiles/s_winter"
X#endif RDRUNNER
X};
Xmpr_static( cWIN, 64, 64, 8, WIN_cimage);
X
Xstatic short BAM_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/f_bam"
X#else
X#include "tiles/f_bam"
X#endif RDRUNNER
X};
Xmpr_static( cBAM, 64, 64, 8, BAM_cimage);
X
Xstatic short MUM_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/f_mum"
X#else
X#include "tiles/f_mum"
X#endif RDRUNNER
X};
Xmpr_static( cMUM, 64, 64, 8, MUM_cimage);
X
Xstatic short ORC_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/f_orch"
X#else
X#include "tiles/f_orch"
X#endif RDRUNNER
X};
Xmpr_static( cORC, 64, 64, 8, ORC_cimage);
X
Xstatic short PLM_cimage[] = {
X#ifdef RDRUNNER
X#include "tiles/rdrunner/f_plum"
X#else
X#include "tiles/f_plum"
X#endif RDRUNNER
X};
Xmpr_static( cPLM, 64, 64, 8, PLM_cimage);
X
X
X/* Playing Tiles (B/W) */
X
Xstatic short BLANK_image[] = {
X#include "tiles/bandw/blank"
X};
Xmpr_static(BLANK, 64, 64, 1, BLANK_image);
X
Xstatic short BAM1_image[] = {
X#include "tiles/bandw/bam1"
X};
Xmpr_static(BAM1, 64, 64, 1, BAM1_image);
X
Xstatic short BAM2_image[] = {
X#include "tiles/bandw/bam2"
X};
Xmpr_static(BAM2, 64, 64, 1, BAM2_image);
X
Xstatic short BAM3_image[] = {
X#include "tiles/bandw/bam3"
X};
Xmpr_static(BAM3, 64, 64, 1, BAM3_image);
X
Xstatic short BAM4_image[] = {
X#include "tiles/bandw/bam4"
X};
Xmpr_static(BAM4, 64, 64, 1, BAM4_image);
X
Xstatic short BAM5_image[] = {
X#include "tiles/bandw/bam5"
X};
Xmpr_static(BAM5, 64, 64, 1, BAM5_image);
X
Xstatic short BAM6_image[] = {
X#include "tiles/bandw/bam6"
X};
Xmpr_static(BAM6, 64, 64, 1, BAM6_image);
X
Xstatic short BAM7_image[] = {
X#include "tiles/bandw/bam7"
X};
Xmpr_static(BAM7, 64, 64, 1, BAM7_image);
X
Xstatic short BAM8_image[] = {
X#include "tiles/bandw/bam8"
X};
Xmpr_static(BAM8, 64, 64, 1, BAM8_image);
X
Xstatic short BAM9_image[] = {
X#include "tiles/bandw/bam9"
X};
Xmpr_static(BAM9, 64, 64, 1, BAM9_image);
X
Xstatic short DOT1_image[] = {
X#include "tiles/bandw/circ1"
X};
Xmpr_static(DOT1, 64, 64, 1, DOT1_image);
X
Xstatic short DOT2_image[] = {
X#include "tiles/bandw/circ2"
X};
Xmpr_static(DOT2, 64, 64, 1, DOT2_image);
X
Xstatic short DOT3_image[] = {
X#include "tiles/bandw/circ3"
X};
Xmpr_static(DOT3, 64, 64, 1, DOT3_image);
X
Xstatic short DOT4_image[] = {
X#include "tiles/bandw/circ4"
X};
Xmpr_static(DOT4, 64, 64, 1, DOT4_image);
X
Xstatic short DOT5_image[] = {
X#include "tiles/bandw/circ5"
X};
Xmpr_static(DOT5, 64, 64, 1, DOT5_image);
X
Xstatic short DOT6_image[] = {
X#include "tiles/bandw/circ6"
X};
Xmpr_static(DOT6, 64, 64, 1, DOT6_image);
X
Xstatic short DOT7_image[] = {
X#include "tiles/bandw/circ7"
X};
Xmpr_static(DOT7, 64, 64, 1, DOT7_image);
X
Xstatic short DOT8_image[] = {
X#include "tiles/bandw/circ8"
X};
Xmpr_static(DOT8, 64, 64, 1, DOT8_image);
X
Xstatic short DOT9_image[] = {
X#include "tiles/bandw/circ9"
X};
Xmpr_static(DOT9, 64, 64, 1, DOT9_image);
X
Xstatic short CHA1_image[] = {
X#include "tiles/bandw/char1"
X};
Xmpr_static(CHA1, 64, 64, 1, CHA1_image);
X
Xstatic short CHA2_image[] = {
X#include "tiles/bandw/char2"
X};
Xmpr_static(CHA2, 64, 64, 1, CHA2_image);
X
Xstatic short CHA3_image[] = {
X#include "tiles/bandw/char3"
X};
Xmpr_static(CHA3, 64, 64, 1, CHA3_image);
X
Xstatic short CHA4_image[] = {
X#include "tiles/bandw/char4"
X};
Xmpr_static(CHA4, 64, 64, 1, CHA4_image);
X
Xstatic short CHA5_image[] = {
X#include "tiles/bandw/char5"
X};
Xmpr_static(CHA5, 64, 64, 1, CHA5_image);
X
Xstatic short CHA6_image[] = {
X#include "tiles/bandw/char6"
X};
Xmpr_static(CHA6, 64, 64, 1, CHA6_image);
X
Xstatic short CHA7_image[] = {
X#include "tiles/bandw/char7"
X};
Xmpr_static(CHA7, 64, 64, 1, CHA7_image);
X
Xstatic short CHA8_image[] = {
X#include "tiles/bandw/char8"
X};
Xmpr_static(CHA8, 64, 64, 1, CHA8_image);
X
Xstatic short CHA9_image[] = {
X#include "tiles/bandw/char9"
X};
Xmpr_static(CHA9, 64, 64, 1, CHA9_image);
X
Xstatic short EAST_image[] = {
X#include "tiles/bandw/c_east"
X};
Xmpr_static(EAST, 64, 64, 1, EAST_image);
X
Xstatic short WEST_image[] = {
X#include "tiles/bandw/c_west"
X};
Xmpr_static(WEST, 64, 64, 1, WEST_image);
X
Xstatic short SOUT_image[] = {
X#include "tiles/bandw/c_south"
X};
Xmpr_static(SOUT, 64, 64, 1, SOUT_image);
X
Xstatic short NORT_image[] = {
X#include "tiles/bandw/c_north"
X};
Xmpr_static(NORT, 64, 64, 1, NORT_image);
X
Xstatic short GRED_image[] = {
X#include "tiles/bandw/d_green"
X};
Xmpr_static(GRED, 64, 64, 1, GRED_image);
X
Xstatic short REDD_image[] = {
X#include "tiles/bandw/d_red"
X};
Xmpr_static(REDD, 64, 64, 1, REDD_image);
X
Xstatic short WHTD_image[] = {
X#include "tiles/bandw/d_white"
X};
Xmpr_static(WHTD, 64, 64, 1, WHTD_image);
X
Xstatic short AUT_image[] = {
X#include "tiles/bandw/s_autumn"
X};
Xmpr_static( AUT, 64, 64, 1, AUT_image);
X
Xstatic short SPR_image[] = {
X#include "tiles/bandw/s_spring"
X};
Xmpr_static( SPR, 64, 64, 1, SPR_image);
X
Xstatic short SUM_image[] = {
X#include "tiles/bandw/s_summer"
X};
Xmpr_static( SUM, 64, 64, 1, SUM_image);
X
Xstatic short WIN_image[] = {
X#include "tiles/bandw/s_winter"
X};
Xmpr_static( WIN, 64, 64, 1, WIN_image);
X
Xstatic short BAM_image[] = {
X#include "tiles/bandw/f_bam"
X};
Xmpr_static( BAM, 64, 64, 1, BAM_image);
X
Xstatic short MUM_image[] = {
X#include "tiles/bandw/f_mum"
X};
Xmpr_static( MUM, 64, 64, 1, MUM_image);
X
Xstatic short ORC_image[] = {
X#include "tiles/bandw/f_orch"
X};
Xmpr_static( ORC, 64, 64, 1, ORC_image);
X
Xstatic short PLM_image[] = {
X#include "tiles/bandw/f_plum"
X};
Xmpr_static( PLM, 64, 64, 1, PLM_image);
END_OF_icons.c
if test 15768 -ne `wc -c <icons.c`; then
echo shar: \"icons.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f mahjongg.c -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"mahjongg.c\"
else
echo shar: Extracting \"mahjongg.c\" \(27074 characters\)
sed "s/^X//" >mahjongg.c <<'END_OF_mahjongg.c'
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 * Revision History
X * ----------------
X *
X * 1.0 Initial release
X *
X * 1.1 removed non-working reverse video cursor code
X * added blank tiles for hidden tiles to stop cheating.
X */
X
X#ifndef lint
Xstatic char *rcs = "$header$ Copyright 1988 Mark Holm";
X#endif !lint
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/time.h>
X#include <sys/ioctl.h>
X#include <sys/file.h>
X#include <sun/fbio.h>
X#include <suntool/sunview.h>
X#include <suntool/panel.h>
X#include <suntool/canvas.h>
X#include <suntool/icon.h>
X#include <sunwindow/notify.h>
X#include <pixrect/pixrect.h>
X
X#include "mahjongg.h"
X
Xvoid die();
Xvoid build_image();
Xvoid place_tiles();
XPixrect *color_button();
X
X
X/* Black and white closed icon image */
X
Xstatic short icon_image[] = {
X#include "mahjongg.icon"
X};
XDEFINE_ICON_FROM_IMAGE(icon, icon_image); /* Black and white icon */
Xstruct icon *cicon; /* storage for color icon */
X
X/* externals */
X
Xextern void quit_proc();
Xextern void undo_proc();
Xextern void new_proc();
Xextern void again_proc();
Xextern void help_proc();
Xextern void board_num_proc();
Xextern void play_back_proc();
Xextern void play_event_proc();
X
Xextern short stick_image[];
Xextern int undo_count;
X
X/* overlap globals */
X
X
XFrame main_frame;
XPanel play_panel, message_panel;
XPanel_item TL_hundred;
XPanel_item TL_ten;
XPanel_item TL_one;
XPanel_item message;
XPanel_item tile[144];
XPanel_item tiles_left[3];
XCursor play_cursor;
Xboolean BandW = FALSE;
XTiles *board[144];
XSelected selected[2];
XSelected last_item;
Xint tile_count;
Xchar state[256];
X
X/* local globals */
X
XPixwin *frame_pw;
XPanel_item tile_message;
XPanel_item cp1;
XPanel_item cp2;
XPanel_item cp3;
XPanel_item cp4;
XPanel_item help;
XPanel_item again;
XPanel_item new;
XPanel_item quit;
XPanel_item undo;
XPanel_item board_num;
Xstruct timeval *tp;
Xstruct timezone *tz;
Xint seed;
X
X/* define color map */
X
X#include "color.h"
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{
X struct pixfont *panel_font;
X struct pixfont *dummy_font;
X int i;
X int middle;
X struct fbtype fb;
X int open_stat;
X
X /* determine type of frame buffer and set BandW accordingly */
X
X open_stat = open("/dev/fb", O_RDONLY);
X (void) ioctl(open_stat, FBIOGTYPE, &fb);
X
X if ( (fb.fb_type == FBTYPE_SUN1BW) ||
X (fb.fb_type == FBTYPE_SUN2BW) ||
X (fb.fb_type == FBTYPE_SUN3BW) ||
X (fb.fb_type == FBTYPE_SUN4BW) )
X BandW = TRUE;
X
X /* initialize random number generator seed */
X
X tp = (struct timeval *) malloc(sizeof(struct timeval));
X tz = (struct timezone *) malloc(sizeof(struct timezone));
X gettimeofday(tp, tz);
X (void) initstate((unsigned) (tp->tv_sec % 255), state, 256); /* initialize random state array */
X seed = RANDOM(20011);
X free(tp);
X free(tz);
X
X /* create main frame */
X
X main_frame = window_create(NULL, FRAME,
X FRAME_SHOW_LABEL, FALSE,
X FRAME_SUBWINDOWS_ADJUSTABLE, FALSE,
X FRAME_ICON, &icon,
X FRAME_ARGC_PTR_ARGV, &argc, argv,
X WIN_HEIGHT, FRAME_Y_MAX,
X WIN_WIDTH, FRAME_X_MAX,
X 0);
X
X /* parse arguments */
X for(argc--, argv++; argc > 0; argc--, argv++)
X if (argv[0][0] = '-')
X switch (argv[0][1]) {
X case 'c': /* force color */
X BandW = FALSE;
X break;
X case 'b': /* force black and white */
X BandW = TRUE;
X break;
X case 'n': /* set board number */
X if(argc-- == 0)
X die("Usage: mahjongg [-b] [-c] [-n #]\n", 0);
X argv++;
X sscanf(argv[0] , "%d", &seed);
X if (seed > 20011) {
X printf("Board numbers must be < 20011");
X seed %= 20011;
X }
X break;
X default:
X die("Usage: mahjongg [-b] [-c] [-n #]\n", 0);
X break;
X }
X else
X die("Usage: mahjongg [-b] [-c] [-n #]\n", 0);
X
X /* if color then apply color icon to window icon */
X
X if(!BandW) {
X cicon = (struct icon *) window_get(main_frame, FRAME_ICON);
X cicon->ic_mpr = &cicon_image;
X }
X
X /* get pixwin to apply color maps */
X
X frame_pw = (Pixwin *) window_get(main_frame, WIN_PIXWIN, 0);
X
X /* apply color maps to frame pixwin */
X
X pw_setcmsname(frame_pw, "mahjongg");
X pw_putcolormap(frame_pw, 0, MAX_COLORS+1, red, green, blue);
X if (BandW)
X pw_putcolormap(frame_pw, 0, 1, &(red[WHITE]), &(green[WHITE]), &(blue[WHITE]));
X
X /* set inheritable colors */
X
X window_set(main_frame, FRAME_INHERIT_COLORS, TRUE, 0);
X
X /* set up the panel on the right hand side */
X
X dummy_font = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.7");
X panel_font = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.b.14");
X message_panel = window_create(main_frame, PANEL,
X WIN_HEIGHT, MESS_Y_MAX,
X WIN_WIDTH, MESS_X_MAX,
X WIN_X, 0,
X WIN_Y, 0,
X WIN_FONT, dummy_font,
X 0);
X
X /* determine middle of panel */
X
X middle = (MESS_X_MAX / 2);
X
X /* create tile counters */
X
X TL_hundred = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_IMAGE,
X (BandW) ? &NUM1 : &cNUM1,
X PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_ITEM_X, X_LOC,
X 0);
X TL_ten = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_IMAGE,
X (BandW) ? &NUM4 : &cNUM4,
X PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_ITEM_X, X_LOC + W_BASE_TILE,
X 0);
X TL_one = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_IMAGE,
X (BandW) ? &NUM4 : &cNUM4,
X PANEL_ITEM_Y, ATTR_ROW(7),
X PANEL_ITEM_X, X_LOC + (W_BASE_TILE * 2),
X 0);
X
X /* create game label messages */
X
X cp1 = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, panel_font,
X PANEL_LABEL_STRING, "MAHJONGG",
X PANEL_ITEM_Y, ATTR_ROW(1) - 11,
X PANEL_ITEM_X, middle - 65,
X 0);
X cp2 = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, dummy_font,
X PANEL_LABEL_STRING, "Copyright 1988",
X PANEL_ITEM_Y, ATTR_ROW(2),
X PANEL_ITEM_X, middle - 70,
X 0);
X cp3 = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, dummy_font,
X PANEL_LABEL_STRING, "Mark A. Holm",
X PANEL_ITEM_Y, ATTR_ROW(3),
X PANEL_ITEM_X, middle - 65,
X 0);
X cp3 = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, dummy_font,
X PANEL_LABEL_STRING, "Exceptions",
X PANEL_ITEM_Y, ATTR_ROW(4),
X PANEL_ITEM_X, middle - 60,
X 0);
X tile_message = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, panel_font,
X PANEL_LABEL_STRING, "Tiles Remaining",
X PANEL_ITEM_Y, ATTR_ROW(5),
X PANEL_ITEM_X, X_LOC + 20,
X 0);
X
X /* create seed item */
X
X board_num = panel_create_item(message_panel, PANEL_TEXT,
X PANEL_LABEL_FONT, panel_font,
X PANEL_VALUE_FONT, panel_font,
X PANEL_LABEL_STRING, "Board Number : ",
X PANEL_VALUE, "",
X PANEL_ITEM_Y, ATTR_ROW(6),
X PANEL_ITEM_X, middle,
X PANEL_NOTIFY_PROC, board_num_proc,
X 0);
X
X /* create control buttons */
X
X help = panel_create_item(message_panel, PANEL_BUTTON,
X PANEL_ITEM_Y, ATTR_ROW(8),
X PANEL_ITEM_X, middle,
X PANEL_LABEL_IMAGE,
X color_button(panel_button_image(message_panel,
X "HELP",
X 6,
X panel_font),
X CYAN),
X PANEL_NOTIFY_PROC, help_proc,
X 0);
X
X again = panel_create_item(message_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X color_button(panel_button_image(message_panel,
X "AGAIN",
X 6,
X panel_font),
X YELLOW),
X PANEL_NOTIFY_PROC, again_proc,
X 0);
X
X new = panel_create_item(message_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X color_button(panel_button_image(message_panel,
X "NEW",
X 6,
X panel_font),
X GREEN),
X PANEL_NOTIFY_PROC, new_proc,
X 0);
X
X undo = panel_create_item(message_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X color_button(panel_button_image(message_panel,
X "UNDO",
X 6,
X panel_font),
X MAGENTA),
X PANEL_NOTIFY_PROC, undo_proc,
X PANEL_SHOW_ITEM, TRUE,
X 0);
X
X quit = panel_create_item(message_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X color_button(panel_button_image(message_panel,
X "QUIT",
X 6,
X panel_font),
X RED),
X PANEL_NOTIFY_PROC, quit_proc,
X 0);
X
X /* place conceled message */
X
X message = panel_create_item(message_panel, PANEL_MESSAGE,
X PANEL_LABEL_FONT, panel_font,
X PANEL_ITEM_Y, ATTR_ROW(10),
X PANEL_ITEM_X, middle,
X PANEL_LABEL_STRING, "",
X PANEL_SHOW_ITEM, FALSE,
X 0);
X
X /* create cursor for play panel*/
X
X play_cursor = cursor_create(CURSOR_IMAGE, &stick,
X CURSOR_XHOT, 8,
X CURSOR_YHOT, 8,
X 0);
X
X if (!BandW) {
X
X cursor_set(play_cursor, CURSOR_OP,
X (PIX_SRC^PIX_DST) | PIX_COLOR( YELLOW ),
X 0);
X }
X
X /* set up panel for the play */
X
X play_panel = window_create(main_frame, PANEL,
X WIN_CONSUME_PICK_EVENTS,
X WIN_NO_EVENTS, WIN_MOUSE_BUTTONS, WIN_UP_EVENTS, WIN_LEFT_KEYS, 0,
X WIN_HEIGHT, PLAY_Y_MAX,
X WIN_WIDTH, PLAY_X_MAX,
X WIN_X, 0,
X WIN_Y, MESS_Y_MAX + BORDER,
X WIN_CURSOR, play_cursor,
X PANEL_PAINT, PANEL_NONE,
X PANEL_BACKGROUND_PROC, play_back_proc,
X PANEL_EVENT_PROC, play_event_proc,
X CANVAS_RETAINED, TRUE,
X 0);
X
X window_set(message_panel, WIN_INPUT_DESIGNEE,
X window_get(play_panel, WIN_DEVICE_NUMBER),
X 0);
X
X /* build board image */
X
X build_image(FALSE);
X place_tiles(TRUE);
X
X /* start main processing */
X
X window_main_loop(main_frame);
X exit(0);
X}
X
X
X/* die because of some UNIX error */
Xvoid die(message, pperr)
Xchar *message;
Xint pperr;
X{
X fprintf(stderr, message);
X if (pperr)
X perror("mahjongg");
X exit(1);
X}
X
Xvoid place_tiles(newboard)
Xboolean newboard;
X
X{
X int i;
X int j;
X int k;
X int x_loc;
X int y_loc;
X
X /* check if not new and destroy existing panel buttons */
X
X if (!newboard)
X for(i = 0; i < 144; i++)
X panel_destroy_item(tile[i]);
X
X /* place tiles */
X
X /* row 1 level 1 */
X
X for(i = 0,
X x_loc = COL2;
X i < 12;
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW1,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 2 level 1 */
X
X for(x_loc = COL4,
X j = 0;
X j < 8;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW2,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 3 level 1 */
X
X for(x_loc = COL3,
X j = 0;
X j < 10;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW3,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 4 1/2 level 1 */
X
X /* Left */
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X COL1,
X PANEL_ITEM_Y,
X ROW4pt5,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X i++; /* increment tile counter */
X
X /* row 4 level 1 */
X
X for(x_loc = COL2,
X j = 0;
X j < 12;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW4,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 5 level 1 */
X
X for(x_loc = COL2,
X j = 0;
X j < 12;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW5,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X /* row 4 1/2 level 1 */
X
X /* Right */
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X COL14,
X PANEL_ITEM_Y,
X ROW4pt5,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X i++; /* increment tile counter */
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X COL15,
X PANEL_ITEM_Y,
X ROW4pt5,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X i++; /* increment tile counter */
X
X /* row 6 level 1 */
X
X for(x_loc = COL3,
X j = 0;
X j < 10;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW6,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 7 level 1 */
X
X for(x_loc = COL4,
X j = 0;
X j < 8;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW7,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* row 8 level 1 */
X
X for(j = 0,
X x_loc = COL2;
X j < 12;
X j++,
X i++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X ROW8,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* rows 1-6 level 2 */
X
X for(y_loc = ROW2 - B_TILE_SHADOW,
X j = 0;
X j < 6;
X j++,
X y_loc += H_BASE_TILE)
X
X for(x_loc = COL5 - S_TILE_SHADOW,
X k = 0;
X k < 6;
X i++,
X k++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X y_loc,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* rows 1-4 level 3 */
X
X for(y_loc = ROW3 - (B_TILE_SHADOW * 2),
X j = 0;
X j < 4;
X j++,
X y_loc += H_BASE_TILE)
X
X for(x_loc = COL6 - (S_TILE_SHADOW * 2),
X k = 0;
X k < 4;
X i++,
X k++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X (board[i]->top_free) ?
X board[i]->image :
X (BandW) ? &BLANK : &cBLANK,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X y_loc,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* rows 1-2 level 4 */
X
X for(y_loc = ROW4 - (B_TILE_SHADOW * 3),
X j = 0;
X j < 2;
X j++,
X y_loc += H_BASE_TILE)
X
X for(x_loc = COL7 - (S_TILE_SHADOW * 3),
X k = 0;
X k < 2;
X i++,
X k++,
X x_loc += W_BASE_TILE)
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X board[i]->image,
X PANEL_ITEM_X,
X x_loc,
X PANEL_ITEM_Y,
X y_loc,
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* Cap tile */
X
X tile[i] = panel_create_item(play_panel, PANEL_BUTTON,
X PANEL_LABEL_IMAGE,
X board[i]->image,
X PANEL_ITEM_X,
X COL7pt5 - (S_TILE_SHADOW * 4),
X PANEL_ITEM_Y,
X ROW4pt5 - (B_TILE_SHADOW * 4),
X PANEL_SHOW_ITEM,
X TRUE,
X PANEL_CLIENT_DATA,
X (caddr_t) board[i],
X 0);
X
X /* paint panel */
X
X panel_paint(play_panel, PANEL_NO_CLEAR);
X
X /* clear stand_by message and release input mask */
X
X panel_set(message, PANEL_SHOW_ITEM,
X FALSE,
X 0);
X
X window_set(message_panel, WIN_CONSUME_PICK_EVENTS,
X WIN_MOUSE_BUTTONS, 0,
X 0);
X window_set(message_panel, WIN_CONSUME_KBD_EVENT,
X WIN_ASCII_EVENTS, 0, 0);
X
X cursor_set(play_cursor, CURSOR_IMAGE, &stick, 0);
X window_set(play_panel, WIN_CURSOR, play_cursor, 0);
X
X}
X
Xvoid build_image(oldimage)
Xboolean oldimage;
X
X{
Xint i;
Xint j;
Xint pool[42];
Xboolean ok;
Xboolean dir;
Xchar seed_text[80];
X
X /* initialize selected structures */
X
X selected[0].filled = FALSE;
X selected[1].filled = FALSE;
X last_item.filled = FALSE;
X undo_count = -1;
X
X panel_set(message, PANEL_SHOW_ITEM,
X FALSE,
X 0);
X panel_set(TL_hundred, PANEL_LABEL_IMAGE,
X (BandW) ? &NUM1 : &cNUM1,
X PANEL_SHOW_ITEM,
X TRUE,
X 0);
X panel_set(TL_ten , PANEL_LABEL_IMAGE,
X (BandW) ? &NUM4 : &cNUM4,
X PANEL_SHOW_ITEM,
X TRUE,
X 0);
X panel_set(TL_one , PANEL_LABEL_IMAGE,
X (BandW) ? &NUM4 : &cNUM4,
X 0);
X
X /* display current seed in text item */
X
X sprintf(seed_text, "%d", seed);
X panel_set(board_num, PANEL_VALUE, seed_text, 0);
X
X /* show stand_by message while building image and grab all input */
X
X panel_set(message, PANEL_LABEL_STRING,
X "Building board. Please wait.",
X PANEL_SHOW_ITEM,
X TRUE, 0);
X
X window_set(message_panel, WIN_IGNORE_PICK_EVENTS,
X WIN_MOUSE_BUTTONS, 0, 0);
X window_set(message_panel, WIN_IGNORE_KBD_EVENT,
X WIN_ASCII_EVENTS, 0, 0);
X cursor_set(play_cursor, CURSOR_IMAGE, &wait, 0);
X window_set(play_panel, WIN_CURSOR, play_cursor, 0);
X
X /* initialize random number counter */
X
X (void) srandom(seed);
X
X tile_count = 144;
X
X /* initialize tile pool */
X for(i = 0; i < 34; i++) pool[i] = 4;
X for(; i < 42; i++) pool[i] = 1;
X
X /* assign values to each location. Board is built from upper left *
X * to lower right, bottom to top. Exception are left tile for row *
X * 4pt5 is before rows 4 and 5, and right tiles for row 4.5 are *
X * after rows 4 and 5 */
X
X for(j = 0; j < 144; j++) {
X if (board[j] == NULL) /* intialize array */
X board[j] = (Tiles *) malloc(sizeof(Tiles));
X
X if (!oldimage) { /* not repeating last board */
X
X /* Randomly seed index into pool. Randomly *
X * run up or down list until unused tile *
X * is found or end of list. If end of *
X * list reseed and run in opposite *
X * direction in list until unused tile is *
X * found. If beginning of list found, *
X * start over. */
X
X ok = FALSE;
X while (ok == FALSE) {
X i = RANDOM(41);
X /* Up, up, up! */
X dir = random()&01;
X while ((i < 42 || i >=0) && pool[i] == 0) (dir) ? i++ : i--;
X if (i == 42 || i < 0) { /* Thud! Reverse march! */
X i = RANDOM(41);
X while ((i < 42 || i >= 0) && pool[i] == 0) (dir) ? i-- : i++;
X }
X if (i == 42 || i < 0) continue; /* Missed! try again */
X pool[i]--;
X ok = TRUE;
X }
X
X /* all flowers and all seasons */
X
X board[j]->value = (i >= 34) ? ((i >= 38) ? 35 : 34) : i;
X switch(i) {
X
X case 0: board[j]->image = (BandW) ? &DOT1 : &cDOT1;
X break;
X case 1: board[j]->image = (BandW) ? &DOT2 : &cDOT2;
X break;
X case 2: board[j]->image = (BandW) ? &DOT3 : &cDOT3;
X break;
X case 3: board[j]->image = (BandW) ? &DOT4 : &cDOT4;
X break;
X case 4: board[j]->image = (BandW) ? &DOT5 : &cDOT5;
X break;
X case 5: board[j]->image = (BandW) ? &DOT6 : &cDOT6;
X break;
X case 6: board[j]->image = (BandW) ? &DOT7 : &cDOT7;
X break;
X case 7: board[j]->image = (BandW) ? &DOT8 : &cDOT8;
X break;
X case 8: board[j]->image = (BandW) ? &DOT9 : &cDOT9;
X break;
X case 9: board[j]->image = (BandW) ? &BAM1 : &cBAM1;
X break;
X case 10: board[j]->image = (BandW) ? &BAM2 : &cBAM2;
X break;
X case 11: board[j]->image = (BandW) ? &BAM3 : &cBAM3;
X break;
X case 12: board[j]->image = (BandW) ? &BAM4 : &cBAM4;
X break;
X case 13: board[j]->image = (BandW) ? &BAM5 : &cBAM5;
X break;
X case 14: board[j]->image = (BandW) ? &BAM6 : &cBAM6;
X break;
X case 15: board[j]->image = (BandW) ? &BAM7 : &cBAM7;
X break;
X case 16: board[j]->image = (BandW) ? &BAM8 : &cBAM8;
X break;
X case 17: board[j]->image = (BandW) ? &BAM9 : &cBAM9;
X break;
X case 18: board[j]->image = (BandW) ? &CHA1 : &cCHA1;
X break;
X case 19: board[j]->image = (BandW) ? &CHA2 : &cCHA2;
X break;
X case 20: board[j]->image = (BandW) ? &CHA3 : &cCHA3;
X break;
X case 21: board[j]->image = (BandW) ? &CHA4 : &cCHA4;
X break;
X case 22: board[j]->image = (BandW) ? &CHA5 : &cCHA5;
X break;
X case 23: board[j]->image = (BandW) ? &CHA6 : &cCHA6;
X break;
X case 24: board[j]->image = (BandW) ? &CHA7 : &cCHA7;
X break;
X case 25: board[j]->image = (BandW) ? &CHA8 : &cCHA8;
X break;
X case 26: board[j]->image = (BandW) ? &CHA9 : &cCHA9;
X break;
X case 27: board[j]->image = (BandW) ? &GRED : &cGRED;
X break;
X case 28: board[j]->image = (BandW) ? &REDD : &cREDD;
X break;
X case 29: board[j]->image = (BandW) ? &WHTD : &cWHTD;
X break;
X case 30: board[j]->image = (BandW) ? &EAST : &cEAST;
X break;
X case 31: board[j]->image = (BandW) ? &WEST : &cWEST;
X break;
X case 32: board[j]->image = (BandW) ? &SOUT : &cSOUT;
X break;
X case 33: board[j]->image = (BandW) ? &NORT : &cNORT;
X break;
X case 34: board[j]->image = (BandW) ? &AUT : &cAUT;
X break;
X case 35: board[j]->image = (BandW) ? &SUM : &cSUM;
X break;
X case 36: board[j]->image = (BandW) ? &SPR : &cSPR;
X break;
X case 37: board[j]->image = (BandW) ? &WIN : &cWIN;
X break;
X case 38: board[j]->image = (BandW) ? &ORC : &cORC;
X break;
X case 39: board[j]->image = (BandW) ? &MUM : &cMUM;
X break;
X case 40: board[j]->image = (BandW) ? &BAM : &cBAM;
X break;
X case 41: board[j]->image = (BandW) ? &PLM : &cPLM;
X break;
X }
X
X }
X /* establish default values */
X
X board[j]->left_free = FALSE;
X board[j]->right_free = FALSE;
X board[j]->top_free = TRUE;
X board[j]->left_next[0] = j - 1;
X board[j]->left_next[1] = 999;
X board[j]->right_next[0] = j + 1;
X board[j]->right_next[1] = 999;
X board[j]->covered[0] = 999;
X board[j]->covered[1] = 999;
X board[j]->covered[2] = 999;
X board[j]->covered[3] = 999;
X board[j]->removed = FALSE;
X
X /* setup special cases */
X
X switch (j) {
X case 139:
X case 141:
X board[j]->top_free = FALSE;
X case 0:
X case 12:
X case 20:
X case 30:
X case 57:
X case 67:
X case 75:
X case 87:
X case 93:
X case 99:
X case 105:
X case 111:
X case 117:
X case 123:
X case 127:
X case 131:
X case 135:
X board[j]->left_free = TRUE;
X board[j]->left_next[0] = 999;
X break;
X case 140:
X case 142:
X board[j]->top_free = FALSE;
X case 11:
X case 19:
X case 29:
X case 56:
X case 66:
X case 74:
X case 86:
X case 92:
X case 98:
X case 104:
X case 110:
X case 116:
X case 122:
X case 126:
X case 130:
X case 134:
X case 138:
X board[j]->right_free = TRUE;
X board[j]->right_next[0] = 999;
X break;
X case 143:
X board[j]->right_free = TRUE;
X board[j]->left_next[0] = 999;
X board[j]->left_free = TRUE;
X board[j]->right_next[0] = 999;
X board[j]->covered[0] = 139;
X board[j]->covered[1] = 140;
X board[j]->covered[2] = 141;
X board[j]->covered[3] = 142;
X break;
X case 42:
X board[j]->right_next[0] = 55;
X break;
X case 43:
X board[j]->left_next[0] = 30;
X break;
X case 55:
X board[j]->left_next[1] = 42;
X break;
X }
X
X }
X
X /* special case (did not fit in above) */
X
X board[30]->right_next[1] = 43;
X
X /* set top_free flags and covered pointers */
X
X for(i = 87, j = 13; i < 143; i++, j++) {
X board[i]->covered[0] = j;
X board[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/* This is the routine that returns the colored button image */
X
XPixrect *color_button(pr,color)
X struct pixrect *pr;
X int color;
X{
X struct pixrect *color_pr;
X
X if(pr == NULL)
X return(NULL);
X
X /* if running in b/w mode return same pixrect */
X if (BandW)
X return(pr);
X
X /* make new pixrect */
X color_pr = mem_create(pr->pr_size.x, pr->pr_size.y, 8);
X
X /* copy pr to color_pr with color added */
X pr_rop(color_pr, 0, 0, pr->pr_size.x, pr->pr_size.y,
X PIX_SRC | PIX_COLOR( color ),
X pr,0,0);
X
X return(color_pr);
X}
END_OF_mahjongg.c
if test 27074 -ne `wc -c <mahjongg.c`; then
echo shar: \"mahjongg.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test ! -d tiles ; then
echo shar: Creating directory \"tiles\"
mkdir tiles
fi
if test ! -d tiles/bandw ; then
echo shar: Creating directory \"tiles/bandw\"
mkdir tiles/bandw
fi
if test -f tiles/bandw/mahjongg.cursor -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"tiles/bandw/mahjongg.cursor\"
else
echo shar: Extracting \"tiles/bandw/mahjongg.cursor\" \(315 characters\)
sed "s/^X//" >tiles/bandw/mahjongg.cursor <<'END_OF_tiles/bandw/mahjongg.cursor'
X/* Format_version=1, Width=16, Height=16, Depth=1, Valid_bits_per_item=16
X * Copyright 1988, Mark Holm
X * Exceptions
X *
X * Permission is given to copy and distribute for non-profit purposes.
X *
X */
X 0xF800,0xFC00,0xC600,0xDB00,0xD980,0x66C0,0x3660,0x1830,
X 0x0C18,0x066C,0x0366,0x019B,0x00DB,0x0063,0x003F,0x001F
END_OF_tiles/bandw/mahjongg.cursor
if test 315 -ne `wc -c <tiles/bandw/mahjongg.cursor`; then
echo shar: \"tiles/bandw/mahjongg.cursor\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test ! -d tiles/rdrunner ; then
echo shar: Creating directory \"tiles/rdrunner\"
mkdir tiles/rdrunner
fi
echo shar: End of archive 1 \(of 38\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 38 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0