v02i021: Another puzzle program, Part01/01
Mike Wexler
mikew at wyse.wyse.com
Thu Nov 24 09:05:00 AEST 1988
Submitted-by: claus at athen.sp4.siemens.de (Clauss Gittinger)
Posting-number: Volume 2, Issue 21
Archive-name: xpuzzle/part01
#! /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 1)."
# Contents: README AUTHOR Imakefile Makefile icon.bit patchlevel.h
# piece0.bit piece1.bit piece2.bit piece3.bit xpuzzle.c xpuzzle.man
# Wrapped by mikew at wyse on Wed Nov 23 15:02:43 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(340 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
Xxpuzzle - another X-window V11 puzzle game
X
XThe goal of this game is to move down the largest piece to the bottom in
Xminimal number of movements. It is known that the puzzle can be solved in
X86 movements. To move a piece, point it by the mouse and press a button,
Xhold the button until you move the mouse to an adjacent empty
Xsquare.
END_OF_FILE
if test 340 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'AUTHOR' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'AUTHOR'\"
else
echo shar: Extracting \"'AUTHOR'\" \(1377 characters\)
sed "s/^X//" >'AUTHOR' <<'END_OF_FILE'
X(Message inbox:224)
XReturn-Path: sinix!athen!claus at unido
XReceived: from wyse by tarfoo.wyse.com (5.58/Wyse client/5-13-88)
X id AA00304; Tue, 22 Nov 88 16:40:48 PST
XReceived: by wyse.wyse.com (5.58/Wyse master/5-13-88)
X id AA20607; Tue, 22 Nov 88 16:40:12 PST
XReceived: from unido.UUCP by uunet.UU.NET (5.59/1.14) with UUCP
X id AA20417; Tue, 22 Nov 88 13:52:19 EST
XReceived: by unido.uucp via EUnet with uucp for uunet
X id AT12618; Tue, 22 Nov 88 19:43:43 +0100
XReceived: by athen.sp4.siemens.de
X at Tue, 22 Nov 88 18:11:48 +0100 (5.52/SIE-0.1)
XMessage-Id: <8811221711.AA29819 at athen.sp4.siemens.de>
XDate: Tue, 22 Nov 88 18:11:48 +0100
XFrom: "Claus Gittinger" <athen!claus at unido>
XTo: mikew at wyse.wyse.com
X
XHi Mike !!
XI've just got a mail from a guy, who wanted to compile my little
Xxpuzzle program which is on the R3 tape. He's got many undefined
Xsymbols, when linking the stuff together. When looking into the tape,
XI found, that there is a lot missing ..
XI don't know how, but the source on the tape seems to be the original
XsunView stuff - NOT the X11 version !!!
X(In my original posting, there where both versions - for comparison of the
X two window systems)
X
XHere is now the stuff, as its on our machine -- it should work under R[123].
XCould you please be so kind and put this into comp.sources.x [before
XI get hundreds of mails :-) ] - thank you.
X
X claus
X
END_OF_FILE
if test 1377 -ne `wc -c <'AUTHOR'`; then
echo shar: \"'AUTHOR'\" unpacked with wrong size!
fi
# end of 'AUTHOR'
fi
if test -f 'Imakefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Imakefile'\"
else
echo shar: Extracting \"'Imakefile'\" \(121 characters\)
sed "s/^X//" >'Imakefile' <<'END_OF_FILE'
X# @(#)Imakefile 1.1 88/05/31
XLOCAL_LIBRARIES = $(XLIB)
XSRCS = xpuzzle.c
XOBJS = xpuzzle.o
X
XComplexProgramTarget(xpuzzle)
END_OF_FILE
if test 121 -ne `wc -c <'Imakefile'`; then
echo shar: \"'Imakefile'\" unpacked with wrong size!
fi
# end of 'Imakefile'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(6444 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile generated by imake - do not edit!
X# $XConsortium: imake.c,v 1.37 88/10/08 20:08:30 jim Exp $
X#
X# The cpp used on this machine replaces all newlines and multiple tabs and
X# spaces in a macro expansion with a single space. Imake tries to compensate
X# for this, but is not always successful.
X#
X
X###########################################################################
X# X Window System Makefile generated from template file Imake.tmpl
X# $XConsortium: Imake.tmpl,v 1.91 88/10/23 22:37:10 jim Exp $
X#
X# Do not change the body of the imake template file. Server-specific
X# parameters may be set in the appropriate .macros file; site-specific
X# parameters (but shared by all servers) may be set in site.def. If you
X# make any changes, you'll need to rebuild the makefiles using
X# "make World" (at best) or "make Makefile; make Makefiles" (at least) in
X# the top level directory.
X#
X# If your C preprocessor doesn't define any unique symbols, you'll need
X# to set BOOTSTRAPCFLAGS when rebuilding imake (usually when doing
X# "make Makefile", "make Makefiles", or "make World").
X#
X# If you absolutely can't get imake to work, you'll need to set the
X# variables at the top of each Makefile as well as the dependencies at the
X# bottom (makedepend will do this automatically).
X#
X
X###########################################################################
X# platform-specific configuration parameters - edit Sun.macros to change
X
X# platform: $XConsortium: Sun.macros,v 1.52 88/10/23 11:00:55 jim Exp $
X# operating system: SunOS 3.4
X
XBOOTSTRAPCFLAGS =
X AS = as
X CC = cc
X CPP = /lib/cpp
X LD = ld
X LINT = lint
X INSTALL = install
X TAGS = ctags
X RM = rm -f
X MV = mv
X LN = ln -s
X RANLIB = ranlib
XRANLIBINSTFLAGS = -t
X AR = ar clq
X LS = ls
X LINTOPTS = -axz
X LINTLIBFLAG = -C
X MAKE = make
XSTD_CPP_DEFINES =
X STD_DEFINES =
X
X###########################################################################
X# site-specific configuration parameters - edit site.def to change
X
X# site: $XConsortium: site.def,v 1.16 88/10/12 10:30:24 jim Exp $
X
X###########################################################################
X# definitions common to all Makefiles - do not edit
X
X SHELL = /bin/sh
X
X DESTDIR = /global
X USRLIBDIR = $(DESTDIR)/lib
X BINDIR = $(DESTDIR)/bin/X11
X INCDIR = $(DESTDIR)/include
X ADMDIR = $(DESTDIR)/usr/adm
X LIBDIR = $(USRLIBDIR)/X11
X LINTLIBDIR = $(USRLIBDIR)/lint
X FONTDIR = $(LIBDIR)/fonts
X XINITDIR = $(LIBDIR)/xinit
X XDMDIR = $(LIBDIR)/xdm
X UWMDIR = $(LIBDIR)/uwm
X AWMDIR = $(LIBDIR)/awm
X TWMDIR = $(LIBDIR)/twm
X DTDIR = $(LIBDIR)/dt
X MANPATH = /usr/man
X MANSOURCEPATH = $(MANPATH)/man
X MANDIR = $(MANSOURCEPATH)n
X LIBMANDIR = $(MANSOURCEPATH)n3
X XAPPLOADDIR = $(LIBDIR)/app-defaults
X
X INSTBINFLAGS = -m 0755
X INSTUIDFLAGS = -m 4755
X INSTLIBFLAGS = -m 0664
X INSTINCFLAGS = -m 0444
X INSTMANFLAGS = -m 0444
X INSTAPPFLAGS = -m 0444
X INSTKMEMFLAGS = -m 4755
X FCFLAGS = -t
X CDEBUGFLAGS = -O
X
X PATHSEP = /
X DEPEND = $(DEPENDSRC)/makedepend
X IMAKE = $(BINDIR)/imake
X RGB = $(RGBSRC)/rgb
X FC = $(BDFTOSNFSRC)/bdftosnf
X MKFONTDIR = $(MKFONTDIRSRC)/mkfontdir
X MKDIRHIER = $(SCRIPTSSRC)/mkdirhier.sh
X
X CFLAGS = $(CDEBUGFLAGS) $(INCLUDES) $(STD_DEFINES) $(DEFINES)
X LINTFLAGS = $(LINTOPTS) $(INCLUDES) $(STD_DEFINES) $(DEFINES) -DLINT
X LDFLAGS = $(CDEBUGFLAGS) -L$(USRLIBDIR) $(SYS_LIBRARIES) $(SYSAUX_LIBRARIES)
X
X IRULESRC = $(LIBDIR)/imake.includes
X
X EXTENSIONLIB = $(USRLIBDIR)/libext.a
X XLIB = $(USRLIBDIR)/libX11.a
X XMULIB = $(USRLIBDIR)/libXmu.a
X OLDXLIB = $(USRLIBDIR)/liboldX.a
X XTOOLLIB = $(USRLIBDIR)/libXt.a
X XAWLIB = $(USRLIBDIR)/libXaw.a
X LINTXLIB = $(USRLIBDIR)/llib-lX11.ln
X LINTXMU = $(USRLIBDIR)/llib-lXmu.ln
X LINTXTOOL = $(USRLIBDIR)/llib-lXt.ln
X LINTXAW = $(USRLIBDIR)/llib-lXaw.ln
X INCLUDES = -I$(INCDIR)
X MACROFILE = Sun.macros
X ICONFIGFILES = $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/$(MACROFILE) $(IRULESRC)/site.def
X IMAKE_DEFINES =
X IMAKE_CMD = $(NEWTOP)$(IMAKE) -TImake.tmpl -I$(NEWTOP)$(IRULESRC) \
X -s Makefile $(IMAKE_DEFINES)
X RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a \
X .emacs_* tags TAGS make.log MakeOut
X
X###########################################################################
X# rules: $XConsortium: Imake.rules,v 1.71 88/10/23 22:46:34 jim Exp $
X
X###########################################################################
X# start of Imakefile
X
X# @(#)Imakefile 1.1 88/05/31
XLOCAL_LIBRARIES = $(XLIB)
XSRCS = xpuzzle.c
XOBJS = xpuzzle.o
X
X PROGRAM = xpuzzle
X
Xall:: xpuzzle
X
Xxpuzzle: $(OBJS) $(LOCAL_LIBRARIES)
X $(RM) $@
X $(CC) -o $@ $(OBJS) $(LOCAL_LIBRARIES) $(LDFLAGS) $(SYSLAST_LIBRARIES)
X
Xrelink::
X $(RM) $(PROGRAM)
X $(MAKE) $(MFLAGS) $(PROGRAM)
X
Xinstall:: xpuzzle
X $(INSTALL) -c $(INSTALLFLAGS) xpuzzle $(BINDIR)
X
Xinstall.man:: xpuzzle.man
X $(INSTALL) -c $(INSTMANFLAGS) xpuzzle.man $(MANDIR)/xpuzzle.n
X
Xdepend:: $(DEPEND)
X
Xdepend::
X $(DEPEND) -s "# DO NOT DELETE" -- $(CFLAGS) -- $(SRCS)
X
X$(DEPEND):
X @echo "making $@"; \
X cd $(DEPENDSRC); $(MAKE)
X
Xclean::
X $(RM) $(PROGRAM)
X
X###########################################################################
X# Imake.tmpl common rules for all Makefiles - do not edit
X
Xemptyrule::
X
Xclean::
X $(RM_CMD) \#*
X
XMakefile:: $(IMAKE)
X
XMakefile:: Imakefile \
X $(IRULESRC)/Imake.tmpl \
X $(IRULESRC)/Imake.rules \
X $(IRULESRC)/site.def \
X $(IRULESRC)/$(MACROFILE)
X - at if [ -f Makefile ]; then \
X echo "$(RM) Makefile.bak; $(MV) Makefile Makefile.bak"; \
X $(RM) Makefile.bak; $(MV) Makefile Makefile.bak; \
X else exit 0; fi
X $(IMAKE_CMD) -DTOPDIR=$(TOP)
X
X$(IMAKE):
X @echo "making $@"; \
X cd $(IMAKESRC); $(MAKE) BOOTSTRAPCFLAGS=$(BOOTSTRAPCFLAGS)
X
Xtags::
X $(TAGS) -w *.[ch]
X $(TAGS) -xw *.[ch] > TAGS
X
X###########################################################################
X# empty rules for directories that do not have SUBDIRS - do not edit
X
Xinstall::
X @echo "install done"
X
Xinstall.man::
X @echo "install.man done"
X
XMakefiles::
X
X###########################################################################
X# dependencies generated by makedepend
X
END_OF_FILE
if test 6444 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'icon.bit' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'icon.bit'\"
else
echo shar: Extracting \"'icon.bit'\" \(3213 characters\)
sed "s/^X//" >'icon.bit' <<'END_OF_FILE'
X#define icon_width 64
X#define icon_height 64
X
Xstatic char icon_bits[] = {
X 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0xff, 0x00, 0x00, 0xe0, 0x03, 0xc0,
X 0x03, 0xc0, 0xff, 0x01, 0x00, 0xf0, 0x07, 0xc0,
X 0x03, 0xe0, 0xc1, 0x03, 0x00, 0xf8, 0x0f, 0xc0,
X 0x03, 0x70, 0x00, 0x07, 0x00, 0xfc, 0x1f, 0xc0,
X 0x03, 0x18, 0x00, 0x0e, 0x00, 0xfc, 0x1f, 0xc0,
X 0x03, 0x1c, 0x00, 0x1c, 0x00, 0xfc, 0x1f, 0xc0,
X 0x03, 0x0c, 0x00, 0x18, 0x00, 0xfc, 0x1f, 0xc0,
X 0x03, 0x0e, 0x00, 0x38, 0x00, 0xfc, 0x1f, 0xc0,
X 0x03, 0x06, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0,
X 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0,
X 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0,
X 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x07, 0xc0,
X 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x07, 0xc0,
X 0x03, 0x00, 0x00, 0x38, 0x00, 0xf0, 0x07, 0xc0,
X 0x03, 0x00, 0x00, 0x18, 0x00, 0xf0, 0x07, 0xc0,
X 0x03, 0x00, 0x00, 0x1c, 0x00, 0xf0, 0x07, 0xc0,
X 0x03, 0x00, 0x00, 0x0e, 0x00, 0xf0, 0x03, 0xc0,
X 0x03, 0x00, 0x00, 0x07, 0x00, 0xf0, 0x03, 0xc0,
X 0x03, 0x00, 0xc0, 0x03, 0x00, 0xf0, 0x03, 0xc0,
X 0x03, 0x00, 0xfc, 0x01, 0x00, 0xf0, 0x03, 0xc0,
X 0x03, 0x00, 0x7c, 0x00, 0x00, 0xf0, 0x03, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0,
X 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x1c, 0x00, 0x00, 0xe0, 0x00, 0xc0,
X 0x03, 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x03, 0xc0,
X 0x03, 0x00, 0x7f, 0x00, 0x00, 0xf8, 0x03, 0xc0,
X 0x03, 0x00, 0x7f, 0x00, 0x00, 0xfc, 0x07, 0xc0,
X 0x03, 0x00, 0x7f, 0x00, 0x00, 0xfc, 0x07, 0xc0,
X 0x03, 0x00, 0x3e, 0x00, 0x00, 0xfc, 0x07, 0xc0,
X 0x03, 0x00, 0x1c, 0x00, 0x00, 0xf8, 0x03, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0,
X 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
X 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
X} ;
END_OF_FILE
if test 3213 -ne `wc -c <'icon.bit'`; then
echo shar: \"'icon.bit'\" unpacked with wrong size!
fi
# end of 'icon.bit'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(22 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X#define PATCHLEVEL 0
X
END_OF_FILE
if test 22 -ne `wc -c <'patchlevel.h'`; then
echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'piece0.bit' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'piece0.bit'\"
else
echo shar: Extracting \"'piece0.bit'\" \(884 characters\)
sed "s/^X//" >'piece0.bit' <<'END_OF_FILE'
X#define piece0_width 32
X#define piece0_height 32
X
Xstatic char piece0_bits[] = {
X 0x00, 0x00, 0x00, 0x00,
X 0xfe, 0xff, 0xff, 0x7f,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xde, 0xdd, 0xdd, 0x5d,
X 0x76, 0x77, 0x77, 0x77,
X 0xee, 0xee, 0xee, 0x6e,
X 0xba, 0xbb, 0xbb, 0x7b,
X 0xfe, 0xff, 0xff, 0x7f,
X 0x00, 0x00, 0x00, 0x00,
X} ;
END_OF_FILE
if test 884 -ne `wc -c <'piece0.bit'`; then
echo shar: \"'piece0.bit'\" unpacked with wrong size!
fi
# end of 'piece0.bit'
fi
if test -f 'piece1.bit' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'piece1.bit'\"
else
echo shar: Extracting \"'piece1.bit'\" \(1684 characters\)
sed "s/^X//" >'piece1.bit' <<'END_OF_FILE'
X#define piece1_width 32
X#define piece1_height 64
X
Xstatic char piece1_bits[] = {
X 0x00, 0x00, 0x00, 0x00,
X 0xfe, 0xff, 0xff, 0x7f,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0x6a,
X 0xfe, 0xff, 0xff, 0x7f,
X 0x00, 0x00, 0x00, 0x00,
X} ;
END_OF_FILE
if test 1684 -ne `wc -c <'piece1.bit'`; then
echo shar: \"'piece1.bit'\" unpacked with wrong size!
fi
# end of 'piece1.bit'
fi
if test -f 'piece2.bit' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'piece2.bit'\"
else
echo shar: Extracting \"'piece2.bit'\" \(1652 characters\)
sed "s/^X//" >'piece2.bit' <<'END_OF_FILE'
X#define piece2_width 64
X#define piece2_height 32
X
Xstatic char piece2_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
X 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a,
X 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X} ;
END_OF_FILE
if test 1652 -ne `wc -c <'piece2.bit'`; then
echo shar: \"'piece2.bit'\" unpacked with wrong size!
fi
# end of 'piece2.bit'
fi
if test -f 'piece3.bit' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'piece3.bit'\"
else
echo shar: Extracting \"'piece3.bit'\" \(3219 characters\)
sed "s/^X//" >'piece3.bit' <<'END_OF_FILE'
X#define piece3_width 64
X#define piece3_height 64
X
Xstatic char piece3_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62,
X 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48,
X 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51,
X 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
X 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
X} ;
END_OF_FILE
if test 3219 -ne `wc -c <'piece3.bit'`; then
echo shar: \"'piece3.bit'\" unpacked with wrong size!
fi
# end of 'piece3.bit'
fi
if test -f 'xpuzzle.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xpuzzle.c'\"
else
echo shar: Extracting \"'xpuzzle.c'\" \(12861 characters\)
sed "s/^X//" >'xpuzzle.c' <<'END_OF_FILE'
Xstatic char SCCSID[] = "@(#)xpuzzle.c 1.1 88/05/31";
X/*
X * Copyright 1988 by Siemens
X * All Rights Reserved
X *
X * Permission to use, copy, modify and distribute this software is
X * hereby granted, provided that this copyright notice appear in all
X * copies and that the copyright notice appear in supporting
X * documentation.
X *
X * written Feb 1988 by claus gittinger
X * based on puzzletool by Jiang-Hsing Chu (jchu at mimsy.umd.edu)
X *
X * Email: ...!decvax!unido!athen!claus
X *
X */
X
X#include "X11/Xlib.h"
X#include <stdio.h>
X
X#include <X11/Xatom.h>
X#include <X11/Xlib.h>
X#include <X11/Xutil.h>
X#include <X11/cursorfont.h>
X
X/*
X * you may have to modify this for your system
X */
X#ifndef ATT
X# define strchr index
X#endif
X
X#define PIECE_COLS 4 /* No of columns of pieces. */
X#define PIECE_H 32 /* Number of pixels for height. */
X#define PIECE_ROWS 5 /* No of rows of pieces. */
X#define PIECE_W 32 /* No of pixels for width. */
X#define DISPLAY 30 /* Calculators numerical display. */
X
X#define MAXLINE 80 /* Length of character strings. */
X#define TOTAL_HEIGHT (PIECE_ROWS * PIECE_H)
X#define TOTAL_WIDTH (PIECE_COLS * PIECE_W)
X
XDisplay *dpy;
Xint screen;
XGC gc;
X
XWindow rootWindow, puzzleWindow;
Xlong FgPixel, BgPixel, BdPixel;
X
X#include "piece0.bit"
X#include "piece1.bit"
X#include "piece2.bit"
X#include "piece3.bit"
X#include "icon.bit"
X
Xint ncolumn,column ; /* Column number of key pressed. */
Xint m,n ; /* mouse and index */
Xint nrow,row ; /* Row number of key pressed. */
Xint step=0;
X
X#define NPIECES 10
X
X#define EMPTY -1
X#define BORDER -2
X#define SMALLPIECE 0
X#define SMALLPIECE1 (SMALLPIECE+0)
X#define SMALLPIECE2 (SMALLPIECE+1)
X#define SMALLPIECE3 (SMALLPIECE+2)
X#define SMALLPIECE4 (SMALLPIECE+3)
X#define VLONGPIECE 4
X#define VLONGPIECE1 (VLONGPIECE+0)
X#define VLONGPIECE2 (VLONGPIECE+1)
X#define VLONGPIECE3 (VLONGPIECE+2)
X#define VLONGPIECE4 (VLONGPIECE+3)
X#define HLONGPIECE 8
X#define BIGPIECE 9
X
Xint board[PIECE_ROWS+2][PIECE_COLS+2]= {
X {BORDER, BORDER, BORDER, BORDER, BORDER, BORDER},
X {BORDER, VLONGPIECE1, BIGPIECE, BIGPIECE, VLONGPIECE2, BORDER},
X {BORDER, VLONGPIECE1, BIGPIECE, BIGPIECE, VLONGPIECE2, BORDER},
X {BORDER, VLONGPIECE3, HLONGPIECE, HLONGPIECE, VLONGPIECE4, BORDER},
X {BORDER, VLONGPIECE3, SMALLPIECE1, SMALLPIECE2, VLONGPIECE4, BORDER},
X {BORDER, EMPTY, SMALLPIECE3, SMALLPIECE4, EMPTY, BORDER},
X {BORDER, BORDER, BORDER, BORDER, BORDER, BORDER}
X};
X
X#define empty(row, col) (board[row][col]==EMPTY)
X
XPixmap piece0_bitmap = NULL,
X piece1_bitmap = NULL,
X piece2_bitmap = NULL,
X piece3_bitmap = NULL;
X
Xstruct pieceStruct {
X int pType;
X int pX, pY;
X int pWidth, pHeight;
X Pixmap pPixmap;
X} pieces[NPIECES] = {
X {SMALLPIECE, 2, 4, 1, 1, NULL},
X {SMALLPIECE, 3, 4, 1, 1, NULL},
X {SMALLPIECE, 2, 5, 1, 1, NULL},
X {SMALLPIECE, 3, 5, 1, 1, NULL},
X {VLONGPIECE, 1, 1, 1, 2, NULL},
X {VLONGPIECE, 4, 1, 1, 2, NULL},
X {VLONGPIECE, 1, 3, 1, 2, NULL},
X {VLONGPIECE, 4, 3, 1, 2, NULL},
X {HLONGPIECE, 2, 3, 2, 1, NULL},
X {BIGPIECE, 2, 1, 2, 2, NULL}
X};
X
X#define pieceType(p) (pieces[p].pType)
X#define pieceX(p) ((pieces[p].pX-1)*PIECE_W)
X#define pieceY(p) ((pieces[p].pY-1)*PIECE_H)
X#define pieceWidth(p) (pieces[p].pWidth*PIECE_W)
X#define pieceHeight(p) (pieces[p].pHeight*PIECE_H)
X#define piecePixmap(p) (pieces[p].pPixmap)
X
Xmain(argc,argv)
Xint argc ;
Xchar *argv[] ;
X{
X int i;
X Visual visual;
X XGCValues xgcv;
X XSetWindowAttributes xswa;
X XSizeHints sizehints;
X char *ProgName, *server, *geom, *borderColor;
X char *foreGround, *backGround;
X int borderWidth = 1;
X
X server = "";
X geom = "";
X borderColor = "black";
X foreGround = "black";
X backGround = "white";
X
X ProgName = argv[0];
X
X /********************************/
X /** parse command line options **/
X /********************************/
X
X for (i=1; i<argc; i++) {
X if (argv[i][0] == '=')
X geom = argv[i];
X else if (strchr(argv[i],':') != NULL)
X server = argv[i];
X else if (strcmp(argv[i], "-fg") == 0)
X foreGround = argv[++i];
X else if (strcmp(argv[i], "-bg") == 0)
X backGround = argv[++i];
X else if (strcmp(argv[i], "-bd") == 0)
X borderColor = argv[++i];
X else if (strcmp(argv[i], "-bw") == 0)
X sscanf(argv[++i], "%d", &borderWidth);
X else
X usage(ProgName);
X }
X
X dpy = XOpenDisplay(server);
X if (dpy == NULL) {
X fprintf(stderr, "can't open display \"%s\"\n",server);
X exit(1);
X }
X screen = DefaultScreen(dpy);
X
X FgPixel = requestColor(foreGround);
X BgPixel = requestColor(backGround);
X BdPixel = requestColor(borderColor);
X
X /*************************************/
X /** configure the window size hints **/
X /*************************************/
X
X sizehints.flags = PMinSize | PMaxSize | PPosition | PSize;
X sizehints.min_width = TOTAL_WIDTH;
X sizehints.min_height = TOTAL_HEIGHT;
X sizehints.max_width = TOTAL_WIDTH;
X sizehints.max_height = TOTAL_HEIGHT;
X sizehints.width = TOTAL_WIDTH;
X sizehints.height = TOTAL_HEIGHT;
X sizehints.x = 100;
X sizehints.y = 300;
X
X if (geom && strlen(geom)) {
X int width, height, flags;
X
X flags = XParseGeometry(geom, &sizehints.x, &sizehints.y,
X &width, &height);
X if (flags & (XValue | YValue))
X sizehints.flags |= USPosition;
X }
X
X /*******************************************************************/
X /** create the puzzle main window and set its standard properties **/
X /*******************************************************************/
X
X xswa.event_mask = ExposureMask | ButtonPressMask |
X ButtonReleaseMask | KeyPressMask;
X xswa.background_pixel = BgPixel;
X xswa.border_pixel = BdPixel;
X xswa.cursor = XCreateFontCursor(dpy, XC_hand1);
X
X visual.visualid = CopyFromParent;
X
X rootWindow = RootWindow(dpy, screen);
X
X puzzleWindow = XCreateWindow(dpy, rootWindow,
X sizehints.x, sizehints.y,
X sizehints.width, sizehints.height,
X borderWidth,
X DefaultDepth(dpy,screen),
X InputOutput,
X &visual,
X CWCursor | CWEventMask | CWBackPixel | CWBorderPixel,
X &xswa);
X
X /*******************************************************************/
X /** define its name and icon-bitmap **/
X /*******************************************************************/
X
X XSetStandardProperties(dpy, puzzleWindow, "puzzle","Puzzle",
X XCreateBitmapFromData(dpy, rootWindow,
X icon_bits,
X icon_width, icon_height),
X argv, argc, &sizehints);
X
X XMapWindow(dpy, puzzleWindow);
X
X xgcv.foreground = FgPixel;
X xgcv.background = BgPixel;
X xgcv.line_width = 0;
X gc = XCreateGC(dpy, puzzleWindow,
X GCForeground|GCBackground|GCLineWidth,
X &xgcv);
X
X make_bitmaps();
X eventloop();
X exit(0) ;
X}
X
Xmake_bitmaps() {
X int p;
X
X piece0_bitmap = XCreateBitmapFromData(dpy, rootWindow,
X piece0_bits, piece0_width, piece0_height);
X piece1_bitmap = XCreateBitmapFromData(dpy, rootWindow,
X piece1_bits, piece1_width, piece1_height);
X piece2_bitmap = XCreateBitmapFromData(dpy, rootWindow,
X piece2_bits, piece2_width, piece2_height);
X piece3_bitmap = XCreateBitmapFromData(dpy, rootWindow,
X piece3_bits, piece3_width, piece3_height);
X
X if (piece0_bitmap==NULL || piece1_bitmap==NULL ||
X piece2_bitmap==NULL ||
X piece3_bitmap==NULL) {
X fprintf(stderr, "cannot allocated bitmaps\n");
X finish();
X }
X
X for (p=SMALLPIECE1; p <= SMALLPIECE4; p++)
X pieces[p].pPixmap = piece0_bitmap;
X
X for (p=VLONGPIECE1; p <= VLONGPIECE4; p++)
X pieces[p].pPixmap = piece1_bitmap;
X
X pieces[HLONGPIECE].pPixmap = piece2_bitmap;
X pieces[BIGPIECE].pPixmap = piece3_bitmap;
X}
X
Xfinish() {
X if (piece0_bitmap != NULL)
X XFreePixmap(dpy, piece0_bitmap);
X if (piece1_bitmap != NULL)
X XFreePixmap(dpy, piece1_bitmap);
X if (piece2_bitmap != NULL)
X XFreePixmap(dpy, piece2_bitmap);
X if (piece3_bitmap != NULL)
X XFreePixmap(dpy, piece3_bitmap);
X exit(1);
X}
X
Xusage(name)
Xchar *name;
X{
X fprintf(stderr, "usage: %s [geometry] [display]\n", name);
X fprintf(stderr, " [-fg color] [-bg color]\n");
X fprintf(stderr, " [-bd color] [-bw number]\n");
X exit(1);
X}
X
XrequestColor(name)
Xchar *name;
X{
X XColor truecolor, availcolor;
X
X if (XAllocNamedColor(dpy,
X DefaultColormap(dpy, DefaultScreen(dpy)),
X name, &availcolor, &truecolor) == 0) {
X fprintf(stderr, "Color '%s' unknown\n", name);
X exit(1);
X }
X if (truecolor.red != availcolor.red ||
X truecolor.green != availcolor.green ||
X truecolor.blue != availcolor.blue) {
X fprintf(stderr, "Warning: %s color bay be wrong\n", name);
X }
X
X return availcolor.pixel;
X}
X
Xeventloop() {
X XEvent event;
X XExposeEvent *ee = (XExposeEvent *)&event;
X XKeyPressedEvent *ke = (XKeyPressedEvent *)&event;
X XButtonPressedEvent *be = (XButtonPressedEvent *)&event;
X char keybuff[10];
X int nchar;
X
X while(1) {
X XNextEvent(dpy, &event);
X switch(event.type) {
X case KeyPress:
X nchar = XLookupString(ke, keybuff, 1, NULL, NULL);
X
X if (nchar > 0) {
X switch (keybuff[0]) {
X case 'q':
X case 'Q':
X finish();
X }
X }
X break;
X
X case ButtonPress:
X column = be->x / PIECE_W ;
X row = be->y / PIECE_H ;
X n = board[row+1][column+1] ;
X m=0;
X break;
X
X case ButtonRelease:
X if (n>=0) {
X ncolumn = be->x / PIECE_W;
X nrow = be->y / PIECE_H ;
X if (! empty(nrow+1, ncolumn+1)) break;
X if (ncolumn > column) m=0;
X if (nrow<row) m=1;
X if (ncolumn<column) m=2;
X if (nrow>row) m=3;
X do_move();
X }
X break;
X
X case Expose:
X if (! ee->count)
X repaint();
X break;
X
X default:
X break;
X }
X }
X}
X
Xrepaint() {
X int p;
X
X XClearWindow(dpy, puzzleWindow);
X for(p=0; p < NPIECES; p++)
X XCopyPlane(dpy, piecePixmap(p), puzzleWindow, gc,
X 0, 0, pieceWidth(p), pieceHeight(p),
X pieceX(p), pieceY(p), 1) ;
X}
X
Xdo_move() {
X int ox,oy,nx,ny;
X
X ox=pieces[n].pX;
X oy=pieces[n].pY;
X switch(pieceType(n)){
X case SMALLPIECE:
X switch(m){
X case 0:
X if (empty(ny=oy, nx=ox+1)) break;
X return;
X case 1:
X if (empty(ny=oy-1, nx=ox)) break;
X return;
X case 2:
X if (empty(ny=oy, nx=ox-1)) break;
X return;
X case 3:
X if (empty(ny=oy+1, nx=ox)) break;
X return;
X }
X break;
X
X case VLONGPIECE:
X switch(m){
X case 0:
X if (empty(oy, ox+1) && empty(oy+1, ox+1)) {
X nx=ox+1; ny=oy;
X break;
X }
X return;
X case 1:
X if (empty(oy-1, ox)) {
X nx=ox; ny=oy-1;
X break;
X }
X return;
X case 2:
X if (empty(oy, ox-1) && empty(oy+1, ox-1)) {
X nx=ox-1; ny=oy;
X break;
X }
X return;
X case 3:
X if (empty(oy+2, ox)) {
X nx=ox; ny=oy+1;
X break;
X }
X return;
X }
X break;
X
X case HLONGPIECE:
X switch(m){
X case 0:
X if (empty(oy, ox+2)) {
X nx=ox+1; ny=oy;
X break;
X }
X return;
X case 1:
X if (empty(oy-1, ox) && empty(oy-1, ox+1)) {
X nx=ox; ny=oy-1;
X break;
X }
X return;
X case 2:
X if (empty(oy, ox-1)) {
X nx=ox-1; ny=oy;
X break;
X }
X return;
X case 3:
X if (empty(oy+1, ox) && empty(oy+1, ox+1)) {
X nx=ox; ny=oy+1;
X break;
X }
X return;
X }
X break;
X
X case BIGPIECE:
X switch(m){
X case 0:
X if (empty(oy, ox+2) && empty(oy+1, ox+2)) {
X nx=ox+1; ny=oy;
X break;
X }
X return;
X case 1:
X if (empty(oy-1, ox) && empty(oy-1, ox+1)) {
X nx=ox; ny=oy-1;
X break;
X }
X return;
X case 2:
X if (empty(oy, ox-1) && empty(oy+1, ox-1)) {
X nx=ox-1; ny=oy;
X break;
X }
X return;
X case 3:
X if (empty(oy+2, ox) && empty(oy+2, ox+1)) {
X nx=ox; ny=oy+1;
X break;
X }
X return;
X }
X break;
X }
X
X#ifdef LATER
X {
X char display[MAXLINE]; /* Current number of moves display. */
X
X sprintf(display, "%d", ++step);
X XDrawImageString(dpy, displayWindow, gc,
X 0, 0, display, strlen(display));
X }
X#endif LATER
X
X pieces[n].pX=nx; /* move the piece */
X pieces[n].pY=ny;
X
X XClearArea(dpy, puzzleWindow,
X (ox-1)*PIECE_W, (oy-1)*PIECE_H,
X pieceWidth(n), pieceHeight(n), 0);
X
X switch(pieceType(n)){
X case SMALLPIECE:
X board[oy][ox]= EMPTY;
X board[ny][nx]= n;
X break;
X
X case VLONGPIECE:
X board[oy][ox]=board[oy+1][ox]= EMPTY;
X board[ny][nx]=board[ny+1][nx]=n;
X break;
X
X case HLONGPIECE:
X board[oy][ox]=board[oy][ox+1]= EMPTY;
X board[ny][nx]=board[ny][nx+1]=n;
X break;
X
X case BIGPIECE:
X board[oy][ox]=board[oy][ox+1]=board[oy+1][ox]=board[oy+1][ox+1]= EMPTY;
X board[ny][nx]=board[ny][nx+1]=board[ny+1][nx]=board[ny+1][nx+1]=n;
X break;
X }
X XCopyPlane(dpy, piecePixmap(n), puzzleWindow, gc,
X 0, 0, pieceWidth(n), pieceHeight(n),
X pieceX(n), pieceY(n), 1) ;
X}
END_OF_FILE
if test 12861 -ne `wc -c <'xpuzzle.c'`; then
echo shar: \"'xpuzzle.c'\" unpacked with wrong size!
fi
# end of 'xpuzzle.c'
fi
if test -f 'xpuzzle.man' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'xpuzzle.man'\"
else
echo shar: Extracting \"'xpuzzle.man'\" \(1004 characters\)
sed "s/^X//" >'xpuzzle.man' <<'END_OF_FILE'
X.TH XPUZZLE 6 "February 1987"
X.UC 4
X.SH NAME
Xxpuzzle \- another X-window V11 puzzle game
X.SH SYNOPSIS
X.B xpuzzle
X[
X.B options
X]
X.SH DESCRIPTION
XThe goal of this game is to move down the largest piece to the bottom in
Xminimal number of movements. It is known that the puzzle can be solved in
X86 movements. To move a piece, point it by the mouse and press a button,
Xhold the button until you move the mouse to an adjacent empty
Xsquare.
X.br
XIf you want to quit, press 'q' or 'Q' on the keyboard, while the cursor is
Xin the puzzle window.
X
XThe following options are valid:
X.PP
X.TP 8
X.B -fg color
Xas usual - change foreground color
X.TP 8
X.B -bg color
Xas usual - change background color
X.TP 8
X.B -bd color
Xas usual - change border color
X.TP 8
X.B -bw number
Xas usual - change border width
X.TP 8
X.B host:display
XName of the display you want the puzzle to run on.
X.SH AUTHORS
X.PP
XJiang-Hsing Chu (jchu at mimsy.umd.edu) original game for suntools
X.PP
XClaus Gittinger (..!decvax!unido!sinix!claus) X11 version
END_OF_FILE
if test 1004 -ne `wc -c <'xpuzzle.man'`; then
echo shar: \"'xpuzzle.man'\" unpacked with wrong size!
fi
# end of 'xpuzzle.man'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have the archive.
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
--
Mike Wexler(wyse!mikew) Phone: (408)433-1000 x1330
Moderator of comp.sources.x
More information about the Comp.sources.x
mailing list