Path: uunet!zephyr.ens.tek.com!master!saab!billr From: billr@saab.CNA.TEK.COM (Bill Randle) Newsgroups: comp.sources.games Subject: v12i090: sidtool2 - pacman game for XView, Part01/07 Message-ID: <1671@masterCNA.TEK.COM> Date: 22 Aug 91 23:14:00 GMT Sender: news@masterCNA.TEK.COM Lines: 1679 Approved: billr@saab.CNA.TEK.COM Submitted-by: richb@Aus.Sun.COM (Rich Burridge) Posting-number: Volume 12, Issue 90 Archive-name: sidtool2/Part01 Environment: X11R4, XView [[From the author: This is version 3.0.2 of sidtool (a pacman like game). It's the third major release of the software. The first two versions were written in SunWindows (1985) and SunView (1987) respectively for Sun workstations. Sidtool has now been converted to XView (an X11 toolkit). Although the software has only been tested on Suns, I hope it should be fairly easy to port to other systems running Unix, C and XView. See the manual pages or the online help for more details of how to play the game. See the README file for details of how to compile sidtool. The graphics user interface has been designed using Suns' devGuide. This automatically generates the sidtool_ui.c and sidtool_ui.h files, and the stubs for the notify procedures have been added into the xview.c file. I can generate stubs and ui files for OLIT and tNt if anybody is interested in creating versions of sidtool using those toolkits.]] #! /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 'README' <<'END_OF_FILE' X X/* @(#)README 1.6 91/08/19 X * X * Screen design and original implementation X * Copyright (C) 1981, 1982, 1983 - Brad A. Myers X * X * Current implementation X * Copyright (C) 1991 Rich Burridge X * X * Permission is given to distribute these sources, as long as the X * copyright messages are not removed, and no monies are exchanged. X * X * No responsibility is taken for any errors on inaccuracies inherent X * either to the comments or the code of this program, but if reported X * to me, then an attempt will be made to fix them. X */ X XSidtool - README - August - 1991. X X-------------------------------------------------------------------------- XCONTENTS: X X1. What is Sidtool? X2. Getting started. X3. Creating a different maze. X4. Sidtool history. X5. Acknowledgements. X-------------------------------------------------------------------------- X X1. What is Sidtool? X------------------- X XThis is version 3.0.2 of sidtool (a pacman like game). It's the third major Xrelease of the software. The first two versions were written in SunWindows X(1985) and SunView (1987) respectively for Sun workstations. Sidtool has now Xbeen converted to XView (an X11 toolkit). Although the software has only been Xtested on Suns, I hope it should be fairly easy to port to other systems Xrunning Unix, C and XView. X XSee the manual pages or the online help for more details of how to play Xthe game. X XThe graphics user interface has been designed using Suns' devGuide. This Xautomatically generates the sidtool_ui.c and sidtool_ui.h files, and the Xstubs for the notify procedures have been added into the xview.c file. I Xcan generate stubs and ui files for OLIT and tNt if anybody is interested Xin creating versions of sidtool using those toolkits. X X--------- X XThere is a mailing list for people interested in sidtool. It is: X X sidtool@Aus.Sun.COM X XTo get added to the list, send a request to: X X sidtool-request@Aus.Sun.COM X XThis list will primarily be used for sending out patches, rather than bother Xthe net in general, but could also be used for discussion on possible Xenhancements to the game. X X X2. Getting started. X------------------- X XInitially there is no Makefile file present in the sidtool source directory. XYou will need to copy Makefile.dist to Makefile, then adjust accordingly. X XYou need to do a "make" followed by a "make install". You might need Xsuper-user permission to do the latter successfully. X XThe Makefile compilation details are setup to default to compiling on a XSun running SunOS v4.1.1 with OpenWindows V3. X XNote that there are various compilation definitions that might need Xadjusting if you are trying to compile and run it on any other machine Xor operating system. X XThese are: X XSUNARROW - Sun specific: uncomment to use the arrow keys for movement. XXVIEWINCDIR - location of the XView #include files. XXVIEWLIBDIR - location of the XView libraries. X XSee the Makefile for a more detailed description of each of these definitions. X X----- X XAs sidtool is ported to other machines, I expect this list to grow. New Xentries will be added to the Makefile.dist, and summarised here. X XIf you need to make changes in order to get sidtool to compile and run Xon your system, please let me know the details (see email address below), Xand I will try to include them into a future version. X XSee the TODO file for the list of known problems and ideas for future Xenhancements. X XNote: This software was developed and tested on a Sun SS1+, and the speed X feels correct for this machine. Running sidtool or other machine might X require some tuning of the pause routines. X X X3. Creating a different maze. X----------------------------- X XSidtool has been designed to allow you to specify alternate mazes. You can Xuse this new maze layout with sidtool, with the -maze command line option. XThe maze layout should be contained in an ASCII file, and conform to the Xfollowing requirements: X X * The maze size is fixed at 26 by 28. X * The maze is not allowed to have any dead ends. X * All boxes in the maze are defined by paths. X * The upper left corner of each box is signified by a small s. X * Use the letters r,d,l,u to signify the direction to travel around boxes. X * Corners must be signified by changing the letter. X * The tunnel start must be signified by a capital S. X * The exit box must have the opening at the top. X * The ghost number 0 must be started directly above this exit. X * The exit should be signified by capital R's. X * All ghosts except for one must start in the box. X * The amount of time spent in the box is specified by the number which X shows where the ghost goes. X * Small dots in the maze are signified by periods '.'; X * Large dots in the maze are signified by asterisks '*'; X * Tunnels may be on left and right. X * All tunnels must have exits at both sides. X * There must be a row around the entire maze defining the border. X * All non-tunnel parts of the border must be 'x's X * The area in the tunnel in which the ghosts go slowly is defined as the X area between the exit and the first non-space character. Thus a '.' X causes the ghosts to speed up. X XThe default maze (which is hard-wired in) looks like this: X Xrrrrrrrrrrrrrdxrrrrrrrrrrrrd Xu............d u....0......d Xu.sd.srrrrrd.d u.srRRrd.sd.d Xu*ud.udlllll.rru.u 8d.ud*d Xu.ul.ud..........u98 d.ud.d Xu....ud.sd.sd.sd.ulllll.ul.d Xulll.ud.ul.ud.ud...........d Xx u.ud....ud.ud.srrrrrd.dll XSrru.ul.rrrud.ud.u dllll.rrx X ....ullll.ul.ull.... XSrrrrrd..............sd.rrrx Xdllllll.srrrrrrrd.rd.ud.ulll Xd.......udlllllll*ud.ud....u Xd.sd.sd.ud........ud.ud.sd.u Xd.ud.ul.ud.srrrrd.ud.ul.ud.u Xd.ud....ud.ulllll.ud....ul.u Xd.urrrd.ud ud.sd....u Xd.ullld.urrrrrrrrrud.ud.sd.u Xd....ud.ulllllllllll.ud.ud.u Xd.sd.ud..............ud.ud*u Xd*ud.urd.srrrrrrrrrd.ud.ud.u Xd.ul.uld.ullllllllll.ul.ul.u Xd.....ud..... ............u Xrrrrd.urrrd.srrrrd....srd.ru Xxllll.ullld.ulll d....ull.uT X ......ud....uld.sd..... XSrd.srrd.ud.rd..ud.ul.srd.rx Xx d.ulll.ul.urd.ul....ull.ux Xx d.........u d....rd.....ux Xxxrrrrrrrrrruxrrrrrurrrrrrux X X X4. Sidtool history. X------------------- X XSidtool is based on the Perq Interactive debugger program, written by XBrad A. Myers when he was at ThreeRivers Inc., back in the early 1980's. XAt that time it was written in Pascal for the POS operating system. About X1985 I converted it to run under Unix and C on Sun's using SunWindows. This Xfirst version of sidtool was actually two programs "talking" to each other Xvia a pipe. One program updated the screen, the other program read input Xfrom the mouse and the keyboard. This was required because at that time, XSunWindows could not do explicit dispatching of events. X XThe second version of sidtool, was a "port" to SunView in 1987, and the Xprogram was modified to use a timer routine and a state machine, which Xlisted all the possible states the program could be in. The graphics were Xsimple, and in fact only used drawing to a graphics canvas. X XThis third version has again been "ported" to the latest flavour-de-jour in Xwindow systems, with the graphics interface being rewritten using Suns' XdevGuide. It therefor now makes use of a control panel with buttons, sliders, Xpopup windows, scrolling list, a property sheet and the works. It's been Xwritten in the XView toolkit, but versions could easily be generated for XOLIT or tNt. X X X5. Acknowledgements. X-------------------- X XThanks go to Brad Myers for the original game. X XTo Dan Heller for the basis of the joystick interface which was introduced Xin the second release back in 1987. X XTo Stuart Marks for the code to handle the Sun arrow keys. X XThanks also to Jeff Blows for various bug reports and suggestions for Xenhancement. X XSuggestions for furthur improvement would be most welcome, plus bugs, Xcomments and flames. X XBrad A. Myers Rich Burridge XSchool of Computer Science Sun Microsystems Australia, XCarnegie Mellon University 495 Victoria Avenue, X5000 Forbes Avenue Chatswood, NSW 2067. XPittsburgh, PA 15213-3890 AUSTRALIA. XTEL: (412) 268-5150 TEL: +61 2 413 2666 XFAX: (412) 681-5739 FAX: +61 2 413 3869 Xbam@a.gp.cs.cmu.edu richb@aus.sun.com END_OF_FILE if test 8277 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'MANIFEST' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'MANIFEST'\" else echo shar: Extracting \"'MANIFEST'\" \(2563 characters\) sed "s/^X//" >'MANIFEST' <<'END_OF_FILE' X File Name Archive # Description X----------------------------------------------------------- X CHANGES 4 X FILES 4 X MANIFEST 1 This shipping list X Makefile.dist 2 X README 1 X TODO 5 X action.c 3 X extern.h 4 X images 1 X images/BASHFUL0.xbm 6 X images/BASHFUL1.xbm 6 X images/POKEY0.xbm 6 X images/POKEY1.xbm 6 X images/SHADOW0.xbm 6 X images/SHADOW1.xbm 6 X images/SPEEDY0.xbm 6 X images/SPEEDY1.xbm 6 X images/blueghost0.xbm 5 X images/blueghost1.xbm 5 X images/bluepics0.xbm 5 X images/bluepics1.xbm 5 X images/cirDOWN0.xbm 6 X images/cirDOWN1.xbm 5 X images/cirDOWN2.xbm 5 X images/cirDOWN3.xbm 5 X images/cirLEFT0.xbm 5 X images/cirLEFT1.xbm 5 X images/cirLEFT2.xbm 5 X images/cirLEFT3.xbm 5 X images/cirRIGHT0.xbm 5 X images/cirRIGHT1.xbm 5 X images/cirRIGHT2.xbm 5 X images/cirRIGHT3.xbm 5 X images/cirUP0.xbm 7 X images/cirUP1.xbm 7 X images/cirUP2.xbm 6 X images/cirUP3.xbm 7 X images/circleexplode0.xbm 4 X images/circleexplode1.xbm 4 X images/circleexplode2.xbm 4 X images/circleexplode3.xbm 1 X images/circleexplode4.xbm 4 X images/circleexplode5.xbm 4 X images/circleexplode6.xbm 4 X images/circleexplode7.xbm 4 X images/circleexplode8.xbm 4 X images/cornerDL.xbm 6 X images/cornerLU.xbm 6 X images/cornerRD.xbm 6 X images/cornerUR.xbm 6 X images/down.xbm 7 X images/empty.xbm 7 X images/eyesDOWN.xbm 6 X images/eyesLEFT.xbm 6 X images/eyesRIGHT.xbm 5 X images/eyesUP.xbm 7 X images/fruit1.xbm 7 X images/fruit2.xbm 7 X images/fruit3.xbm 7 X images/fruit4.xbm 7 X images/fruit5.xbm 7 X images/fruit6.xbm 7 X images/fruit7.xbm 7 X images/fruit8.xbm 7 X images/left.xbm 7 X images/picbigdot.xbm 5 X images/picsmalldot.xbm 4 X images/right.xbm 7 X images/sidtool.xbm 6 X images/up.xbm 4 X main.c 2 X patchlevel.h 2 X setup.c 3 X sidtool.h 1 X sidtool.man 4 X sidtool.man.text 3 X sidtool_ui.c 2 X sidtool_ui.h 4 X xview.c 1 END_OF_FILE if test 2563 -ne `wc -c <'MANIFEST'`; then echo shar: \"'MANIFEST'\" unpacked with wrong size! fi # end of 'MANIFEST' fi if test ! -d 'images' ; then echo shar: Creating directory \"'images'\" mkdir 'images' fi if test -f 'images/circleexplode3.xbm' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'images/circleexplode3.xbm'\" else echo shar: Extracting \"'images/circleexplode3.xbm'\" \(2743 characters\) sed "s/^X//" >'images/circleexplode3.xbm' <<'END_OF_FILE' X#define circleexplode3_width 64 X#define circleexplode3_height 64 Xstatic unsigned char circleexplode3_bits[] = { X 0x00,0x80,0xff,0xff,0xff,0x0f,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0x07,0x00, X 0x00,0x00,0x80,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00, X 0x00,0x00,0x00,0x80,0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x00, X 0x00,0x00,0x00,0x00,0x80,0xff,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff, X 0xff,0xff,0x01,0x00,0x00,0x00,0xff,0xff,0xf5,0xff,0xdf,0x01,0x00,0x00,0xff, X 0xff,0xea,0xff,0xef,0x03,0x00,0x00,0xff,0xff,0xf5,0xff,0xf7,0x01,0x00,0x00, X 0xff,0xff,0xea,0xff,0xfb,0x11,0x00,0x00,0xff,0xff,0xff,0xff,0xfb,0x11,0x00, X 0x00,0xff,0xff,0xff,0xff,0xfd,0x11,0x00,0x00,0xff,0xff,0xff,0xff,0xfe,0x10, X 0x00,0x00,0xff,0xff,0xff,0x7f,0xff,0x18,0x00,0x00,0xff,0xff,0xff,0x7f,0xff, X 0x18,0x00,0x00,0xff,0xff,0xff,0xbf,0xff,0x18,0x00,0x00,0xff,0xff,0xff,0xdf, X 0xff,0x18,0x00,0x00,0xff,0xff,0xff,0xef,0x7f,0x1c,0x00,0x00,0xff,0xff,0xff, X 0xef,0x7f,0x1c,0x00,0x00,0xff,0xff,0xff,0xf7,0x7f,0x1c,0x00,0x00,0xff,0xff, X 0xff,0xfb,0x7f,0x1c,0x00,0x00,0x01,0x00,0x00,0xfc,0x3f,0x1e,0x00,0x00,0xfe, X 0xff,0xff,0xff,0x3f,0x1e,0x00,0x00,0x0f,0x00,0x00,0xfe,0x3f,0x0e,0x00,0x00, X 0xff,0xff,0xff,0xff,0x3f,0x0e,0x00,0x00,0xff,0xff,0x0f,0xfe,0x1f,0x0f,0x00, X 0x00,0xff,0xff,0xff,0xff,0x1f,0x0f,0x00,0x00,0xff,0xff,0xff,0xff,0x1f,0x0f, X 0x00,0x00,0xff,0xff,0xff,0xff,0x1f,0x0f,0x00,0x00,0xfe,0xff,0xff,0xff,0x9f, X 0x0f,0x00,0x00,0xfc,0xff,0xff,0xff,0x8f,0x0f,0x00,0x00,0x00,0x00,0xf0,0xff, X 0x8f,0x07,0x00,0x00,0x00,0x00,0xf0,0xff,0x8f,0x07,0x00,0x00,0x00,0x00,0xe0, X 0xff,0xcf,0x07,0x00,0x00,0x00,0x00,0xe0,0xff,0xc7,0x07,0x00,0x00,0x00,0x00, X 0xc0,0xff,0xc7,0x07,0x00,0x00,0x00,0x00,0xc0,0xff,0x07,0x00,0x00,0x00,0x00, X 0x00,0x80,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, X 0x00,0x00}; END_OF_FILE if test 2743 -ne `wc -c <'images/circleexplode3.xbm'`; then echo shar: \"'images/circleexplode3.xbm'\" unpacked with wrong size! fi # end of 'images/circleexplode3.xbm' fi if test -f 'sidtool.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sidtool.h'\" else echo shar: Extracting \"'sidtool.h'\" \(10449 characters\) sed "s/^X//" >'sidtool.h' <<'END_OF_FILE' X X/* @(#)sidtool.h 1.7 91/08/19 X * X * Definitions used by the sidtool program. X * X * Screen design and original implementation X * Copyright (C) 1981, 1982, 1983 - Brad A. Myers X * X * Current implementation X * Copyright (C) 1991 Rich Burridge X * X * Permission is given to distribute these sources, as long as the X * copyright messages are not removed, and no monies are exchanged. X * X * No responsibility is taken for any errors on inaccuracies inherent X * either to the comments or the code of this program, but if reported X * to me, then an attempt will be made to fix them. X */ X X#include X#include X X/* For all function declarations, if ANSI then use a prototype. */ X X#if defined(__STDC__) X#define P(args) args X#else /* ! __STDC__ */ X#define P(args) () X#endif /* STDC */ X X#define SPEED 3 /* Speed of this Sun. */ X#define S_NAME "sidtool.hs" /* Default highscore filename. */ X Xtypedef int BOOLEAN ; X Xchar *getenv() ; X X#define CLOSE (void) close /* To make lint happy. */ X#define DOINC (void) doinc X#define FCLOSE (void) fclose X#define FGETS (void) fgets X#define FPRINTF (void) fprintf X#define FREE (void) free X#define GETHOSTNAME (void) gethostname X#define MEMSET (void) memset X#define READ (void) read X#define SSCANF (void) sscanf X#define SETJMP (void) setjmp X#define SPRINTF (void) sprintf X#define SRAND (void) srand X#define STRCAT (void) strcat X#define STRCPY (void) strcpy X#define WRITE (void) write X X#define EQUAL(a, b) !strncmp(a, b, strlen(b)) X X#define SQUARE 26 /* Size of each square of the maze. */ X#define XBASE 45 /* X start of maze. */ X#define YBASE 15 /* Y start of maze. */ X X/* Set the function to be used for characters. */ X#define SCHRFUNC(f) (sfunc = f) X X/* Determine the bug index, POKEY to SHADOW. */ X#define GIND(x) ((x) - &bugs[0]) X X#define AUTO_SCORE 5 /* Player number to update in auto mode. */ X#define FRUIT_SCORE 6 X#define HIGH_SCORE 7 X X#define BORDER_SIZE 7 /* Frame border width (in pixels). */ X#define BSPACE 8 /* Backspace used by getline. */ X#define BUTXOFF 30 /* X offset of buttons. */ X#define BUTYOFF 10 /* Y offset of buttons. */ X#define CATCHUP 3 /* Amount screen catches up blue bug. */ X#define CR 13 X#define DEF_PLAYERS 1 /* Default number of players. */ X#define DEF_SKILL 5 /* Default skill level. */ X#define DEL 127 /* Used to start the sid tool game. */ X#define ENKEY 01652 /* Encode key used in highscore file. */ X#define FALSE 0 X#define FRUITMX 13 /* X maze position of fruit. */ X#define FRUITMY 16 /* Y maze position of fruit. */ X#define GOFFSET SQUARE / 2 - 3 /* Offset of bugs and screen. */ X#define INC argc-- ; argv++ ; X#define LPAUSE 20000 /* Default pause length (microseconds). */ X#define MAXIMAGES 61 /* Maximum number of icon images. */ X#define MAXNUMPLAYERS 4 /* Number of players allowed. */ X#define MAXLINE 80 /* Maximum string length. */ X#define MINMOVE 20 X#define SLUG_MSECS 5 /* Default main loop time (millisecs). */ X#define SWIDTH 768 /* Maximum screen width. */ X#define SHEIGHT 900 /* Maximum screen height. */ X#define TRUE 1 X#define XSIZE 26 /* Number of squares in x. */ X#define YSIZE 28 /* Number of squares in y. */ X Xenum font_type { BOLDFONT, NORMALFONT } ; /* Font types used by sidtool. */ X Xenum rop_type { RRPL, RXOR, RCLR, RSET, RINV } ; /* Rasterop types. */ X X/* States for the sidtool automation. */ X Xenum sid_type { STARTUP, INITGAME, PLAY, DOPLAY, X MAKEPLAY, DOREST, HIGHSCORE, DOCREDIT, X MOVELEFT, MOVERIGHT, DOLEAVE, RESETGAME } ; X Xenum but_type { BUT_HELP, BUT_PROPS, BUT_SCORES, BUT_QUIT, X BUT_NEW, BUT_STOP, BUT_CONT, BUT_APPLY, X BUT_RESET } ; X Xenum choice_type { C_PLAY } ; X X/* Sidtool images. */ X Xenum icon_type { CURCIRCLE, CORNER, CORNER1, CORNER2, X CORNER3, BDOT, SDOT, CIRCLES, X CIRCLES1, CIRCLES2, CIRCLES3, CIRCLES4, X CIRCLES5, CIRCLES6, CIRCLES7, CIRCLES8, X CIRCLES9, CIRCLES10, CIRCLES11, CIRCLES12, X CIRCLES13, CIRCLES14, CIRCLES15, BUGPICS, X BUGPICS1, BUGPICS2, BUGPICS3, BUGPICS4, X BUGPICS5, BUGPICS6, BUGPICS7, BLUEBUG, X BLUEBUG1, BLUEPICS, BLUEPICS1, EYES, X EYES1, EYES2, EYES3, EXPLODE, X EXPLODE1, EXPLODE2, EXPLODE3, EXPLODE4, X EXPLODE5, EXPLODE6, EXPLODE7, EXPLODE8, X FRUIT, FRUIT1, FRUIT2, FRUIT3, X FRUIT4, FRUIT5, FRUIT6, FRUIT7, X FRUIT8, RJSTICK, UJSTICK, LJSTICK, X DJSTICK } ; X Xenum corner_type { UR, RD, DL, LU } ; /* Corners. */ X Xenum dot_type { NODOT, BIGDOT, SMALLDOT } ; /* Dotsize. */ X Xenum dir_type { RIGHT, UP, LEFT, DOWN } ; /* Direction. */ X Xenum ghost_type { POKEY, BASHFUL, SPEEDY, SHADOW } ; /* Ghostnames. */ X Xenum image_type { CNTR1, CNTR2, CNTR3, CNTR4, /* Panel images. */ X CURFRUIT } ; X Xenum mes_type { M_PLAYER1, M_PLAYER2, /* Message types. */ X M_PLAYER3, M_PLAYER4 } ; X Xenum res_type { R_PLAYERS, R_SKILL, R_PAUSE, R_SLUG } ; /* Resource types. */ X Xenum sound_type { S_DIE, S_EATBIGDOT, S_EATBLUE, /* Sound types. */ X S_EATFRUIT, S_ERROR, S_NEWSCREEN } ; X Xenum win_type { W_PROPS, W_SCORES } ; /* Window types. */ X Xenum prop_type { P_SKILL, P_PLAYERS } ; /* Property window types. */ X Xstruct scorerec X { X char who[MAXLINE] ; X int score ; X } ; X Xstruct bugrec X { X enum dir_type dir ; X BOOLEAN eyesonly ; /* Going to box. */ X BOOLEAN enteringbox ; /* Going down into box. */ X BOOLEAN inbox ; /* Inside or leaving. */ X BOOLEAN intunnel ; X int delay ; X int scrx, scry ; X int mx, my ; X int bluetime ; /* If zero then not blue. */ X int boxtime ; /* Countdown until leave. */ X int count ; /* Incremented every tic. */ X int pic ; /* 0 or 1. */ X } ; X Xstruct startrec X { X int x, y, time ; X } ; X Xchar *get_resource P((enum res_type)) ; X Xenum dir_type dorandomdir P((enum dir_type, int, int, int, int, X int *, int *, int *, int *, int)) ; Xenum dir_type reversedir P((enum dir_type)) ; X Xint checkinc P((enum dir_type, int, int)) ; Xint checkcollision P((int, int, int *)) ; Xint doinc P((enum dir_type, int, int, int, int, int *, int *, int *, int *)) ; Xint gcentered P((int, int)) ; Xint get_choice P((enum choice_type)) ; Xint get_int_resource P((enum res_type, int *)) ; Xint get_value P((enum prop_type)) ; Xint main P((int, char **)) ; Xint randomrange P(()) ; X Xvoid activate_button P((enum but_type, int)) ; Xvoid activate_choice P((enum choice_type, int)) ; Xvoid activate_message P((enum mes_type, int)) ; Xvoid blinkpause P(()) ; Xvoid blt_mem P((enum icon_type, int, int, int, int, enum rop_type, X enum icon_type src, int, int)) ; Xvoid blt_mem_to_scrn P((int, int, int, int, enum rop_type, X enum icon_type, int, int)) ; Xvoid blt_scrn P((int, int, int, int, enum rop_type)) ; Xvoid changebugs P(()) ; Xvoid changeplayers P((int)) ; Xvoid clear_screen P(()) ; Xvoid cmdbool P((int, char *, char *)) ; Xvoid cmdint P((int, int, char *, char *)) ; Xvoid cmdstr P((char *, char *, char *)) ; Xvoid destroyblue P((struct bugrec *)) ; Xvoid destroyfruit P(()) ; Xvoid do_flush P(()) ; Xvoid do_startup P(()) ; Xvoid docredits P(()) ; Xvoid dohelp P(()) ; Xvoid doplay P(()) ; Xvoid doupdate P(()) ; Xvoid draw_joystick P((enum dir_type)) ; Xvoid draw_text P((int, int, enum font_type, char *)) ; Xvoid drawbox P((int, int)) ; Xvoid drawbug P((struct bugrec *)) ; Xvoid drawcir P((enum icon_type, int, int)) ; Xvoid drawcorner P((enum corner_type, int, int)) ; Xvoid drawdot P((enum dot_type, int, int)) ; Xvoid drawline P((int, int, int)) ; Xvoid drawmaze P(()) ; Xvoid erasebugs P(()) ; Xvoid explodecircle P((int, int)) ; Xvoid fixexits P(()) ; Xvoid get_icons P(()) ; Xvoid get_options P(()) ; Xvoid geths P((struct scorerec *, int)) ; Xvoid getparam P((char *, char **, char *)) ; Xvoid handlecollision P((struct bugrec *)) ; Xvoid headto P((int, int, int, int, int, int, enum dir_type *, X int *, int *, int *, int *)) ; Xvoid initgame P(()) ; Xvoid init_options P(()) ; Xvoid init_rops P(()) ; Xvoid initialize P(()) ; Xvoid load_image P((enum icon_type, unsigned char *)) ; Xvoid load_resources P(()) ; Xvoid longpause P((int)) ; Xvoid make_play P(()) ; Xvoid make_sound P((enum sound_type)) ; Xvoid move_left P(()) ; Xvoid move_right P(()) ; Xvoid newbugs P((int)) ; Xvoid next_state P(()) ; Xvoid ppause P((int)) ; Xvoid play P(()) ; Xvoid position_popup P((enum win_type)) ; Xvoid process_button P((char *)) ; Xvoid puths P((struct scorerec, int)) ; Xvoid read_resources P(()) ; Xvoid readallhighscores P(()) ; Xvoid removecircle P(()) ; Xvoid resetmaze P(()) ; Xvoid restore_screen P(()) ; Xvoid save_cmdline P((char *)) ; Xvoid savescorefile P(()) ; Xvoid set_choice P((enum choice_type, int)) ; Xvoid set_cursor P((int)) ; Xvoid set_highscore P((int)) ; Xvoid set_image P((enum image_type, enum icon_type, enum rop_type)) ; Xvoid set_label P((enum but_type)) ; Xvoid set_list P((int)) ; Xvoid set_score P((int, int)) ; Xvoid set_timer P((int)) ; Xvoid set_value P((enum prop_type, int)) ; Xvoid setdots P((int)) ; Xvoid show_window P((enum win_type, int)) ; Xvoid showplayerscore P((int)) ; Xvoid transpt P((int, int, int *, int *)) ; Xvoid untranspt P((int, int, int *, int *)) ; Xvoid updatebugs P(()) ; Xvoid updatefruit P(()) ; Xvoid updatescore P((int)) ; Xvoid warp_mouse P(()) ; Xvoid write_cmdline P(()) ; Xvoid writehighscore P(()) ; END_OF_FILE if test 10449 -ne `wc -c <'sidtool.h'`; then echo shar: \"'sidtool.h'\" unpacked with wrong size! fi # end of 'sidtool.h' fi if test -f 'xview.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xview.c'\" else echo shar: Extracting \"'xview.c'\" \(24979 characters\) sed "s/^X//" >'xview.c' <<'END_OF_FILE' X X/* @(#)xview.c 1.8 91/08/19 X * X * XView dependent graphics routines used by sidtool. X * X * Screen design and original implementation X * Copyright (C) 1981, 1982, 1983 - Brad A. Myers X * X * Current implementation X * Copyright (C) 1991 Rich Burridge X * X * Permission is given to distribute these sources, as long as the X * copyright messages are not removed, and no monies are exchanged. X * X * No responsibility is taken for any errors on inaccuracies inherent X * either to the comments or the code of this program, but if reported X * to me, then an attempt will be made to fix them. X */ X X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X X#include "sidtool_ui.h" X X#include "sidtool.h" X#include "extern.h" X X#define NOTIFY_SET_ITIMER_FUNC (void) notify_set_itimer_func X#define XV_SET (void) xv_set X X#define BFONT "-b&h-lucidatypewriter-bold-r-*-*-*-130-*-*-*-*-iso8859-1" X#define NFONT "-b&h-lucidatypewriter-medium-r-*-*-*-130-*-*-*-*-iso8859-1" X Xsidtool_Wmain_objects *Sidtool_Wmain ; Xsidtool_Pprops_objects *Sidtool_Pprops ; Xsidtool_Pscores_objects *Sidtool_Pscores ; X XAttr_attribute INSTANCE ; X X#ifdef SUN_ARROW_KEYS Xstatic int event_is_keypad P((Event *)) ; Xstatic KeySym keypad_keysym P((Event *)) ; Xstatic void key_init P(()) ; X#endif /*SUN_ARROW_KEYS*/ X Xvoid Bnotify P((Panel_item, Event *)) ; Xvoid Ccanvas_repaint P((Canvas, Xv_window, X Display *, Window, Xv_xrectlist *)) ; Xvoid event_proc P((Xv_window, Event *, Notify_arg, Notify_event_type)) ; Xvoid make_x_stuff P((Frame, Canvas)) ; X XNotify_value Ccanvas_event P((Xv_window, Event *, X Notify_arg, Notify_event_type)) ; XNotify_value main_loop P((Notify_client, int)) ; XPanel_setting Snotify P((Panel_item, Event *)) ; X XCanvas canvas ; XCanvas_paint_window pw ; XDrawable xid ; XFrame frame ; XPixmap images[MAXIMAGES] ; /* The sidtool icon images. */ XPixmap scratch ; XXFontStruct *bfont, *nfont ; XXGCValues gc_val ; XXrmDatabase sidtool_DB ; /* Combined resources database. */ XXv_cursor cursor, offcursor ; X XDisplay *dpy ; XGC gc ; XGC ropgc ; /* Graphics context for rasterops. */ XGC svgc = NULL ; XGC textgc ; /* Graphics context for writing all text. */ X X#ifdef SUN_ARROW_KEYS X/* Data for holding information about the server's keyboard mapping. */ Xint kcmin ; /* Minimum keycode. */ Xint kcmax ; /* Maximum keycode. */ Xint keysyms_per_key ; /* Keysyms per keycode. */ Xunsigned char *kparray ; /* Array indicating if key is on keypad. */ X#endif /*SUN_ARROW_KEYS*/ X Xstatic char *cmdline = NULL ; /* Saved command line options. */ X Xint rops[5] ; /* Graphics dependent rasterop codes. */ Xint screen ; Xlong backgnd, foregnd ; Xunsigned int depth ; Xunsigned long gc_mask ; X X Xint Xmain(argc, argv) Xint argc ; Xchar **argv ; X{ X progname = argv[0] ; /* Save pointer to this programs name. */ X init_options() ; /* Initialise default option values. */ X X xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0) ; X init_rops() ; X X Sidtool_Wmain = sidtool_Wmain_objects_initialize(NULL, NULL) ; X Sidtool_Pprops = sidtool_Pprops_objects_initialize(NULL, X Sidtool_Wmain->Wmain) ; X Sidtool_Pscores = sidtool_Pscores_objects_initialize(NULL, X Sidtool_Wmain->Wmain) ; X make_x_stuff(Sidtool_Wmain->Wmain, Sidtool_Wmain->Ccanvas) ; X load_resources() ; /* Get resources from various places. */ X read_resources() ; /* Read resources from merged database. */ X get_options(argc, argv) ; /* Get command line options. */ X X XV_SET(canvas, CANVAS_RETAINED, retained, 0) ; X X#ifdef SUN_ARROW_KEYS X key_init() ; /* Determine function pad keys. */ X#endif /*SUN_ARROW_KEYS*/ X X do_startup() ; X set_timer(TRUE) ; X write_cmdline() ; /* Save sidtool command line. */ X canpaint = TRUE ; X xv_main_loop(Sidtool_Wmain->Wmain) ; X exit(0) ; X/*NOTREACHED*/ X} X X Xvoid Xactivate_button(btype, state) Xenum but_type btype ; Xint state ; X{ X switch (btype) X { X case BUT_HELP : XV_SET(Sidtool_Wmain->Bhelp, X PANEL_INACTIVE, !state, X 0) ; X break ; X case BUT_PROPS : XV_SET(Sidtool_Wmain->Bprops, X PANEL_INACTIVE, !state, X 0) ; X break ; X case BUT_SCORES : XV_SET(Sidtool_Wmain->Bscores, X PANEL_INACTIVE, !state, X 0) ; X break ; X case BUT_NEW : XV_SET(Sidtool_Wmain->Bnewgame, X PANEL_INACTIVE, !state, X 0) ; X break ; X case BUT_CONT : X case BUT_STOP : XV_SET(Sidtool_Wmain->Bstop, X PANEL_INACTIVE, !state, X 0) ; X } X} X X Xvoid Xactivate_choice(ctype, state) Xenum choice_type ctype ; Xint state ; X{ X switch ((int) ctype) X { X case C_PLAY : XV_SET(Sidtool_Wmain->SETgame, X PANEL_INACTIVE, !state, X 0) ; X } X} X X Xvoid Xactivate_message(mtype, state) Xenum mes_type mtype ; Xint state ; X{ X if (mtype == M_PLAYER1) X { X XV_SET(Sidtool_Wmain->Mplayer1, PANEL_INACTIVE, !state, 0) ; X XV_SET(Sidtool_Wmain->Mscore1, PANEL_INACTIVE, !state, 0) ; X } X else if (mtype == M_PLAYER2) X { X XV_SET(Sidtool_Wmain->Mplayer2, PANEL_INACTIVE, !state, 0) ; X XV_SET(Sidtool_Wmain->Mscore2, PANEL_INACTIVE, !state, 0) ; } X else if (mtype == M_PLAYER3) X { X XV_SET(Sidtool_Wmain->Mplayer3, PANEL_INACTIVE, !state, 0) ; X XV_SET(Sidtool_Wmain->Mscore3, PANEL_INACTIVE, !state, 0) ; } X else if (mtype == M_PLAYER4) X { X XV_SET(Sidtool_Wmain->Mplayer4, PANEL_INACTIVE, !state, 0) ; X XV_SET(Sidtool_Wmain->Mscore4, PANEL_INACTIVE, !state, 0) ; } X} X X X/* Move an offscreen raster area to another offscreen raster area. */ X Xvoid Xblt_mem(dst, dx, dy, width, height, rop, src, sx, sy) Xint dx, dy, width, height, sx, sy ; Xenum rop_type rop ; Xenum icon_type dst, src ; X{ X XSetFunction(dpy, svgc, rops[(int) rop]) ; X XCopyArea(dpy, images[(int) src], images[(int) dst], svgc, sx, sy, X (unsigned int) width, (unsigned int) height, dx, dy) ; X} X X X/* Move an offscreen raster area to the screen. */ X Xvoid Xblt_mem_to_scrn(srcx, srcy, width, height, rop, mem, memx, memy) Xint srcx, srcy, width, height, memx, memy ; Xenum rop_type rop ; Xenum icon_type mem ; X{ X if (memx || memy) X { X XCopyArea(dpy, images[(int) mem], scratch, svgc, X memx, memy, width, height, 0, 0) ; X gc_val.stipple = scratch ; X } X else gc_val.stipple = images[(int) mem] ; X gc_val.ts_x_origin = srcx ; X gc_val.ts_y_origin = srcy ; X gc_val.function = rops[(int) rop] ; X gc_mask = GCFunction | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin ; X XChangeGC(dpy, ropgc, gc_mask, &gc_val) ; X XFillRectangle(dpy, xid, ropgc, srcx, srcy, width, height) ; X} X X X/* Manipulate a portion of the screen with itself. */ X Xvoid Xblt_scrn(srcx, srcy, width, height, rop) Xint srcx, srcy, width, height ; Xenum rop_type rop ; X{ X XSetFunction(dpy, ropgc, rops[(int) rop]) ; X XCopyArea(dpy, xid, xid, ropgc, srcx, srcy, X (unsigned int) width, (unsigned int) height, srcx, srcy) ; X} X X X/*ARGSUSED*/ Xvoid XBnotify(item, event) XPanel_item item ; XEvent *event ; X{ X char *str ; X X str = (char *) xv_get(item, PANEL_LABEL_STRING) ; X process_button(str) ; X} X X XNotify_value XCcanvas_event(win, event, arg, type) XXv_window win ; XEvent *event ; XNotify_arg arg ; XNotify_event_type type ; X{ X event_proc(win, event, arg, type) ; X return(notify_next_event_func(win, (Notify_event) event, arg, type)) ; X} X X X/*ARGSUSED*/ Xvoid XCcanvas_repaint(canvas, paint_window, display, xid, rects) XCanvas canvas ; XXv_window paint_window ; XDisplay *display ; XWindow xid ; XXv_xrectlist *rects ; X{ X XEvent ev ; X X/* Get the remaining expose events. */ X X while (XPending(dpy) && (XPeekEvent(dpy, &ev), X (ev.type == Expose && ev.xany.window == xid))) X XNextEvent(dpy, &ev) ; X X restore_screen() ; X} X X Xvoid Xdo_flush() X{ X XSync(dpy, 0) ; X} X X Xvoid Xdraw_text(x, y, ftype, text) /* Write text in font at x,y. */ Xint x, y ; Xenum font_type ftype ; Xchar *text ; X{ X XSetFunction(dpy, textgc, rops[(int) sfunc]) ; X if (ftype == BOLDFONT) XSetFont(dpy, textgc, bfont->fid) ; X else XSetFont(dpy, textgc, nfont->fid) ; X XDrawString(dpy, xid, textgc, x, y, text, strlen(text)) ; X} X X X#ifdef SUN_ARROW_KEYS X/* Tell whether an event is a keyboard event from a keypad key. This function X * looks at the raw X event and uses information from Xlib to make this X * determination. This function is sometimes necessary because there are X * often several keysyms on a keypad key, and XView doesn't always give the X * "right" one. X */ X Xstatic int Xevent_is_keypad(event) XEvent *event ; X{ X XEvent *xk = event_xevent(event) ; X X if (xk->type != KeyPress && xk->type != KeyRelease) return(0) ; X return(kparray[xk->xkey.keycode - kcmin] > 0) ; X} X#endif /*SUN_ARROW_KEYS*/ X X X/*ARGSUSED*/ Xvoid Xevent_proc(window, event, arg, type) XXv_window window ; XEvent *event ; XNotify_arg arg ; XNotify_event_type type ; X{ X static int oldx = 0 ; X static int oldy = 0 ; X int curx, cury ; X int dx, dy, id, isascii, isdown ; X X id = event_id(event) ; X isascii = event_is_ascii(event) ; X isdown = event_is_down(event) ; X curx = event_x(event) ; X cury = event_y(event) ; X X#ifdef SUN_ARROW_KEYS X/* Determine if one of the arrow keys on the right function pad have been X * pressed, and map to the appropriate direction. Saves us having to mess X * around with remapping the keyboard. X */ X X if (event_is_keypad(event)) X { X switch (keypad_keysym(event)) X { X case XK_KP_2 : sc = 'd' ; X break ; X case XK_KP_4 : sc = 'l' ; X break ; X case XK_KP_6 : sc = 'r' ; X break ; X case XK_KP_8 : sc = 'u' ; X } X return ; X } X#endif /*SUN_ARROW_KEYS*/ X X/* If we get a KBD_DONE event and we are playing a normal game, then return X * the mouse to the middle of the window. X */ X X if (id == KBD_DONE && !stopped && progstate == MAKEPLAY && !autoplay) X warp_mouse() ; X X if (isascii || !autoplay && (id == MS_RIGHT || id == LOC_MOVE)) X { X c = id ; X if (!autoplay) X { X if (isascii) X { X if (isdown) X { X if (c == 'h') sc = 'l' ; X else if (c == 'j') sc = 'd' ; X else if (c == 'k') sc = 'u' ; X else if (c == 'l') sc = 'r' ; X } X return ; X } X if (c == LOC_MOVE) X { X dx = abs(curx - oldx) ; X dy = abs(cury - oldy) ; X if (dx <= 4 && dy <= 4) /* Move at least 4 pixels */ X { X oldx = curx ; X oldy = cury ; X return ; X } X if (dx > dy) X if ((curx - oldx) > 0) c = 'r' ; X else c = 'l' ; X else X if ((cury - oldy) > 0) c = 'd' ; X else c = 'u' ; X oldx = curx ; X oldy = cury ; X } X sc = c ; X } X } X} X X Xint Xget_choice(ctype) Xenum choice_type ctype ; X{ X switch ((int) ctype) X { X case C_PLAY : return((int) xv_get(Sidtool_Wmain->SETgame, PANEL_VALUE)) ; X } X/*NOTREACHED*/ X} X X Xchar * Xget_resource(rtype) /* Get sidtool resource from merged databases. */ Xenum res_type rtype ; X{ X char cstr[MAXLINE], nstr[MAXLINE], str[MAXLINE] ; X char *str_type[20] ; X XrmValue value ; X X STRCPY(str, resources[(int) rtype]) ; X SPRINTF(nstr, "sidtool.%s", str) ; X if (islower(str[0])) str[0] = toupper(str[0]) ; X SPRINTF(cstr, "Sidtool.%s", str) ; X if (XrmGetResource(sidtool_DB, nstr, cstr, str_type, &value) == NULL) X return((char *) NULL) ; X else return(value.addr) ; X} X X Xint Xget_value(ptype) Xenum prop_type ptype ; X{ X if (ptype == P_PLAYERS) X return((int) xv_get(Sidtool_Pprops->SETplayer, PANEL_VALUE)) ; X else if (ptype == P_SKILL) X return((int) xv_get(Sidtool_Pprops->SLlevel, PANEL_VALUE)) ; X/*NOTREACHED*/ X} X X Xvoid Xinit_rops() /* Load the array of rasterop values. */ X{ X rops[(int) RRPL] = GXcopy ; X rops[(int) RXOR] = GXxor ; X rops[(int) RCLR] = GXclear ; X rops[(int) RSET] = GXset ; X rops[(int) RINV] = GXinvert ; X} X X X#ifdef SUN_ARROW_KEYS X/* Get information about the keyboard mappings. Determine which keys are X * keypad. X */ X Xstatic void Xkey_init() X{ X int i, j ; X KeySym *tmp ; X KeySym ks ; X X XDisplayKeycodes(dpy, &kcmin, &kcmax) ; X tmp = XGetKeyboardMapping(dpy, kcmin, 1, &keysyms_per_key) ; X XFree((char *) tmp) ; X X kparray = (unsigned char *) malloc((unsigned) (kcmax - kcmin + 1)) ; X X/* For each key, run through its list of keysyms. If this keysym is a X * keypad keysym, we know this key is on the keypad. Mark it as such in X * kparray[]. X */ X X for (i = kcmin; i <= kcmax; ++i) X { X kparray[i - kcmin] = 0 ; X for (j = 0; j < keysyms_per_key; ++j) X { X ks = XKeycodeToKeysym(dpy, i, j) ; X if (IsKeypadKey(ks)) X { X kparray[i - kcmin] = 1 ; X break ; X } X } X } X} X X X/* Given a keyboard event from the keypad, return the KP_whatever keysym X * corresponding to the key in the event. If no keypad keysym can be found, X * returns NoSymbol. X */ X Xstatic KeySym Xkeypad_keysym(event) XEvent *event ; X{ X int i ; X int keycode = event_xevent(event)->xkey.keycode ; X KeySym ks ; X X for (i = 0; i < keysyms_per_key; ++i) X { X ks = XKeycodeToKeysym(dpy, keycode, i) ; X if (IsKeypadKey(ks)) return(ks) ; X } X return(NoSymbol) ; X} X#endif /*SUN_ARROW_KEYS*/ X X Xvoid Xload_image(itype, cbuf) Xenum icon_type itype ; Xunsigned char *cbuf ; X{ X images[(int) itype] = XCreatePixmapFromBitmapData(dpy, xid, (char *) cbuf, X 64, 64, 1, 0, 1) ; X} X X X/* Get the resource databases. These are looked for in the following ways: X * X * Classname file in the app-defaults directory. In this case, Classname X * is Reve. X * X * Classname file in the directory specified by the XUSERFILESEARCHPATH X * or XAPPLRESDIR environment variable. X * X * Property set using xrdb, accessible through the XResourceManagerString X * macro or, if that is empty, the ~/.Xdefaults file. X * X * XENVIRONMENT environment variable or, if not set, .Xdefaults-hostname X * file. X */ X Xvoid Xload_resources() X{ X XrmDatabase db ; X char *home, name[MAXPATHLEN], *ptr ; X int len ; X X home = getenv("HOME") ; X XrmInitialize() ; X STRCPY(name, "/usr/lib/X11/app-defaults/Sidtool") ; X X/* Get applications defaults file, if any. */ X X db = XrmGetFileDatabase(name) ; X XrmMergeDatabases(db, &sidtool_DB) ; X X/* Merge server defaults, created by xrdb. If nor defined, use ~/.Xdefaults. */ X X if (XResourceManagerString(dpy) != NULL) X db = XrmGetStringDatabase(XResourceManagerString(dpy)) ; X else X { X SPRINTF(name, "%s/.Xdefaults", home) ; X db = XrmGetFileDatabase(name) ; X } X XrmMergeDatabases(db, &sidtool_DB) ; X X/* Open XENVIRONMENT file or, if not defined, the .Xdefaults, and merge X * into existing database. X */ X X if ((ptr = getenv("XENVIRONMENT")) == NULL) X { X SPRINTF(name, "%s/.Xdefaults-", home) ; X len = strlen(name) ; X GETHOSTNAME(name+len, MAXPATHLEN-len) ; X db = XrmGetFileDatabase(name) ; X } X else db = XrmGetFileDatabase(ptr) ; X XrmMergeDatabases(db, &sidtool_DB) ; X} X X X/*ARGSUSED*/ XNotify_value Xmain_loop(client, itimer_type) XNotify_client client ; Xint itimer_type ; X{ X next_state() ; /* Next step through the automation. */ X return(NOTIFY_DONE) ; X} X X Xvoid Xmake_x_stuff(f, c) XFrame f ; XCanvas c ; X{ X char nullcur_data[32] ; X Drawable svxid ; X Server_image nullsv ; X X canvas = c ; X frame = f ; X dpy = (Display *) xv_get(f, XV_DISPLAY) ; X pw = canvas_paint_window(c) ; X xid = (Window) xv_get(pw, XV_XID) ; X screen = DefaultScreen(dpy) ; X foregnd = BlackPixel(dpy, screen) ; X backgnd = WhitePixel(dpy, screen) ; X depth = DefaultDepth(dpy, screen) ; X X gc_mask = GCForeground | GCBackground | GCGraphicsExposures ; X gc_val.foreground = foregnd ; X gc_val.background = backgnd ; X gc_val.function = GXcopy ; X gc_val.graphics_exposures = False ; X gc = XCreateGC(dpy, xid, gc_mask, &gc_val) ; X X textgc = XCreateGC(dpy, xid, gc_mask, &gc_val) ; X if (depth > 1) XSetForeground(dpy, textgc, foregnd ^ backgnd) ; X X ropgc = XCreateGC(dpy, xid, gc_mask, &gc_val) ; X XSetFillStyle(dpy, ropgc, FillStippled) ; X X scratch = XCreatePixmap(dpy, xid, 64, 64, 1) ; X X if ((nfont = XLoadQueryFont(dpy, NFONT)) == NULL) X { X FPRINTF(stderr, "%s: can't open normal screen font.\n", progname) ; X exit(1) ; X } X if ((bfont = XLoadQueryFont(dpy, BFONT)) == NULL) X { X FPRINTF(stderr, "%s: can't open bold screen font.\n", progname) ; X exit(1) ; X } X XSetFont(dpy, gc, nfont->fid) ; X X MEMSET(nullcur_data, 0, 32) ; X nullsv = (Server_image) xv_create(XV_NULL, SERVER_IMAGE, X XV_HEIGHT, 16, X XV_WIDTH, 16, X SERVER_IMAGE_BITS, nullcur_data, X 0) ; X offcursor = xv_create(XV_NULL, CURSOR, X CURSOR_IMAGE, nullsv, X 0) ; X X svxid = (Drawable) xv_get(nullsv, XV_XID) ; X gc_mask = GCForeground | GCBackground ; X gc_val.foreground = 1 ; X gc_val.background = 0 ; X svgc = XCreateGC(dpy, svxid, gc_mask, &gc_val) ; X X cursor = (Xv_cursor) xv_get(pw, WIN_CURSOR) ; X XV_SET(pw, WIN_CONSUME_EVENTS, LOC_MOVE, 0, 0) ; X#ifdef WANTED X XV_SET(c, CANVAS_RETAINED, retained, 0) ; X#endif /*WANTED*/ X} X X Xvoid Xposition_popup(wtype) Xenum win_type wtype ; X{ X Frame child ; X Rect crect, prect ; X int width ; X X if (wtype == W_PROPS) child = Sidtool_Pprops->Pprops ; X else if (wtype == W_SCORES) child = Sidtool_Pscores->Pscores ; X if ((int) xv_get(child, XV_SHOW)) return ; X frame_get_rect(Sidtool_Wmain->Wmain, &prect) ; X frame_get_rect(child, &crect) ; X width = (int) xv_get(Sidtool_Wmain->Wmain, XV_WIDTH) ; X X switch ((int) wtype) X { X case W_PROPS : crect.r_left = prect.r_left + width + BORDER_SIZE ; X crect.r_top = prect.r_top ; X break ; X case W_SCORES : crect.r_left = prect.r_left + width + BORDER_SIZE ; X crect.r_top = prect.r_top + 150 ; X } X frame_set_rect(child, &crect) ; X} X X Xvoid Xsave_cmdline(line) /* Save user supplied command line options. */ Xchar *line ; X{ X if (cmdline != NULL) FREE(cmdline) ; X cmdline = (char *) malloc((unsigned int) strlen(line) + 1) ; X STRCPY(cmdline, line) ; X XV_SET(frame, WIN_CMD_LINE, cmdline, 0) ; X} X X XPanel_setting XSnotify(item, event) XPanel_item item ; XEvent *event ; X{ X STRCPY(allhighscores[skilllevel].who, (char *) xv_get(item, PANEL_VALUE)) ; X savescorefile() ; X set_list(skilllevel) ; X set_timer(TRUE) ; X X XV_SET(Sidtool_Pscores->MShighscore, XV_SHOW, TRUE, 0) ; X XV_SET(Sidtool_Pscores->MSoldscore, XV_SHOW, TRUE, 0) ; X XV_SET(Sidtool_Pscores->MSplayer, XV_SHOW, TRUE, 0) ; X XV_SET(Sidtool_Pscores->MSname, XV_SHOW, TRUE, 0) ; X X progstate = DOCREDIT ; X return panel_text_notify(item, event) ; X} X X Xvoid Xset_choice(ctype, val) Xenum choice_type ctype ; Xint val ; X{ X switch ((int) ctype) X { X case C_PLAY : XV_SET(Sidtool_Wmain->SETgame, PANEL_VALUE, val, 0) ; X } X} X X Xvoid Xset_cursor(state) Xint state ; X{ X if (state) XV_SET(pw, WIN_CURSOR, cursor, 0) ; X else XV_SET(pw, WIN_CURSOR, offcursor, 0) ; X} X X Xvoid Xset_highscore(level) Xint level ; X{ X char buffer[MAXLINE] ; X X SPRINTF(buffer, X "Player %1d has beaten the high score for skill level %1d.", X highplayer, level) ; X XV_SET(Sidtool_Pscores->MShighscore, PANEL_LABEL_STRING, buffer, 0) ; X XV_SET(Sidtool_Pscores->MShighscore, XV_SHOW, TRUE, 0) ; X X if (allhighscores[skilllevel].score) X { X SPRINTF(buffer, "The old record was %1d0 held by: %s.", X allhighscores[skilllevel].score, X allhighscores[skilllevel].who) ; X XV_SET(Sidtool_Pscores->MSoldscore, PANEL_LABEL_STRING, buffer, 0) ; X XV_SET(Sidtool_Pscores->MSoldscore, XV_SHOW, TRUE, 0) ; X } X X SPRINTF(buffer, "Type player %1d's name or initials: ", highplayer) ; X XV_SET(Sidtool_Pscores->MSplayer, PANEL_LABEL_STRING, buffer, 0) ; X XV_SET(Sidtool_Pscores->MSplayer, XV_SHOW, TRUE, 0) ; X X XV_SET(Sidtool_Pscores->MSname, XV_SHOW, TRUE, 0) ; X} X X Xvoid Xset_image(image, icon, rop) Xenum image_type image ; Xenum icon_type icon ; Xenum rop_type rop ; X{ X Drawable ixid ; X Panel_item p ; X Server_image sv ; X X switch ((int) image) X { X case CNTR1 : p = Sidtool_Wmain->Mcounter1 ; X break ; X case CNTR2 : p = Sidtool_Wmain->Mcounter2 ; X break ; X case CNTR3 : p = Sidtool_Wmain->Mcounter3 ; X break ; X case CNTR4 : p = Sidtool_Wmain->Mcounter4 ; X break ; X case CURFRUIT : p = Sidtool_Wmain->Mfruitpic ; X } X sv = (Server_image) xv_get(p, PANEL_LABEL_IMAGE) ; X ixid = (Drawable) xv_get(sv, XV_XID) ; X X XSetFunction(dpy, svgc, rops[(int) rop]) ; X XCopyArea(dpy, images[(int) icon], ixid, svgc, 0, 0, 50, 50, 0, 0) ; X XV_SET(p, XV_SHOW, TRUE, 0) ; X} X X Xvoid Xset_label(btype) Xenum but_type btype ; X{ X XV_SET(Sidtool_Wmain->Bstop, PANEL_LABEL_STRING, but_names[(int) btype], 0) ; X} X X Xvoid Xset_list(level) Xint level ; X{ X char buffer[MAXLINE] ; X X SPRINTF(buffer, "%1d: %s - %1d0", X level, allhighscores[level].who, allhighscores[level].score) ; X XV_SET(Sidtool_Pscores->Lscores, PANEL_LIST_STRING, level-1, buffer, 0) ; X} X X Xvoid Xset_score(stype, score) /* Set auto, player or high score in panel. */ Xint stype, score ; X{ X Panel_item p ; X char s[MAXLINE] ; X int show = TRUE ; X X if (stype >= 1 && stype <= 4) show = on ; X score *= 10 ; X if (stype == AUTO_SCORE) SPRINTF(s, "%1d (AUTO)", score) ; X else if (stype == HIGH_SCORE) SPRINTF(s, "(%1d) %1d", skilllevel, score) ; X else SPRINTF(s, "%1d", score) ; X X switch (stype) X { X case AUTO_SCORE : X case 1 : p = Sidtool_Wmain->Mscore1 ; X break ; X case 2 : p = Sidtool_Wmain->Mscore2 ; X break ; X case 3 : p = Sidtool_Wmain->Mscore3 ; X break ; X case 4 : p = Sidtool_Wmain->Mscore4 ; X break ; X case FRUIT_SCORE : p = Sidtool_Wmain->Mfruitval ; X break ; X case HIGH_SCORE : p = Sidtool_Wmain->Mhscore ; X } X XV_SET(p, X PANEL_LABEL_STRING, s, X XV_SHOW, show, X 0) ; X} X X Xvoid Xset_timer(state) Xint state ; X{ X NOTIFY_SET_ITIMER_FUNC(Sidtool_Wmain->Wmain, X state ? (Notify_func) main_loop : X NOTIFY_FUNC_NULL, X ITIMER_REAL, &NOTIFY_POLLING_ITIMER, X ((struct itimerval *) 0)) ; X} X X Xvoid Xset_value(ptype, value) Xenum prop_type ptype ; Xint value ; X{ X if (ptype == P_PLAYERS) X XV_SET(Sidtool_Pprops->SETplayer, PANEL_VALUE, value-1, 0) ; X else if (ptype == P_SKILL) X XV_SET(Sidtool_Pprops->SLlevel, PANEL_VALUE, value, 0) ; X} X X Xvoid Xshow_window(wtype, state) /* [Un]show property or score popup. */ Xenum win_type wtype ; Xint state ; X{ X Frame f ; X X switch ((int) wtype) X { X case W_PROPS : f = Sidtool_Pprops->Pprops ; X break ; X case W_SCORES : f = Sidtool_Pscores->Pscores ; X } X if (!state && (int) xv_get(f, FRAME_PROPS_PUSHPIN_IN)) return ; X XV_SET(f, XV_SHOW, state, 0) ; X} X X Xvoid Xwarp_mouse() X{ X XV_SET(canvas, X WIN_MOUSE_XY, (int) xv_get(canvas, XV_WIDTH) / 2, X (int) xv_get(canvas, XV_HEIGHT) / 2, 0) ; X} END_OF_FILE if test 24979 -ne `wc -c <'xview.c'`; then echo shar: \"'xview.c'\" unpacked with wrong size! fi # end of 'xview.c' fi echo shar: End of archive 1 \(of 7\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 5 6 7 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 7 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0