claus@athen.UUCP ("Claus Gittinger") (03/19/88)
very sorry - last mail had a wrong xpuzzle.c (old one with one line "include defs.h" too many in it); here is the right one ..... Thanks again Claus Another puzzle for X11 ... ------------- cut here ------------------------------- #/bin/sh #This is a shar file. To use: # 1. Remove everything before the /bin/sh line # 2. Execute with /bin/sh (not csh) to extract the files: # Imakefile # Makefile.sun # README # icon.bit # piece0.bit # piece1.bit # piece2.bit # piece3.bit # puzzletool.c # puzzletool.h # sunBMconv # sunBMconv.l # xpuzzle.c # xpuzzle.man file="${0}" echo extracting Imakefile 1>&2 cat >Imakefile << 'EnD of Imakefile' LOCAL_LIBRARIES = $(XLIB) SRCS = xpuzzle.c OBJS = xpuzzle.o ComplexProgramTarget(xpuzzle) sunBMconv: sunBMconv.l att make sunBMconv.o rm sunBMconv.c att cc -o sunBMconv sunBMconv.o -ll EnD of Imakefile echo extracting Makefile.sun 1>&2 cat >Makefile.sun << 'EnD of Makefile.sun' puzzletool: puzzletool.o cc -g -o puzzletool puzzletool.o -lsuntool -lsunwindow -lpixrect puzzletool.o: puzzletool.c puzzletool.h EnD of Makefile.sun echo extracting README 1>&2 cat >README << 'EnD of README' This game originates by Jiang-Hsing Chu, who has made it awailable to the net a few weeks ago - The original code (puzzletool / Makefile.sun) was written to run under suntools - The new code (*.bit, xpuzzle.c / Imakefile) compiles and runs under X11R1 (it has not been tested under X11R2) For those who like to compare the code of the two window systems, the original code is still in this distribution and should still be compilable for suntools To compile for suntools, use Makefile.sun; to compile under X11R1 (X11R2 not tested) use the Imakefile to create a Makefile and make it ... Have fun ..... Claus Gittinger Software Consultant Siemens Dep D-St-Sp-4 Charles-de-Gaullestr. 2a 8000 Munich/Neuperlach West Germany ..!decvax!unido!sinix!claus The rest of this text is the original README ... The goal of this game is to move down the largest piece to the bottom in minimal number of movements. It is known that the puzzle can be solved in 86 movements. To move a piece, point it by the mouse and press the left button, hold the left button until you move the mouse to an adjacent empty square. Use the middle button to close the frame into the icon format. If you want to quit, press the right button. The game works on SUN workstation only. It is tested in SUN 3/50. Some ideas on setting up the interface were borrowed from the calctool program by Rich Burridge. Have fun. Jiang-Hsing Chu jchu@mimsy.umd.edu EnD of README echo extracting icon.bit 1>&2 cat >icon.bit << 'EnD of icon.bit' #define icon_width 64 #define icon_height 64 static char icon_bits[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0xff, 0x00, 0x00, 0xe0, 0x03, 0xc0, 0x03, 0xc0, 0xff, 0x01, 0x00, 0xf0, 0x07, 0xc0, 0x03, 0xe0, 0xc1, 0x03, 0x00, 0xf8, 0x0f, 0xc0, 0x03, 0x70, 0x00, 0x07, 0x00, 0xfc, 0x1f, 0xc0, 0x03, 0x18, 0x00, 0x0e, 0x00, 0xfc, 0x1f, 0xc0, 0x03, 0x1c, 0x00, 0x1c, 0x00, 0xfc, 0x1f, 0xc0, 0x03, 0x0c, 0x00, 0x18, 0x00, 0xfc, 0x1f, 0xc0, 0x03, 0x0e, 0x00, 0x38, 0x00, 0xfc, 0x1f, 0xc0, 0x03, 0x06, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0, 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0, 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x0f, 0xc0, 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x30, 0x00, 0xf8, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x38, 0x00, 0xf0, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x18, 0x00, 0xf0, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x1c, 0x00, 0xf0, 0x07, 0xc0, 0x03, 0x00, 0x00, 0x0e, 0x00, 0xf0, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x07, 0x00, 0xf0, 0x03, 0xc0, 0x03, 0x00, 0xc0, 0x03, 0x00, 0xf0, 0x03, 0xc0, 0x03, 0x00, 0xfc, 0x01, 0x00, 0xf0, 0x03, 0xc0, 0x03, 0x00, 0x7c, 0x00, 0x00, 0xf0, 0x03, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x01, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0xc0, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0, 0x03, 0x00, 0x0c, 0x00, 0x00, 0x40, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x1c, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x03, 0x00, 0x3e, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0x00, 0x7f, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0x00, 0x7f, 0x00, 0x00, 0xfc, 0x07, 0xc0, 0x03, 0x00, 0x7f, 0x00, 0x00, 0xfc, 0x07, 0xc0, 0x03, 0x00, 0x3e, 0x00, 0x00, 0xfc, 0x07, 0xc0, 0x03, 0x00, 0x1c, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x03, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } ; EnD of icon.bit echo extracting piece0.bit 1>&2 cat >piece0.bit << 'EnD of piece0.bit' #define piece0_width 32 #define piece0_height 32 static char piece0_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xde, 0xdd, 0xdd, 0x5d, 0x76, 0x77, 0x77, 0x77, 0xee, 0xee, 0xee, 0x6e, 0xba, 0xbb, 0xbb, 0x7b, 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, } ; EnD of piece0.bit echo extracting piece1.bit 1>&2 cat >piece1.bit << 'EnD of piece1.bit' #define piece1_width 32 #define piece1_height 64 static char piece1_bits[] = { 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0x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, } ; EnD of piece1.bit echo extracting piece2.bit 1>&2 cat >piece2.bit << 'EnD of piece2.bit' #define piece2_width 64 #define piece2_height 32 static char piece2_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0x6a, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, } ; EnD of piece2.bit echo extracting piece3.bit 1>&2 cat >piece3.bit << 'EnD of piece3.bit' #define piece3_width 64 #define piece3_height 64 static char piece3_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x62, 0x8a, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x48, 0x12, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x51, 0x46, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } ; EnD of piece3.bit echo extracting puzzletool.c 1>&2 cat >puzzletool.c << 'EnD of puzzletool.c' #include "puzzletool.h" void canvas_proc() ; Canvas canvas, rcanvas ; Cursor main_cursor ; Event event ; Frame frame ; Icon puzzletool_icon ; Panel panel ; Panel_item display_item ; struct Pixfont *nfont ; Pixwin *cpw ; short piece0_image[] = { /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0x0000,0x0000,0x0000,0x0000,0x7FFF,0xFFFE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7BBB,0xBBBA,0x0000,0x0000,0x6EEE,0xEEEE,0x0000,0x0000, 0x7777,0x7776,0x0000,0x0000,0x5DDD,0xDDDE,0x0000,0x0000, 0x7FFF,0xFFFE,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 } ; mpr_static(piece0_pr,64,64,1,piece0_image) ; short piece1_image[] = { /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0x0000,0x0000,0x0000,0x0000,0x7FFF,0xFFFE,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x6AAA,0xAAAA,0x0000,0x0000,0x5555,0x5556,0x0000,0x0000, 0x7FFF,0xFFFE,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 } ; mpr_static(piece1_pr,64,64,1,piece1_image) ; short piece2_image[] = { /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0x0000,0x0000,0x0000,0x0000,0x7FFF,0xFFFF,0xFFFF,0xFFFE, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x6AAA,0xAAAA,0xAAAA,0xAAAA,0x5555,0x5555,0x5555,0x5556, 0x7FFF,0xFFFF,0xFFFF,0xFFFE,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 } ; mpr_static(piece2_pr,64,64,1,piece2_image) ; short piece3_image[] = { /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0x0000,0x0000,0x0000,0x0000,0x7FFF,0xFFFF,0xFFFF,0xFFFE, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x4444,0x4444,0x4444,0x4446,0x5111,0x1111,0x1111,0x1112, 0x4888,0x8888,0x8888,0x888A,0x6222,0x2222,0x2222,0x2222, 0x7FFF,0xFFFF,0xFFFF,0xFFFE,0x0000,0x0000,0x0000,0x0000 } ; mpr_static(piece3_pr,64,64,1,piece3_image) ; short icon_image[] = { /* Format_version=1, Width=64, Height=64, Depth=1, Valid_bits_per_item=16 */ 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0xFF00,0x0007,0xC003,0xC003,0xFF80,0x000F,0xE003, 0xC007,0x83C0,0x001F,0xF003,0xC00E,0x00E0,0x003F,0xF803, 0xC018,0x0070,0x003F,0xF803,0xC038,0x0038,0x003F,0xF803, 0xC030,0x0018,0x003F,0xF803,0xC070,0x001C,0x003F,0xF803, 0xC060,0x000C,0x001F,0xF003,0xC000,0x000C,0x001F,0xF003, 0xC000,0x000C,0x001F,0xF003,0xC000,0x000C,0x001F,0xE003, 0xC000,0x000C,0x001F,0xE003,0xC000,0x001C,0x000F,0xE003, 0xC000,0x0018,0x000F,0xE003,0xC000,0x0038,0x000F,0xE003, 0xC000,0x0070,0x000F,0xC003,0xC000,0x00E0,0x000F,0xC003, 0xC000,0x03C0,0x000F,0xC003,0xC000,0x3F80,0x000F,0xC003, 0xC000,0x3E00,0x000F,0xC003,0xC000,0x3000,0x0007,0x8003, 0xC000,0x3000,0x0007,0x8003,0xC000,0x3000,0x0007,0x8003, 0xC000,0x3000,0x0007,0x8003,0xC000,0x3000,0x0007,0x8003, 0xC000,0x3000,0x0007,0x0003,0xC000,0x3000,0x0007,0x0003, 0xC000,0x3000,0x0007,0x0003,0xC000,0x3000,0x0003,0x0003, 0xC000,0x3000,0x0003,0x0003,0xC000,0x3000,0x0002,0x0003, 0xC000,0x3000,0x0002,0x0003,0xC000,0x3000,0x0002,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x3800,0x0007,0x0003, 0xC000,0x7C00,0x001F,0xC003,0xC000,0xFE00,0x001F,0xC003, 0xC000,0xFE00,0x003F,0xE003,0xC000,0xFE00,0x003F,0xE003, 0xC000,0x7C00,0x003F,0xE003,0xC000,0x3800,0x001F,0xC003, 0xC000,0x0000,0x001F,0xC003,0xC000,0x0000,0x0007,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xC000,0x0000,0x0000,0x0003,0xC000,0x0000,0x0000,0x0003, 0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF,0xFFFF } ; mpr_static(icon_pixrect,64,64,1,icon_image) ; int ncolumn,column ; /* Column number of key pressed. */ int m,n ; /* mouse and index */ int nrow,row ; /* Row number of key pressed. */ int step=0; int board[7][6]= { {-2,-2,-2,-2,-2,-2}, {-2,4,9,9,5,-2}, {-2,4,9,9,5,-2}, {-2,6,8,8,7,-2}, {-2,6,0,1,7,-2}, {-2,-1,2,3,-1,-2}, {-2,-2,-2,-2,-2,-2} }; int pieces[10][5] = { {0,2,4,1,1}, {0,3,4,1,1}, {0,2,5,1,1}, {0,3,5,1,1}, {1,1,1,1,2}, {1,4,1,1,2}, {1,1,3,1,2}, {1,4,3,1,2}, {2,2,3,2,1},{3,2,1,2,2} } ; char display[MAXLINE] ; /* Current calculator display. */ main(argc,argv) int argc ; char *argv[] ; { nfont = pf_open(NORMALFONT) ; /* Open normal sized font. */ puzzletool_icon = icon_create(ICON_WIDTH,64, ICON_IMAGE,&icon_pixrect, 0) ; frame = window_create((Window) 0, FRAME, FRAME_ICON, puzzletool_icon, FRAME_SHOW_LABEL, FALSE, FRAME_SUBWINDOWS_ADJUSTABLE, FALSE, FRAME_NO_CONFIRM, FALSE, WIN_TOP_MARGIN, DISPLAY, WIN_ROW_HEIGHT, PIECE_H, WIN_COLUMN_WIDTH, PIECE_W, WIN_ROWS, PIECE_ROWS, WIN_COLUMNS, PIECE_COLS, FRAME_ARGS, argc,argv, 0) ; panel = window_create(frame, PANEL, WIN_CONSUME_KBD_EVENTS, WIN_ASCII_EVENTS, 0, WIN_HEIGHT, DISPLAY, 0) ; canvas = window_create(frame,CANVAS, WIN_BELOW,panel, WIN_WIDTH,TOTAL_WIDTH, WIN_HEIGHT,TOTAL_HEIGHT, WIN_FONT,nfont, WIN_EVENT_PROC,canvas_proc, 0) ; WINDOW_SET(canvas,WIN_CONSUME_KBD_EVENT,WIN_ASCII_EVENTS,0) ; display_item = panel_create_item(panel,PANEL_MESSAGE, PANEL_LABEL_X,10, PANEL_LABEL_Y,DISPLAY-15, PANEL_LABEL_FONT,nfont, PANEL_LABEL_STRING,"", 0) ; cpw = canvas_pixwin(canvas) ; main_cursor = window_get(canvas,WIN_CURSOR) ; make_canvas() ; /* Draw the calculators pieces. */ window_fit(frame) ; window_main_loop(frame) ; exit(0) ; } /*ARGSUSED*/ static void canvas_proc(win,event,arg) Canvas win ; Event *event ; caddr_t arg ; { if (event_is_button(event) && event_is_down(event)) { switch (event_id(event)) { case MS_LEFT : column = event_x(event) / PIECE_W ; row = event_y(event) / PIECE_H ; n = board[row+1][column+1] ; m=0; return; case MS_MIDDLE : WINDOW_SET(frame,FRAME_CLOSED,TRUE,0); return; case MS_RIGHT : WINDOW_DESTROY(frame); default: return ; } } if (event_is_button(event) && event_is_up(event) && n>=0) { switch (event_id(event)) { case MS_LEFT : ncolumn = event_x(event) / PIECE_W; nrow = event_y(event) / PIECE_H ; if(board[nrow+1][ncolumn+1]!=-1)return ; if(ncolumn>column) m=0; if(nrow<row)m=1; if(ncolumn<column) m=2; if(nrow>row)m=3; do_move(); case MS_MIDDLE : case MS_RIGHT : default: return ; } } return ; } display_test(display) /* Output result to calculator display. */ char display[MAXLINE]; { PANEL_SET(display_item,PANEL_LABEL_STRING,display,0) ; } make_canvas() { int n,x ; char pstr[10] ; pw_writebackground(cpw,0,0,TOTAL_WIDTH,TOTAL_HEIGHT,PIX_CLR) ; for(n=0;n<4;++n) pw_write(cpw,(pieces[n][PX]-1)*PIECE_W, (pieces[n][PY]-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece0_pr,0,0) ; for(n=4;n<8;++n) pw_write(cpw,(pieces[n][PX]-1)*PIECE_W, (pieces[n][PY]-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece1_pr,0,0) ; n=8; pw_write(cpw,(pieces[n][PX]-1)*PIECE_W, (pieces[n][PY]-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece2_pr,0,0) ; n=9; pw_write(cpw,(pieces[n][PX]-1)*PIECE_W, (pieces[n][PY]-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece3_pr,0,0) ; } do_move() { int ox,oy,nx,ny; ox=pieces[n][PX]; oy=pieces[n][PY]; switch(n){ case 0: case 1: case 2: case 3: switch(m){ case 0: if(board[ny=oy][nx=ox+1]==-1)break; return; case 1: if(board[ny=oy-1][nx=ox]==-1)break; return; case 2: if(board[ny=oy][nx=ox-1]==-1)break; return; case 3: if(board[ny=oy+1][nx=ox]==-1)break; return; } break; case 4: case 5: case 6: case 7: switch(m){ case 0: if(board[oy][ox+1]==-1&&board[oy+1][ox+1]==-1){nx=ox+1;ny=oy;break;} return; case 1: if(board[oy-1][ox]==-1){nx=ox;ny=oy-1;break;} return; case 2: if(board[oy][ox-1]==-1&&board[oy+1][ox-1]==-1){nx=ox-1;ny=oy;break;} return; case 3: if(board[oy+2][ox]==-1){nx=ox;ny=oy+1;break;} return; } break; case 8: switch(m){ case 0: if(board[oy][ox+2]==-1){nx=ox+1;ny=oy;break;} return; case 1: if(board[oy-1][ox]==-1&&board[oy-1][ox+1]==-1){nx=ox;ny=oy-1;break;} return; case 2: if(board[oy][ox-1]==-1){nx=ox-1;ny=oy;break;} return; case 3: if(board[oy+1][ox]==-1&&board[oy+1][ox+1]==-1){nx=ox;ny=oy+1;break;} return; } break; case 9: switch(m){ case 0: if(board[oy][ox+2]==-1&&board[oy+1][ox+2]==-1){nx=ox+1;ny=oy;break;} return; case 1: if(board[oy-1][ox]==-1&&board[oy-1][ox+1]==-1){nx=ox;ny=oy-1;break;} return; case 2: if(board[oy][ox-1]==-1&&board[oy+1][ox-1]==-1){nx=ox-1;ny=oy;break;} return; case 3: if(board[oy+2][ox]==-1&&board[oy+2][ox+1]==-1){nx=ox;ny=oy+1;break;} return; } break; } itos(++step,display); display_test(display); pieces[n][PX]=nx;pieces[n][PY]=ny; switch(n){ case 0: case 1: case 2: case 3: board[oy][ox]= -1; board[ny][nx]=n; pw_writebackground(cpw,(ox-1)*PIECE_W,(oy-1)*PIECE_H,pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_CLR); pw_write(cpw,(nx-1)*PIECE_W, (ny-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece0_pr,0,0) ; break; case 4: case 5: case 6: case 7: board[oy][ox]=board[oy+1][ox]= -1; board[ny][nx]=board[ny+1][nx]=n; pw_writebackground(cpw,(ox-1)*PIECE_W,(oy-1)*PIECE_H,pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_CLR); pw_write(cpw,(nx-1)*PIECE_W, (ny-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece1_pr,0,0) ; break; case 8: board[oy][ox]=board[oy][ox+1]= -1; board[ny][nx]=board[ny][nx+1]=n; pw_writebackground(cpw,(ox-1)*PIECE_W,(oy-1)*PIECE_H,pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_CLR); pw_write(cpw,(nx-1)*PIECE_W, (ny-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece2_pr,0,0) ; break; case 9: board[oy][ox]=board[oy][ox+1]=board[oy+1][ox]=board[oy+1][ox+1]= -1; board[ny][nx]=board[ny][nx+1]=board[ny+1][nx]=board[ny+1][nx+1]=n; pw_writebackground(cpw,(ox-1)*PIECE_W,(oy-1)*PIECE_H,pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_CLR); pw_write(cpw,(nx-1)*PIECE_W, (ny-1)*PIECE_H, pieces[n][PDX]*PIECE_W,pieces[n][PDY]*PIECE_H,PIX_SRC,&piece3_pr,0,0) ; break; } } itos(i,c) int i; char *c; { int j; char t; c[0]='\0'; for(j=1;i>0;j++){ c[j]=i%10+'0'; i/=10; } for(i=0;i<j/2;++i){ t=c[i]; c[i]=c[j-1-i]; c[j-1-i]=t; } } EnD of puzzletool.c echo extracting puzzletool.h 1>&2 cat >puzzletool.h << 'EnD of puzzletool.h' #include <stdio.h> #include <strings.h> #include <ctype.h> #include <suntool/sunview.h> #include <suntool/canvas.h> #include <suntool/panel.h> char *sprintf() ; #define FGETS (void) fgets /* To make lint happy. */ #define FPRINTF (void) fprintf #define IOCTL (void) ioctl #define PANEL_SET (void) panel_set #define READ (void) read #define SPRINTF (void) sprintf #define SSCANF (void) sscanf #define STRCAT (void) strcat #define STRCPY (void) strcpy #define STRNCAT (void) strncat #define STRNCPY (void) strncpy #define WINDOW_DESTROY (void) window_destroy #define WINDOW_READ_EVENT (void) window_read_event #define WINDOW_SET (void) window_set #define NORMALFONT "/usr/lib/fonts/fixedwidthfonts/screen.r.12" #define PIECE_COLS 4 /* No of columns of pieces. */ #define PIECE_H 32 /* Number of pixels for height. */ #define PIECE_ROWS 5 /* No of rows of pieces. */ #define PIECE_W 32 /* No of pixels for width. */ #define DISPLAY 30 /* Calculators numerical display. */ #define EQUAL !strcmp /* For character comparisons. */ #define MAXLINE 80 /* Length of character strings. */ #define TOTAL_HEIGHT (PIECE_ROWS * PIECE_H) #define TOTAL_WIDTH (PIECE_COLS * PIECE_W) #define PTYPE 0 #define PX 1 #define PY 2 #define PDX 3 #define PDY 4 EnD of puzzletool.h echo extracting sunBMconv 1>&2 cat >sunBMconv << 'EnD of sunBMconv' j^RP^Pd^Nh8 _j ^F^[Ftl^O@hN&DELxN&^At&^Hhj^WFlgUDELDELbk^B@^Os^_8j DELDELbd^Z^HC!^LWy'PDELDEL`T(^Z^Y^W~^D|^_@| ^C^F'PDELDEL`T ^By'PDELDELpPPDELDELb`Z^U^OWDELDELb`^WPDELDELb`N^\Flj:^O^WDELDEL`$^_^PDELDEL`$z^SWVDELDEL`$^B@^F^P^W^Fhj^U^O^PDELDEL`$^D^W^PDELDEL`$^DN^XFDELh^WFhl^WFlDELDELq^X& DELDELq^X^Z^Q^OPDELDELb\^WVDELDELq^Xdj ^WVDELDELq^Xd^_Gd^Z_@`j ^WVDELDELq^X`^O@p^W@p^WF`x^TBxDEL^W.t'PDELDEL`T(z DELDELq^X^Z^H^OWDELDELb\^OPDELDELb`^WPDELDELb`^TRDELDELq^XDELj^AN^O2N^\h^AN# ^L'`PDELDELaNW^A^W^C|j^A/j^Ab'PDELDEL`T(Z^AW'PDELDEL`T#(N? ^B'hPDELDEL`T^W^FtW^A^W@x'h(^C(W^A.DELDELbHJ DELDELq^X^Z^H^OWDELDELb\^OPDELDELb`^WPDELDELb`^TRDELDELq^XDELj^A^L^O2N^\h^AN# ^L'`PDELDELaNW^A^W^C|j DELDELq^X^Z^H^OWDELDELb\^OPDELDELb`^WPDELDELb`^TRDELDELq^XDELj ^PWy'PDELDEL`T(^Z=f^OGp^W@pN^\FDELDELq^X& DELDELq^X^Z^H^OWDELDELb\^OPDELDELb`^WPDELDELb`^TRDELDELq^XDELj^Ej<ij^A^N^OGp^W@p\@^A^_p DELDELq^X^Z^H^OWDELDELb\^OPDELDELb`^WPDELDELb`^TRDELDELq^XDELNc^VDELDELtH^WpWE^H^B^A"^_8^_ ^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^B*7^[9^B,7[:^B^A27[^N^BK7[^Q^Bt7[^P^B~7[^T^B^A7[^Y^B :^['^P:^[4+:^[/-:[2<:[&<:^[C?:^[Q^BE: echo extracting sunBMconv.l 1>&2 cat >sunBMconv.l << 'EnD of sunBMconv.l' %{ %} HEXDIGIT [0-9a-fA-F] HEX 0x{HEXDIGIT}{HEXDIGIT} %% {HEX} { int oldBit, newBit; int oldVal, newVal; int n; sscanf(yytext+2, "%x", &oldVal); for (n=0, newVal=0, oldBit=0x80, newBit=0x01; n<8; n++, oldBit>>=1, newBit<<=1) if (oldVal & oldBit) newVal |= newBit; printf("0x%02x", newVal); } . ECHO; \n ECHO; %% EnD of sunBMconv.l echo extracting xpuzzle.c 1>&2 cat >xpuzzle.c << 'EnD of xpuzzle.c' /* * Copyright 1988 by Siemens * All Rights Reserved * * Permission to use, copy, modify and distribute this software is * hereby granted, provided that this copyright notice appear in all * copies and that the copyright notice appear in supporting * documentation. * * written Feb 1988 by claus gittinger * based on puzzletool by Jiang-Hsing Chu (jchu@mimsy.umd.edu) * * Email: ...!decvax!unido!athen!claus * */ #include "X11/Xlib.h" #include <stdio.h> #include <X11/Xatom.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> /* * you may have to modify this for your system */ #ifndef ATT # define strchr index #endif #define PIECE_COLS 4 /* No of columns of pieces. */ #define PIECE_H 32 /* Number of pixels for height. */ #define PIECE_ROWS 5 /* No of rows of pieces. */ #define PIECE_W 32 /* No of pixels for width. */ #define DISPLAY 30 /* Calculators numerical display. */ #define MAXLINE 80 /* Length of character strings. */ #define TOTAL_HEIGHT (PIECE_ROWS * PIECE_H) #define TOTAL_WIDTH (PIECE_COLS * PIECE_W) Display *dpy; int screen; GC gc; Window rootWindow, puzzleWindow; long FgPixel, BgPixel, BdPixel; #include "piece0.bit" #include "piece1.bit" #include "piece2.bit" #include "piece3.bit" #include "icon.bit" int ncolumn,column ; /* Column number of key pressed. */ int m,n ; /* mouse and index */ int nrow,row ; /* Row number of key pressed. */ int step=0; #define NPIECES 10 #define EMPTY -1 #define BORDER -2 #define SMALLPIECE 0 #define SMALLPIECE1 (SMALLPIECE+0) #define SMALLPIECE2 (SMALLPIECE+1) #define SMALLPIECE3 (SMALLPIECE+2) #define SMALLPIECE4 (SMALLPIECE+3) #define VLONGPIECE 4 #define VLONGPIECE1 (VLONGPIECE+0) #define VLONGPIECE2 (VLONGPIECE+1) #define VLONGPIECE3 (VLONGPIECE+2) #define VLONGPIECE4 (VLONGPIECE+3) #define HLONGPIECE 8 #define BIGPIECE 9 int board[PIECE_ROWS+2][PIECE_COLS+2]= { {BORDER, BORDER, BORDER, BORDER, BORDER, BORDER}, {BORDER, VLONGPIECE1, BIGPIECE, BIGPIECE, VLONGPIECE2, BORDER}, {BORDER, VLONGPIECE1, BIGPIECE, BIGPIECE, VLONGPIECE2, BORDER}, {BORDER, VLONGPIECE3, HLONGPIECE, HLONGPIECE, VLONGPIECE4, BORDER}, {BORDER, VLONGPIECE3, SMALLPIECE1, SMALLPIECE2, VLONGPIECE4, BORDER}, {BORDER, EMPTY, SMALLPIECE3, SMALLPIECE4, EMPTY, BORDER}, {BORDER, BORDER, BORDER, BORDER, BORDER, BORDER} }; #define empty(row, col) (board[row][col]==EMPTY) Pixmap piece0_bitmap = NULL, piece1_bitmap = NULL, piece2_bitmap = NULL, piece3_bitmap = NULL; struct pieceStruct { int pType; int pX, pY; int pWidth, pHeight; Pixmap pPixmap; } pieces[NPIECES] = { {SMALLPIECE, 2, 4, 1, 1, NULL}, {SMALLPIECE, 3, 4, 1, 1, NULL}, {SMALLPIECE, 2, 5, 1, 1, NULL}, {SMALLPIECE, 3, 5, 1, 1, NULL}, {VLONGPIECE, 1, 1, 1, 2, NULL}, {VLONGPIECE, 4, 1, 1, 2, NULL}, {VLONGPIECE, 1, 3, 1, 2, NULL}, {VLONGPIECE, 4, 3, 1, 2, NULL}, {HLONGPIECE, 2, 3, 2, 1, NULL}, {BIGPIECE, 2, 1, 2, 2, NULL} }; #define pieceType(p) (pieces[p].pType) #define pieceX(p) ((pieces[p].pX-1)*PIECE_W) #define pieceY(p) ((pieces[p].pY-1)*PIECE_H) #define pieceWidth(p) (pieces[p].pWidth*PIECE_W) #define pieceHeight(p) (pieces[p].pHeight*PIECE_H) #define piecePixmap(p) (pieces[p].pPixmap) main(argc,argv) int argc ; char *argv[] ; { int i; Visual visual; XGCValues xgcv; XSetWindowAttributes xswa; XSizeHints sizehints; char *ProgName, *server, *geom, *borderColor; char *foreGround, *backGround; int borderWidth = 1; server = ""; geom = ""; borderColor = "black"; foreGround = "black"; backGround = "white"; ProgName = argv[0]; /********************************/ /** parse command line options **/ /********************************/ for (i=1; i<argc; i++) { if (argv[i][0] == '=') geom = argv[i]; else if (strchr(argv[i],':') != NULL) server = argv[i]; else if (strcmp(argv[i], "-fg") == 0) foreGround = argv[++i]; else if (strcmp(argv[i], "-bg") == 0) backGround = argv[++i]; else if (strcmp(argv[i], "-bd") == 0) borderColor = argv[++i]; else if (strcmp(argv[i], "-bw") == 0) sscanf(argv[++i], "%d", &borderWidth); else usage(ProgName); } dpy = XOpenDisplay(server); if (dpy == NULL) { fprintf(stderr, "can't open display \"%s\"\n",server); exit(1); } screen = DefaultScreen(dpy); FgPixel = requestColor(foreGround); BgPixel = requestColor(backGround); BdPixel = requestColor(borderColor); /*************************************/ /** configure the window size hints **/ /*************************************/ sizehints.flags = PMinSize | PMaxSize | PPosition | PSize; sizehints.min_width = TOTAL_WIDTH; sizehints.min_height = TOTAL_HEIGHT; sizehints.max_width = TOTAL_WIDTH; sizehints.max_height = TOTAL_HEIGHT; sizehints.width = TOTAL_WIDTH; sizehints.height = TOTAL_HEIGHT; sizehints.x = 100; sizehints.y = 300; if (strlen(geom)) { int width, height, flags; flags = XParseGeometry(geom, &sizehints.x, &sizehints.y, &width, &height); if (flags & (XValue | YValue)) sizehints.flags |= USPosition; } /*******************************************************************/ /** create the puzzle main window and set its standard properties **/ /*******************************************************************/ xswa.event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | KeyPressMask; xswa.background_pixel = BgPixel; xswa.border_pixel = BdPixel; xswa.cursor = XCreateFontCursor(dpy, XC_hand1); visual.visualid = CopyFromParent; rootWindow = RootWindow(dpy, screen); puzzleWindow = XCreateWindow(dpy, rootWindow, sizehints.x, sizehints.y, sizehints.width, sizehints.height, borderWidth, DefaultDepth(dpy,screen), InputOutput, &visual, CWCursor | CWEventMask | CWBackPixel | CWBorderPixel, &xswa); /*******************************************************************/ /** define its name and icon-bitmap **/ /*******************************************************************/ XSetStandardProperties(dpy, puzzleWindow, "puzzle","Puzzle", XCreateBitmapFromData(dpy, rootWindow, icon_bits, icon_width, icon_height), argv, argc, &sizehints); XMapWindow(dpy, puzzleWindow); xgcv.foreground = FgPixel; xgcv.background = BgPixel; xgcv.line_width = 0; gc = XCreateGC(dpy, puzzleWindow, GCForeground|GCBackground|GCLineWidth, &xgcv); make_bitmaps(); eventloop(); exit(0) ; } make_bitmaps() { int p; piece0_bitmap = XCreateBitmapFromData(dpy, rootWindow, piece0_bits, piece0_width, piece0_height); piece1_bitmap = XCreateBitmapFromData(dpy, rootWindow, piece1_bits, piece1_width, piece1_height); piece2_bitmap = XCreateBitmapFromData(dpy, rootWindow, piece2_bits, piece2_width, piece2_height); piece3_bitmap = XCreateBitmapFromData(dpy, rootWindow, piece3_bits, piece3_width, piece3_height); if (piece0_bitmap==NULL || piece1_bitmap==NULL || piece2_bitmap==NULL || piece3_bitmap==NULL) { fprintf(stderr, "cannot allocated bitmaps\n"); finish(); } for (p=SMALLPIECE1; p <= SMALLPIECE4; p++) pieces[p].pPixmap = piece0_bitmap; for (p=VLONGPIECE1; p <= VLONGPIECE4; p++) pieces[p].pPixmap = piece1_bitmap; pieces[HLONGPIECE].pPixmap = piece2_bitmap; pieces[BIGPIECE].pPixmap = piece3_bitmap; } finish() { if (piece0_bitmap != NULL) XFreePixmap(dpy, piece0_bitmap); if (piece1_bitmap != NULL) XFreePixmap(dpy, piece1_bitmap); if (piece2_bitmap != NULL) XFreePixmap(dpy, piece2_bitmap); if (piece3_bitmap != NULL) XFreePixmap(dpy, piece3_bitmap); exit(1); } usage(name) char *name; { fprintf(stderr, "usage: %s [geometry] [display]\n", name); fprintf(stderr, " [-fg color] [-bg color]\n"); fprintf(stderr, " [-bd color] [-bw number]\n"); exit(1); } requestColor(name) char *name; { XColor truecolor, availcolor; if (XAllocNamedColor(dpy, DefaultColormap(dpy, DefaultScreen(dpy)), name, &availcolor, &truecolor) == 0) { fprintf(stderr, "Color '%s' unknown\n", name); exit(1); } if (truecolor.red != availcolor.red || truecolor.green != availcolor.green || truecolor.blue != availcolor.blue) { fprintf(stderr, "Warning: %s color bay be wrong\n", name); } return availcolor.pixel; } eventloop() { XEvent event; XExposeEvent *ee = (XExposeEvent *)&event; XKeyPressedEvent *ke = (XKeyPressedEvent *)&event; XButtonPressedEvent *be = (XButtonPressedEvent *)&event; char keybuff[10]; int nchar; while(1) { XNextEvent(dpy, &event); switch(event.type) { case KeyPress: nchar = XLookupString(ke, keybuff, 1, NULL, NULL); if (nchar > 0) { switch (keybuff[0]) { case 'q': case 'Q': finish(); } } break; case ButtonPress: column = be->x / PIECE_W ; row = be->y / PIECE_H ; n = board[row+1][column+1] ; m=0; break; case ButtonRelease: if (n>=0) { ncolumn = be->x / PIECE_W; nrow = be->y / PIECE_H ; if (! empty(nrow+1, ncolumn+1)) break; if (ncolumn > column) m=0; if (nrow<row) m=1; if (ncolumn<column) m=2; if (nrow>row) m=3; do_move(); } break; case Expose: if (! ee->count) repaint(); break; default: break; } } } repaint() { int p; XClearWindow(dpy, puzzleWindow); for(p=0; p < NPIECES; p++) XCopyPlane(dpy, piecePixmap(p), puzzleWindow, gc, 0, 0, pieceWidth(p), pieceHeight(p), pieceX(p), pieceY(p), 1) ; } do_move() { int ox,oy,nx,ny; ox=pieces[n].pX; oy=pieces[n].pY; switch(pieceType(n)){ case SMALLPIECE: switch(m){ case 0: if (empty(ny=oy, nx=ox+1)) break; return; case 1: if (empty(ny=oy-1, nx=ox)) break; return; case 2: if (empty(ny=oy, nx=ox-1)) break; return; case 3: if (empty(ny=oy+1, nx=ox)) break; return; } break; case VLONGPIECE: switch(m){ case 0: if (empty(oy, ox+1) && empty(oy+1, ox+1)) { nx=ox+1; ny=oy; break; } return; case 1: if (empty(oy-1, ox)) { nx=ox; ny=oy-1; break; } return; case 2: if (empty(oy, ox-1) && empty(oy+1, ox-1)) { nx=ox-1; ny=oy; break; } return; case 3: if (empty(oy+2, ox)) { nx=ox; ny=oy+1; break; } return; } break; case HLONGPIECE: switch(m){ case 0: if (empty(oy, ox+2)) { nx=ox+1; ny=oy; break; } return; case 1: if (empty(oy-1, ox) && empty(oy-1, ox+1)) { nx=ox; ny=oy-1; break; } return; case 2: if (empty(oy, ox-1)) { nx=ox-1; ny=oy; break; } return; case 3: if (empty(oy+1, ox) && empty(oy+1, ox+1)) { nx=ox; ny=oy+1; break; } return; } break; case BIGPIECE: switch(m){ case 0: if (empty(oy, ox+2) && empty(oy+1, ox+2)) { nx=ox+1; ny=oy; break; } return; case 1: if (empty(oy-1, ox) && empty(oy-1, ox+1)) { nx=ox; ny=oy-1; break; } return; case 2: if (empty(oy, ox-1) && empty(oy+1, ox-1)) { nx=ox-1; ny=oy; break; } return; case 3: if (empty(oy+2, ox) && empty(oy+2, ox+1)) { nx=ox; ny=oy+1; break; } return; } break; } #ifdef LATER { char display[MAXLINE]; /* Current number of moves display. */ sprintf(display, "%d", ++step); XDrawImageString(dpy, displayWindow, gc, 0, 0, display, strlen(display)); } #endif LATER pieces[n].pX=nx; /* move the piece */ pieces[n].pY=ny; XClearArea(dpy, puzzleWindow, (ox-1)*PIECE_W, (oy-1)*PIECE_H, pieceWidth(n), pieceHeight(n), 0); switch(pieceType(n)){ case SMALLPIECE: board[oy][ox]= EMPTY; board[ny][nx]= n; break; case VLONGPIECE: board[oy][ox]=board[oy+1][ox]= EMPTY; board[ny][nx]=board[ny+1][nx]=n; break; case HLONGPIECE: board[oy][ox]=board[oy][ox+1]= EMPTY; board[ny][nx]=board[ny][nx+1]=n; break; case BIGPIECE: board[oy][ox]=board[oy][ox+1]=board[oy+1][ox]=board[oy+1][ox+1]= EMPTY; board[ny][nx]=board[ny][nx+1]=board[ny+1][nx]=board[ny+1][nx+1]=n; break; } XCopyPlane(dpy, piecePixmap(n), puzzleWindow, gc, 0, 0, pieceWidth(n), pieceHeight(n), pieceX(n), pieceY(n), 1) ; } EnD of xpuzzle.c echo extracting xpuzzle.man 1>&2 cat >xpuzzle.man << 'EnD of xpuzzle.man' .TH XPUZZLE 6 "February 1987" .UC 4 .SH NAME xpuzzle \- another X-window V11 puzzle game .SH SYNOPSIS .B xpuzzle [ .B options ] .SH DESCRIPTION The goal of this game is to move down the largest piece to the bottom in minimal number of movements. It is known that the puzzle can be solved in 86 movements. To move a piece, point it by the mouse and press a button, hold the button until you move the mouse to an adjacent empty square. .br If you want to quit, press 'q' or 'Q' on the keyboard, while the cursor is in the puzzle window. The following options are valid: .PP .TP 8 .B -fg color as usual - change foreground color .TP 8 .B -bg color as usual - change background color .TP 8 .B -bd color as usual - change border color .TP 8 .B -bw number as usual - change border width .TP 8 .B host:display Name of the display you want the puzzle to run on. .SH AUTHORS .PP Jiang-Hsing Chu (jchu@mimsy.umd.edu) original game for suntools .PP Claus Gittinger (..!decvax!unido!sinix!claus) X11 version EnD of xpuzzle.man