[comp.sources.games] v01i018: sidtool - pacman game for Suns, Part01/05

games-request@tekred.UUCP (05/16/87)

Submitted by: Rich Burridge <munnari!sunk.oz!richb@seismo.css.gov>
Comp.sources.games: Volume 1, Issue 18
Archive-name: sidtool/Part01

	[I've actually tried this on our Sun50.  It's pretty neat.
	 This version *includes* the first official patch for the
	 game.  Note that the default is for the support files to
	 be in the same directory as the game.  Edit "sidtool.h"
	 if you want to change this.  Note also that the mouse
	 cursor has to be inside the sidtool window for it to
	 recognize the DEL key.   -br]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 5)."
# Contents:  README MANIFEST images images/animate.c release sid_blt.c
#   sid_main.c
# Wrapped by billr@tekred on Tue May 12 09:16:27 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(1865 characters\)
sed "s/^X//" >README <<'END_OF_README'
X
X  Welcome to sidtool version 2.1.  -  April 1987.
X
XThis software is the second major release of the Sun Interactive
XDebugger program, better known as sidtool. It probably still
Xcontains bugs (and features). Should you find any of these, I
Xwould be pleased to hear about them, and try to remove them.
X
XThis software will only work correctly with SunOS v3.2 or later.
XWith a small effort, it could probably be made to run under v3.0,
Xbut this is not supported.
X
XSETUP.
XNote there is a #define in sidtool.h called SPEED. Experimentation
Xwith this should give a better timing for other machines such as 
XSun2s and the 3/260s.
X
XUnpack these files into a directory, alter the BINDIR line in
Xthe top level Makefile to be where you want the sidtool release
Xto be put, and type "make install".
X
XDISCLAIMER.
XThis software was developed and tested on a 3/50. It is recognised
Xthat this software runs slowly on Sun2s, and that there are
Xprobably timing problems on other Sun3s. If you find a good pause
Xfactor, please let me know.
X
XOPTIONS.
XThere are a few command line options for alternately specifying
Xwhere some of the files used by sidtool can be found. These are:
X
X -afilename   -  New animate filename.
X -cspeed      -  New class (speed) of machine.
X -d           -  Run in self demonstration mode.
X -hfilename   -  New help filename.
X -mfilename   -  New maze filename.
X -sfilename   -  New high score filename.
X
XThe replacement filenames can also be specified by environment
Xvariables. These are:
X
X SID_MAZE    -  New maze filename.
X SID_ANIMATE -  New animate filename.
X SID_SCORE   -  New high score filename.
X SID_HELP    -  New help filename.
X
XKNOWN BUGS AND FEATURES:    None known.
X
XHave fun,
X
X  Rich Burridge,         SUN Microsystems Australia (Melbourne).
X  Tel:  +61 59 962672.   UUCP:  sun!sunaus!sunk!richb
X                         ACSnet:  richb@sunk.oz
END_OF_README
if test 1865 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f MANIFEST -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"MANIFEST\"
else
echo shar: Extracting \"MANIFEST\" \(2394 characters\)
sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X INTRO                     4	
X MANIFEST                  1	This shipping list
X Makefile                  4	
X README                    1	
X README_v30                4	
X TO_DO                     5	
X bltstuff.h                4	
X images                    1	
X images/BASHFUL0.pic       3	
X images/BASHFUL1.pic       3	
X images/Makefile           2	
X images/POKEY0.pic         4	
X images/POKEY1.pic         4	
X images/SHADOW0.pic        4	
X images/SHADOW1.pic        4	
X images/SPEEDY0.pic        4	
X images/SPEEDY1.pic        4	
X images/animate.c          1	
X images/blueghost0.pic     3	
X images/blueghost1.pic     2	
X images/bluepics0.pic      3	
X images/bluepics1.pic      3	
X images/cirDOWN0.pic       3	
X images/cirDOWN1.pic       3	
X images/cirDOWN2.pic       3	
X images/cirDOWN3.pic       3	
X images/cirLEFT0.pic       3	
X images/cirLEFT1.pic       3	
X images/cirLEFT2.pic       3	
X images/cirLEFT3.pic       3	
X images/cirRIGHT0.pic      3	
X images/cirRIGHT1.pic      3	
X images/cirRIGHT2.pic      3	
X images/cirRIGHT3.pic      3	
X images/cirUP0.pic         4	
X images/cirUP1.pic         4	
X images/cirUP2.pic         4	
X images/cirUP3.pic         4	
X images/circleexplode0.pic 2	
X images/circleexplode1.pic 2	
X images/circleexplode2.pic 2	
X images/circleexplode3.pic 2	
X images/circleexplode4.pic 2	
X images/circleexplode5.pic 2	
X images/circleexplode6.pic 2	
X images/circleexplode7.pic 2	
X images/circleexplode8.pic 2	
X images/cornerDL.pic       4	
X images/cornerLU.pic       3	
X images/cornerRD.pic       3	
X images/cornerUR.pic       3	
X images/eyesDOWN.pic       3	
X images/eyesLEFT.pic       3	
X images/eyesRIGHT.pic      3	
X images/eyesUP.pic         4	
X images/fruit1.pic         4	
X images/fruit2.pic         4	
X images/fruit3.pic         4	
X images/fruit4.pic         4	
X images/fruit5.pic         4	
X images/fruit6.pic         4	
X images/fruit7.pic         4	
X images/fruit8.pic         4	
X images/picbigdot.pic      3	
X images/picsmalldot.pic    2	
X main.cursor               5	
X patchlevel.h              4	
X release                   1	
X sid_blt.c                 1	
X sid_main.c                1	
X sid_stuff.c               2	
X sid_sun.c                 2	
X sidtool.h                 2	
X sidtool.help              4	
X sidtool.icon              4	
X sidtool.maze              2	
END_OF_MANIFEST
if test 2394 -ne `wc -c <MANIFEST`; then
    echo shar: \"MANIFEST\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test ! -d images ; then
    echo shar: Creating directory \"images\"
    mkdir images
fi
if test -f images/animate.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"images/animate.c\"
else
echo shar: Extracting \"images/animate.c\" \(4180 characters\)
sed "s/^X//" >images/animate.c <<'END_OF_images/animate.c'
X
X/*  animate.c
X *
X *  Make the debugger.animate file from the individual icons.
X *  Written by Rich Burridge - Sun Microsystems Australia (Melbourne).
X *
X *  Version 2.1.  -  April 1987.
X *
X *  No responsibility is taken for any errors or 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 <stdio.h>
X#include <strings.h>
X#include <errno.h>
X
X#define  CLOSE    (void) close      /* To make lint happy. */
X#define  FCLOSE   (void) fclose
X#define  FPRINTF  (void) fprintf
X#define  SSCANF   (void) sscanf
X#define  STRCPY   (void) strcpy
X#define  STRNCPY  (void) strncpy
X#define  WRITE    (void) write
X
X#define  BUFSIZE  512               /* Output buffer size in characters. */
X#define  MAXLINE  256               /* Maximum length of character string. */
X
Xextern int errno ;
X
Xchar progname[MAXLINE] ;            /* Name of this program. */
Xchar filename[MAXLINE] ;            /* Name of the sidtool animate file. */
X
Xint fd ;                            /* File descriptor for animate data. */
X
X
Xgetline(fd,s)      /* Checks each character, and ignore's it if its NULL. */
XFILE *fd ;
Xchar s[MAXLINE] ;
X
X{
X  int c,i ;
X
X  i = 0 ;
X  while (i < MAXLINE-1 && (c = getc(fd)) != EOF && c != '\n')
X  if (c != '\0') s[i++] = c ;
X
X  if (c == EOF) return ;
X  if (c == '\n') s[i++] = c ;
X  s[i] = '\0' ;
X}
X
X
Xload_cursor(name)
Xchar name[MAXLINE] ;
X
X{
X  unsigned short buf[BUFSIZE/2] ;
X  int i,j,temp ;
X  char arg[MAXLINE],line[MAXLINE] ;
X  FILE *fin,*fopen() ;
X
X  if ((fin = fopen(name,"r")) == NULL)
X    {
X      FPRINTF(stderr,"%s: can't open %s.\n",progname,name) ;
X      exit(1) ;
X    }
X  getline(fin,line) ;
X  getline(fin,line) ;
X  for (i = 0; i < 32; i++)
X    {
X      getline(fin,line) ;
X      for (j = 0; j < 8; j++)
X        {
X          STRNCPY(&arg[0],&line[j*7+3],4) ;
X          arg[4] = '\0' ;
X          SSCANF(arg,"%X",&temp) ;
X          buf[i*8+j] = (short) temp ;
X        }
X    }
X  WRITE(fd,(char *) buf,BUFSIZE) ;
X  FCLOSE(fin) ;
X}
X
X
X/*ARGSUSED*/
Xmain(argc,argv)
Xint argc ;
Xchar *argv[] ;
X
X{
X  STRCPY(progname,argv[0]) ;
X  STRCPY(filename,"sidtool.animate") ;
X  if ((fd = open(filename,2)) == -1)
X    if ((fd = creat(filename,0777)) == -1)
X      {
X        FPRINTF(stderr,"\n%s: unable to create %s.\n",progname,filename) ;
X        exit(1) ;
X      }
X
X  load_cursor("cornerUR.pic") ;
X  load_cursor("cornerRD.pic") ;
X  load_cursor("cornerDL.pic") ;
X  load_cursor("cornerLU.pic") ;
X
X  load_cursor("picbigdot.pic") ;
X  load_cursor("picsmalldot.pic") ;
X
X  load_cursor("cirRIGHT0.pic") ;
X  load_cursor("cirRIGHT1.pic") ;
X  load_cursor("cirRIGHT2.pic") ;
X  load_cursor("cirRIGHT3.pic") ;
X
X  load_cursor("cirUP0.pic") ;
X  load_cursor("cirUP1.pic") ;
X  load_cursor("cirUP2.pic") ;
X  load_cursor("cirUP3.pic") ;
X
X  load_cursor("cirLEFT0.pic") ;
X  load_cursor("cirLEFT1.pic") ;
X  load_cursor("cirLEFT2.pic") ;
X  load_cursor("cirLEFT3.pic") ;
X
X  load_cursor("cirDOWN0.pic") ;
X  load_cursor("cirDOWN1.pic") ;
X  load_cursor("cirDOWN2.pic") ;
X  load_cursor("cirDOWN3.pic") ;
X
X  load_cursor("POKEY0.pic") ;
X  load_cursor("POKEY1.pic") ;
X
X  load_cursor("BASHFUL0.pic") ;
X  load_cursor("BASHFUL1.pic") ;
X
X  load_cursor("SPEEDY0.pic") ;
X  load_cursor("SPEEDY1.pic") ;
X
X  load_cursor("SHADOW0.pic") ;
X  load_cursor("SHADOW1.pic") ;
X
X  load_cursor("blueghost0.pic") ;
X  load_cursor("blueghost1.pic") ;
X
X  load_cursor("bluepics0.pic") ;
X  load_cursor("bluepics1.pic") ;
X
X  load_cursor("eyesRIGHT.pic") ;
X  load_cursor("eyesUP.pic") ;
X  load_cursor("eyesLEFT.pic") ;
X  load_cursor("eyesDOWN.pic") ;
X
X  load_cursor("circleexplode0.pic") ;
X  load_cursor("circleexplode1.pic") ;
X  load_cursor("circleexplode2.pic") ;
X  load_cursor("circleexplode3.pic") ;
X  load_cursor("circleexplode4.pic") ;
X  load_cursor("circleexplode5.pic") ;
X  load_cursor("circleexplode6.pic") ;
X  load_cursor("circleexplode7.pic") ;
X  load_cursor("circleexplode8.pic") ;
X
X  load_cursor("fruit1.pic") ;
X  load_cursor("fruit2.pic") ;
X  load_cursor("fruit3.pic") ;
X  load_cursor("fruit4.pic") ;
X  load_cursor("fruit5.pic") ;
X  load_cursor("fruit6.pic") ;
X  load_cursor("fruit7.pic") ;
X  load_cursor("fruit8.pic") ;
X  CLOSE(fd) ;
X}
END_OF_images/animate.c
if test 4180 -ne `wc -c <images/animate.c`; then
    echo shar: \"images/animate.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test ! -d release ; then
    echo shar: Creating directory \"release\"
    mkdir release
fi
if test -f sid_blt.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"sid_blt.c\"
else
echo shar: Extracting \"sid_blt.c\" \(21194 characters\)
sed "s/^X//" >sid_blt.c <<'END_OF_sid_blt.c'
X
X/*  sid_blt.c
X *
X *  Various routines that do "rasterop" type graphics used by sidtool.
X *
X *  Written by Rich Burridge - SUN Microsystems Australia (Melbourne).
X *
X *  Version 2.1.  -  April 1987.
X *
X *  No responsibility is taken for any errors inherent either to the code
X *  or the comments of this program, but if reported to me then an attempt
X *  will be made to fix them.
X */
X
X#include <stdio.h>
X#include <strings.h>
X#include <setjmp.h>
X#include "bltstuff.h"
X#include "sidtool.h"
X#include <sys/types.h>
X#include <sys/timeb.h>
X#include <suntool/sunview.h>
X#include <suntool/canvas.h>
X
Xextern jmp_buf exception ;
Xextern int val ;
X
Xextern Pixfont *pf ;
Xextern Pixwin *pw ;
X
X/* For descriptions of these variables, see sid_main.c */
X
Xextern BOOLEAN autoplay,demomode,remove ;
X
Xextern char a_name[MAXLINE],buffer[MAXLINE],but_names[7][8],h_name[MAXLINE] ;
Xextern char m_name[MAXLINE],maze[XSIZE+2][YSIZE+2],names[4][MAXLINE],sc ;
Xextern char titlestring[MAXLINE] ;
X
Xextern int autoscore,blueblink,blueincblink,boxx,boxy,button,c,circatchup ;
Xextern int cirmx,cirmy,cirx,ciry,count,credits,curbluetime[MAXNUMPLAYERS+1] ;
Xextern int curdir,dots[MAXNUMPLAYERS+1][XSIZE+4][YSIZE+2],dotx,doty ;
Xextern int fruitchances[MAXNUMPLAYERS+1],fruiton,fruittime,fruitx,fruity ;
Xextern int fruitmaze[MAXNUMPLAYERS+1],g,gamestate,height,highplayer ;
Xextern int highscore,inc,movei,movej,movex,newdir,numcir[MAXNUMPLAYERS+1] ;
Xextern int numdots[MAXNUMPLAYERS+1],nx,ny,oldcurdir,oldcx,oldcy,orgx,orgy ;
Xextern int pausetime,player,posx,posy,progstate,score[MAXNUMPLAYERS+1] ;
Xextern int sfunc,skilllevel,speed,tunnel[XSIZE+4][YSIZE+2],walls[XSIZE+6][YSIZE+1] ;
Xextern int width,x,y ;
X
Xextern Pixrect *load_picture() ;
Xextern long random() ;
X
Xextern Pixrect *bigdot,*bluebug[2],*bluepics[2],*bugpics[4][2],*circleexplode[9] ;
Xextern Pixrect *circles[4][4],*corner[4],*curcircle,*eyes[4],*fruitpics[9] ;
Xextern Pixrect *smalldot ;
X
Xextern struct bugrec  bugs[4] ;         /* The bad guys. */
Xextern struct scorerec allhighscores[11] ;
Xextern struct startrec startpos[4] ;
X
X
Xclear_screen()
X
X{
X  BLT_SCRN(orgx,orgy,width,height,RCLR) ;
X
X/*  To get over displaying the last cursor incorrectly after a cleared screen,
X *  the old cursor position is forced off the screen.
X */
X
X  oldcx = 1000 ;
X  oldcy = 1000 ;
X}
X
X
Xddrawline(mx,my,dir)
Xint mx,my,dir ;
X
X/*  Draw a maze line from mx,my in the direction dir.
X *  Parameters: dir should be d,u,l,r, (or R for a thin line).
X */
X
X{
X  int x,y ;
X
X  TRANSPT(mx,my,x,y) ;
X  switch (dir)
X    {
X      case 'd' :
X      case 'u' : BLT_SCRN(x+SQUARE/2,y,2,SQUARE,RSET) ;
X                 break ;
X      case 'l' :
X      case 'r' : BLT_SCRN(x,y+SQUARE/2,SQUARE,2,RSET) ;
X                 break ;
X      case 'R' : BLT_SCRN(x,y+SQUARE/2,SQUARE,1,RSET) ;
X    }
X}
X
X
Xdrawbug(g)
Xregister struct bugrec *g ;
X 
X{
X  int inc,winc ;
X 
X  inc = g->scrx - GOFFSET ;
X  winc = 0 ;
X 
X  if (inc < 0)
X    if (inc <= 45) return ;
X    else  winc = inc ;
X  else if (inc > SWIDTH-45)
X    if (inc > SWIDTH - 1) return ;
X    else
X      {
X        winc = SWIDTH-45-inc ;
X        inc = 0 ;
X      }
X  else inc = 0 ;
X
X  if (g->eyesonly)
X    {
X      BLT_MEM_TO_SCRN(g->scrx-GOFFSET-inc,g->scry-GOFFSET,
X                      45+winc,21,RXOR,eyes[g->dir],-inc,0) ;
X/* Fake BLT to get speed same. */
X      BLT_MEM(bugpics[GIND(g)][g->pic],0,0,45+winc,21,RRPL,
X              bugpics[GIND(g)][g->pic],0,0) ;
X    }
X  else if (g->bluetime > 0)
X    {
X      if ((g->bluetime < blueblink) &&
X          (g->bluetime % blueincblink > blueincblink / 2))
X        BLT_MEM_TO_SCRN(g->scrx-GOFFSET-inc,g->scry-GOFFSET,
X                        45+winc,45,RXOR,bluepics[g->pic],-inc,0) ;
X      else
X        BLT_MEM_TO_SCRN(g->scrx-GOFFSET-inc,g->scry-GOFFSET,
X                        45+winc,45,RXOR,bluebug[g->pic],-inc,0) ;
X/* Fake BLT to get speed same. */
X      BLT_MEM(eyes[g->dir],0,0,45+winc,21,RRPL,eyes[g->dir],0,0) ;
X    }
X  else
X    { 
X      BLT_MEM_TO_SCRN(g->scrx-GOFFSET-inc,g->scry-GOFFSET,
X                      45+winc,45,RXOR,bugpics[GIND(g)][g->pic],-inc,0) ;
X      BLT_MEM_TO_SCRN(g->scrx-GOFFSET-inc,g->scry-GOFFSET,
X                      45+winc,21,RXOR,eyes[g->dir],-inc,0) ;
X    }
X}
X
X
Xdrawcir(p,x,y)             /* Draw the specified screen on the screen. */
Xint x,y ;
XPixrect *p ;
X
X{
X  if (x < 0) return ;                   /* Fully off left side. */
X  else if (x > SWIDTH+1) return ;       /* Fully off right side. */
X
X  if (!(oldcx == x && oldcy == y))
X    {
X      BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X      curcircle = p ;
X      BLT_MEM_TO_SCRN(x-GOFFSET+5,y-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X      oldcx = x ;
X      oldcy = y ;
X    }
X}
X
X
Xdrawcorner(mx,my,dir)
Xint dir,mx,my ;
X
X/*  Draw a corner at MAZE position mx,my turning the direction dir. */
X
X{
X  int x,y ;
X
X  TRANSPT(mx,my,x,y) ;
X  BLT_MEM_TO_SCRN(x,y,SQUARE,SQUARE,RRPL,corner[dir],0,0) ;
X}
X 
X 
Xdrawdot(mx,my,size)        /* XORS a dot at the maze position mx,my. */
Xint mx,my,size ;
X
X{
X   TRANSPT(mx,my,mx,my) ;
X   if (size == BIGDOT) BLT_MEM_TO_SCRN(mx,my,24,24,RXOR,bigdot,0,0) ;
X   else if (size == SMALLDOT) BLT_MEM_TO_SCRN(mx+9,my+9,7,7,RXOR,smalldot,9,9) ;
X}
X
X
Xdrawmaze()     /* Draw the maze,the dots,the scores, etc on the screen. */
X 
X{
X  int x,y ;
X 
X  clear_screen() ;
X  for (y = 0; y <= YSIZE+1; y++)
X    {
X      walls[1][y] = 1 ;
X      walls[0][y] = 1 ;
X      walls[XSIZE+4][y] = 1 ;
X      walls[XSIZE+5][y] = 1 ;
X      for (x = 0; x <= XSIZE+1; x++) walls[x+2][y] = 0 ;
X    }
X 
X  for (y = 0; y <= YSIZE+1; y++)
X    for (x = 0; x <= XSIZE+1; x++)
X      if ((maze[x][y] == 's') || (maze[x][y] == 'S') || (maze[x][y] == 'T'))
X        drawbox(x,y) ;
X      else if (maze[x][y] == 'x') walls[x+2][y] = 1 ;   /* Borders. */
X 
X  PPAUSE(pausetime*30) ;
X  BLT_SCRN(XBASE-(SQUARE/2)-2,YBASE-(SQUARE/2)-2,
X                  SQUARE*(XSIZE+1)+6,SQUARE*(YSIZE+1)+6,RINV) ;
X  fixexits() ;
X
X  for (y = 1; y <= YSIZE; y++)
X    for (x = 1; x <= XSIZE; x++)
X      if (dots[player][x+1][y] == SMALLDOT)
X        {
X          PPAUSE(pausetime*5) ;
X          drawdot(x,y,SMALLDOT) ;
X        }
X      else if (dots[player][x+1][y] == BIGDOT)
X        {
X          PPAUSE(pausetime*5) ;
X          drawdot(x,y,BIGDOT) ;
X        }
X
X  for (x = 1; x <= 4; x++) showplayerscore(x) ;
X
X  SPRINTF(buffer,"High Score (%1d)",skilllevel) ;
X  WRITELN(310,20,buffer) ;
X  if (!highscore) WRITELN(348,35,"0") ;
X  else
X    { 
X      SPRINTF(buffer,"%1d0",highscore) ;
X      WRITELN(348,35,buffer) ;
X    }
X
X  for (x = 1; x <= numcir[player]; x++)
X    {
X      PPAUSE(pausetime*30) ;
X      BLT_MEM_TO_SCRN(30+(x-1)*60,20,50,50,RXOR,circles[RIGHT][0],0,0) ;
X    }
X
X  BLT_MEM_TO_SCRN(705,25,45,45,RRPL,fruitpics[fruitmaze[player]],0,0) ;
X  BLT_SCRN(700,20,55,55,RINV) ;
X  SPRINTF(buffer,"%1d0",fruitscore(fruitmaze[player])) ;
X  WRITELN(710,15,buffer) ;
X
X  if (autoplay && (!demomode))
X    {
X      SCHRFUNC(RXOR) ;
X      WRITELN(339,YBASE+SQUARE*16,"GAME OVER!") ;
X      SCHRFUNC(RRPL) ;
X      WRITELN(300,65,"Type DEL to begin") ;
X      WRITELN(480,50,"Auto Score") ;
X      WRITELN(489,65,"0") ;
X    }
X}
X
X
Xdocredits()
X 
X{
X  int g,x,y,i,j ;
X 
X  credits = 1 ;
X  clear_screen() ;
X  dohelp() ;
X  WRITELN(5,860,"Type DEL to begin") ;
X  for (i = 0; i < 100; i++) LONGPAUSE() ;
X
X  newbugs(0) ;
X  UNTRANSPT(130,350,dotx,doty) ;
X  UNTRANSPT(860,350,x,y) ;
X  TRANSPT(x,y,i,ciry) ;
X  BLT_SCRN(3,ciry-37,762,100,RINV) ;
X
X  for (g = POKEY; g <= SHADOW; g++)
X    {
X      bugs[g].mx = x + g * 2 ;
X      bugs[g].my = doty ;
X      bugs[g].dir = g ;
X      TRANSPT(bugs[g].mx,bugs[g].my,bugs[g].scrx,bugs[g].scry) ;
X      drawbug(&bugs[g]) ;                        /* Should be invisible. */
X    }
X  drawdot(dotx,doty,BIGDOT) ;
X  cirx = 720 ;
X  inc = 0 ;
X  movei = 1 ;
X  progstate = MOVELEFT ;
X}
X
X
Xmove_left()      /* Animate screen and bugs left. */
X
X{
X  int g ;
X
X  if (movei % 8) cirx-- ;
X  drawcir(circles[LEFT][inc],cirx,ciry) ;
X  if (movei % 4 == 0) inc = (inc + 1) % 4 ;
X  for (g = POKEY; g <= SHADOW; g++)
X    {
X      drawbug(&bugs[g]) ;               /* Erase old. */
X      bugs[g].scrx-- ;
X      if (movei % 13 == 0) bugs[g].pic = (bugs[g].pic + 1) % 2 ;
X      if (movei % 18 == 0) bugs[g].dir = (bugs[g].dir + 1) % 4 ;
X      drawbug(&bugs[g]) ;               /* Draw new. */
X    }
X  if (++movei > 662)
X    {
X      credits = 2 ;
X      drawdot(dotx,doty,BIGDOT) ;
X      for (g = POKEY; g <= SHADOW; g++)
X        {
X          drawbug(&bugs[g]) ;           /* Erase old. */
X          bugs[g].bluetime = 32000 ;
X          drawbug(&bugs[g]) ;           /* Draw new as blue. */
X        } 
X      SCHRFUNC(RXOR) ;
X      movej = 200 ;
X      movex = 1 ;
X      movei = 1 ;
X      progstate = MOVERIGHT ;
X    }
X}
X
X
Xmove_right()    /* Animate eating screen and bugs right. */
X
X{
X  int g,i ;
X
X   PPAUSE(8*movex) ;
X   if (movei % 26) cirx++ ;
X   drawcir(circles[RIGHT][inc],cirx,ciry) ;
X   if (movei % 4 == 0) inc = (inc + 1) % 4 ;
X   for (g = POKEY; g <= SHADOW; g++)
X     if (!bugs[g].eyesonly)
X       {
X         drawbug(&bugs[g]) ;            /* Erase old. */
X         if (movei % 2) bugs[g].scrx++ ;
X         if (movei % 13 == 0) bugs[g].pic = (bugs[g].pic + 1) % 2 ;
X         if (cirx >= bugs[g].scrx-20)
X           {
X             bugs[g].eyesonly = 1 ;
X             SPRINTF(buffer,"%1d",movej) ;
X             WRITELN(bugs[g].scrx-20,440,buffer) ;
X             for (i = 0; i < 60; i++) LONGPAUSE() ;
X             SPRINTF(buffer,"%1d",movej) ;
X             WRITELN(bugs[g].scrx-20,440,buffer) ;
X             movej *= 2 ;
X             movex++ ;
X           }
X         else drawbug(&bugs[g]) ;       /* Draw new. */
X       }
X  if (++movei > 665)
X    {
X      SCHRFUNC(RRPL) ;
X      for (i = 0; i < 100; i++) LONGPAUSE() ;
X      credits = 0 ;
X      progstate = INITGAME ;
X    }
X}
X
X
Xdohelp()
X
X{
X  int g,i,x,y ;
X  char line[MAXLINE] ;
X  FILE *fn ;
X
X  write_bold(105,100,titlestring) ;
X  WRITELN(105,120,"Original version by Brad A. Myers with pictures of fruit by Terry Vavra.") ;
X
X  for (g = POKEY; g <= SHADOW; g++)
X    {
X      if (g > 1) y = YBASE + 130 ;
X      else y = YBASE + 50 ;
X      x = (g % 2) ? 384 : 100 ;
X
X      BLT_MEM_TO_SCRN(x,y,45,45,RRPL,bugpics[g][0],0,0) ;
X      BLT_MEM_TO_SCRN(x,y,45,21,RXOR,eyes[g],0,0) ;
X      for (i = 0; i < 40; i++) LONGPAUSE() ;
X      SPRINTF(buffer,"- %s",names[g]) ;
X      WRITELN(x+60,y+25,buffer) ;
X      for (i = 0; i < 40; i++) LONGPAUSE() ;
X    }
X
X  if ((fn = fopen(h_name,"r")) == NULL)
X    {
X      FPRINTF(stderr,"\nsidtool: can't open %s\n",h_name) ;
X      exit(-1) ;
X    }
X  x = 105 ;
X  y = 465 ;
X  i = 0 ;
X  while (get_string(fn,line) != -1)
X    {
X      WRITELN(x,i*15+y,line) ;
X      i++ ;
X    }
X  if (!autoplay) make_control_panel() ;
X  if (!autoplay) display_settings() ;
X}
X
X
Xdoplay()
X
X{
X  if (remove)                /* Jump here if have been eaten or starting new game. */
X    {
X      removecircle() ;
X      numcir[player]-- ;
X    }
X  curdir = LEFT ;             /* Jump here if got all dots. */
X  fruiton = 0 ;
X  sc = ' ' ;
X  inc = 0 ;
X  count = 1 ;
X  posx = (SWIDTH / 2) - 11 ;
X  posy = YBASE + SQUARE * 21 ;
X  fruittime = randomrange(1000,2500) ;
X  UNTRANSPT(posx,posy,cirmx,cirmy) ;
X  drawcir(circles[curdir][inc],posx,posy) ;
X  newbugs(1) ;
X  if (demomode || !autoplay)
X    {
X      SCHRFUNC(RXOR) ;
X      WRITELN(357,YBASE+SQUARE*16,"READY!") ;
X      blinkpause() ;
X      SCHRFUNC(RXOR) ;
X      WRITELN(357,YBASE+SQUARE*16,"READY!") ;
X      SCHRFUNC(RRPL) ;
X    }
X}
X
X
Xmake_play()         /* Perform next movement of each sid tool object. */
X
X{
X  updatebugs() ;
X  if (checkcollision(cirmx,cirmy,&g)) handlecollision(&bugs[g]) ;
X  if (fruittime != -1)
X    {
X      fruittime-- ;
X      if (!fruittime) updatefruit() ;
X    }
X  newdir = curdir ;
X  if (GCENTERED(posx,posy))
X    {
X      if (autoplay)
X        newdir = dorandomdir(curdir,posx,posy,cirmx,cirmy,&x,&y,&nx,&ny,1) ;
X      else
X        switch (curdir)
X          {
X            case UP    :      if (sc == 'r' && !walls[cirmx+3][cirmy]) newdir = RIGHT ;
X                         else if (sc == 'l' && !walls[cirmx+1][cirmy]) newdir = LEFT ;
X                         else if (sc == 'd' && !walls[cirmx+2][cirmy+1]) newdir = DOWN ;
X                         break ;
X
X            case DOWN  :      if (sc == 'r' && !walls[cirmx+3][cirmy]) newdir = RIGHT ;
X                         else if (sc == 'l' && !walls[cirmx+1][cirmy]) newdir = LEFT ;
X                         else if (sc == 'u' && !walls[cirmx+2][cirmy-1]) newdir = UP ;
X                         break ;
X
X            case RIGHT :      if (sc == 'l' && !walls[cirmx+1][cirmy]) newdir = LEFT ;
X                         else if (sc == 'u' && !walls[cirmx+2][cirmy-1]) newdir = UP ;
X                         else if (sc == 'd' && !walls[cirmx+2][cirmy+1]) newdir = DOWN ;
X                         break ;
X
X            case LEFT  :      if (sc == 'r' && !walls[cirmx+3][cirmy]) newdir = RIGHT ;
X                         else if (sc == 'u' && !walls[cirmx+2][cirmy-1]) newdir = UP ;
X                         else if (sc == 'd' && !walls[cirmx+2][cirmy+1]) newdir = DOWN ;
X                         break ;
X          }
X    }    
X  if (doinc(newdir,posx,posy,cirmx,cirmy,&x,&y,&nx,&ny)) doupdate() ;
X  else
X    { 
X      if (!GCENTERED(posx,posy)) doupdate() ;          /* Until centered. */
X      else
X        { 
X          if (oldcurdir != curdir)
X            {
X              BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,
X                              45,45,RXOR,curcircle,0,0) ;
X              curcircle = circles[curdir][0] ;
X              BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,
X                              45,45,RXOR,curcircle,0,0) ;
X              oldcurdir = curdir ;
X            }
X        }    
X    }    
X  if (checkcollision(cirmx,cirmy,&g)) handlecollision(&bugs[g]) ;
X}
X
X
Xdoupdate()
X
X{
X  count++ ;
X  if (count % circatchup == 0) return ;       /* Go slower than bugs. */
X  drawcir(circles[newdir][inc],x,y) ;
X  if (count % 4 == 0) inc = (inc + 1) % 4 ;
X  if (fruiton)
X    if ((nx == FRUITMX) && (ny == FRUITMY)) destroyfruit() ;
X  if (dots[player][nx+1][ny] != NODOT)
X    {
X      if (dots[player][nx+1][ny] == SMALLDOT) updatescore(1) ;
X      else
X        { 
X          changebugs() ;
X          updatescore(5) ;
X        }
X      numdots[player]-- ;
X      drawdot(nx,ny,dots[player][nx+1][ny]) ;
X      dots[player][nx+1][ny] = NODOT ;
X      if (!numdots[player])
X        {
X          resetmaze() ;
X          gamestate = FALSE ;
X          progstate = RESETGAME ;
X          longjmp(exception,val) ;
X        }
X    }    
X  curdir = newdir ;
X  posx = x ;
X  posy = y ;
X  cirmx = nx ;
X  cirmy = ny ;
X}
X
X
Xexplodecircle(posx,posy)
Xint posx,posy ;
X 
X{
X  int i ;
X 
X  for (i = 0; i <= 8; i++)
X    {
X      BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X      curcircle = circleexplode[i] ;
X      BLT_MEM_TO_SCRN(posx-GOFFSET+5,posy-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X      oldcx = posx ;
X      oldcy = posy ;
X      PPAUSE(pausetime*70) ;
X    } 
X  for (i = 0; i < 80; i++) LONGPAUSE() ;
X}
X
X
Xfixexits()
X
X/*  Look for tunnels on the borders.  For each, show the area as black
X *  on the screen and set the walls and tunnel global variables to
X *  reflect the presence of the tunnel.
X */
X
X{
X  int x,y,t ;
X
X  PPAUSE(pausetime*30) ;
X  for (y = 1; y <= YSIZE; y++)
X    if (maze[0][y] == ' ')
X      {
X        walls[1][y] = 0 ;
X        walls[0][y] = 0 ;
X        x = -1 ;
X        do
X          {
X            x++ ;
X            tunnel[x][y] = 1 ;
X          }
X        while (maze[x][y] == ' ') ;
X        TRANSPT(0,y,x,t) ;
X        BLT_SCRN(3,t-2-SQUARE/2,XBASE-(SQUARE/2)-5,SQUARE*2+6,RINV) ;
X      }
X
X  PPAUSE(pausetime*30) ;
X  for (y = 1; y <= YSIZE; y++)
X    if (maze[XSIZE+1][y] == ' ')
X      {
X        walls[XSIZE+4][y] = 0 ;
X        walls[XSIZE+5][y] = 0 ;
X        x = XSIZE+1 ;
X        do
X          {
X            x-- ;
X            tunnel[x][y] = 1 ;
X          }
X        while (maze[x][y] == ' ') ;
X        TRANSPT(0,y,x,t) ;
X        BLT_SCRN(XBASE-(SQUARE/2)+SQUARE*(XSIZE+1)+4,t-2-SQUARE/2,
X                           XBASE-(SQUARE/2)-5,SQUARE*2+6,RINV) ;
X      }
X}
X
X
Xget_button_option()
X
X{
X  if (!c) return ;
X  else if (c >= BUT_AUTO+2 && c <= BUT_START+2)
X    {
X      BLT_SCRN(SQUARE/2+100*(c-2)+BUTXOFF,SQUARE/2+BUTYOFF,70,SQUARE,RINV) ;
X      PPAUSE(pausetime*100) ;
X      BLT_SCRN(SQUARE/2+100*(c-2)+BUTXOFF,SQUARE/2+BUTYOFF,70,SQUARE,RINV) ;
X      progstate = MAKESEL ;
X      button = c - 2 ;
X      c = 0 ;
X    }
X}
X
X
Xinitialize()
X
X{
X  int fd,i,j,g,x,y ;
X  struct timeb tp ;
X  FILE *fn ;
X
X  ftime(&tp) ;
X  for (x = 1; x < tp.millitm % 10; x++) y = (int) random() ;    /* Randomize start. */
X
X  if (!demomode) FPRINTF(stdout," Random") ;
X  if (!demomode) FPRINTF(stdout," Memory") ;
X
X  if ((fd = open(a_name,0)) == -1)
X    {
X      FPRINTF(stderr,"sidtool: unable to open %s.\n",a_name) ;
X      exit(-1) ;
X    }
X
X  for (i = UR; i <= LU; i++) corner[i] = load_picture(fd) ;
X
X  bigdot = load_picture(fd) ;
X  smalldot = load_picture(fd) ;
X
X  for (i = RIGHT; i <= DOWN; i++)
X    for (j = 0; j <= 3; j++) circles[i][j] = load_picture(fd) ;
X  for (i = POKEY; i <= SHADOW; i++)
X    for (j = 0; j <= 1; j++) bugpics[i][j] = load_picture(fd) ;
X
X  for (i = 0; i <= 1; i++) bluebug[i] = load_picture(fd) ;
X  for (i = 0; i <= 1; i++) bluepics[i] = load_picture(fd) ;
X  for (i = 0; i <= 3; i++) eyes[i] = load_picture(fd) ;
X  for (i = 0; i <= 8; i++) circleexplode[i] = load_picture(fd) ;
X  for (i = 1; i <= 8; i++) fruitpics[i] = load_picture(fd) ;
X
X  CLOSE(fd) ;
X
X  if (!demomode) FPRINTF(stdout," File") ;
X
X  if ((fn = fopen(m_name,"r")) == NULL)
X    {
X      FPRINTF(stderr,"\nsidtool: can't open %s\n",m_name) ;
X      exit(-1) ;
X    }
X
X  for (y = 0; y <= YSIZE+1; y++)
X    {
X      FGETS(buffer,MAXLINE,fn) ;
X      for (x = 0; x <= XSIZE+1; x++) maze[x][y] = buffer[x] ;
X    }
X  FCLOSE(fn) ;
X
X if (!demomode) FPRINTF(stdout," Maze") ;
X
X  TRANSPT(FRUITMX,FRUITMY,fruitx,fruity) ;
X  readallhighscores() ;
X  highscore = allhighscores[skilllevel].score ;
X  if (!demomode) FPRINTF(stdout," HighScore") ;
X
X  g = POKEY ;
X  for (y = 1; y <= YSIZE; y++)
X    for (x = 1; x <= XSIZE; x++)
X      if ((maze[x][y] >= '0') && (maze[x][y] <= '9'))
X        {
X          startpos[g].x = x ;
X          startpos[g].y = y ;
X          startpos[g].time = maze[x][y] - '0' ;
X          if (g < SHADOW) g++ ;
X          if (maze[x][y] == '0')
X            {
X              boxx = x ;
X              boxy = y ;
X            }
X        }    
X
X  if (!demomode) FPRINTF(stdout," Starting\n") ;
X  for (x = 0; x < XSIZE+3; x++)
X    for (y = 0; y < YSIZE; y++) tunnel[x][y] = 0 ;
X}
X
X
Xmake_button(x,y,but_name)
Xint x,y ;
Xchar but_name[MAXLINE] ;
X 
X{
X  int len ;
X
X  len = strlen(but_name) * 10 ;
X  BLT_MEM_TO_SCRN(x,y,SQUARE,SQUARE,RRPL,corner[UR],0,0) ;
X  BLT_MEM_TO_SCRN(x,y+SQUARE,SQUARE,SQUARE,RRPL,corner[LU],0,0) ;
X
X  BLT_SCRN(x+SQUARE,y+SQUARE/2,len,2,RSET) ;
X  BLT_SCRN(x+SQUARE,y+SQUARE*3/2,len,2,RSET) ;
X
X  BLT_MEM_TO_SCRN(x+len,y,SQUARE,SQUARE,RRPL,corner[RD],0,0) ;
X  BLT_MEM_TO_SCRN(x+len,y+SQUARE,SQUARE,SQUARE,RRPL,corner[DL],0,0) ;
X  write_bold(x+SQUARE-5,y+SQUARE*3/2-10,but_name) ;
X}
X
X
Xmake_control_panel()
X
X{
X  int i ;
X
X  BLT_SCRN(0,0,width,YBASE-20,RCLR) ;                 /* Clear panel area. */
X  for (i = BUT_AUTO; i <= BUT_START; i++)
X    make_button(100*i+BUTXOFF,BUTYOFF,but_names[i]) ; /* Make option buttons. */
X}
X
X
Xremovecircle()
X
X{
X  BLT_MEM_TO_SCRN(30+(numcir[player]-1)*60,20,50,50,RXOR,circles[RIGHT][0],0,0) ;
X}
X
X
Xresetmaze()
X
X{
X  int i,j ;
X
X  erasebugs() ;
X  LONGPAUSE() ;
X  for (i = 1; i <= 20; i++)
X    {
X      BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X      for (j = 0; j < 10; j++) LONGPAUSE() ;
X    }
X  LONGPAUSE() ;
X  if (fruitmaze[player] < 8) fruitmaze[player]++ ;
X  fruitchances[player] = 0 ;
X  setdots(player) ;
X  drawmaze() ;
X  if (curbluetime[player] > 1) curbluetime[player] -= 60 ;
X}
X
X
Xupdatefruit()
X
X{
X  Pixrect *p ;
X
X  p = fruitpics[fruitmaze[player]] ;
X  BLT_MEM_TO_SCRN(fruitx-GOFFSET,fruity-GOFFSET,45,45,RXOR,p,0,0) ;
X  if (fruiton)                        /* Turning fruit off. */
X    {
X      fruitchances[player]++ ;
X      if (fruitchances[player] > 2) fruittime = -1 ;    /* Already had 2 chances. */
X      else fruittime = randomrange(1000,2500) ;
X    }
X  else fruittime = randomrange(500,1000) ;              /* Turning fruit on. */
X  fruiton = !fruiton ;
X}
X
X
Xupdatescore(amt)
Xint amt ;
X
X{
X  int i,temp,x,y ;
X
X  if (autoplay)
X    if (!demomode)
X      {
X        autoscore += amt ;
X        SPRINTF(buffer,"%1d0",autoscore) ;
X        WRITELN(489,65,buffer) ;
X        return ;
X      }
X  temp = score[player] + amt ;
X  if (temp >= 1000)
X    if (score[player] < 1000)
X      {
X        for (i = 1; i < 7; i++)
X          {
X            BLT_MEM_TO_SCRN(oldcx-GOFFSET+5,oldcy-GOFFSET+5,45,45,RXOR,curcircle,0,0) ;
X            for (i = 0; i < 10; i++) LONGPAUSE() ;
X          }
X        numcir[player]++ ;
X        BLT_MEM_TO_SCRN(30+(numcir[player]-1)*60,20,50,50,RXOR,circles[RIGHT][0],0,0) ;
X      }
X  score[player] = temp ;
X  x = (player % 2) ? 217 : 597 ;
X  y = (player < 3) ? 40  : 80 ;
X  SPRINTF(buffer,"%1d0",score[player]) ;
X  WRITELN(x,y,buffer) ;
X  if (score[player] > highscore)
X    {
X      highplayer = player ;
X      highscore = score[player] ;
X      SPRINTF(buffer,"%1d0",highscore) ;
X      WRITELN(348,35,buffer) ;
X    }
X}
END_OF_sid_blt.c
if test 21194 -ne `wc -c <sid_blt.c`; then
    echo shar: \"sid_blt.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f sid_main.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"sid_main.c\"
else
echo shar: Extracting \"sid_main.c\" \(23265 characters\)
sed "s/^X//" >sid_main.c <<'END_OF_sid_main.c'
X 
X/*  sid_main.c
X *
X *  Sid Tool - the Sun Interactive Debugger program.
X *
X *  Written by Rich Burridge - Sun Microsystems Australia (Melbourne).
X *
X *  Version 2.1.  -  April 1987.
X *
X *  No responsibility is taken for any errors inherent either to the code
X *  or the comments of this program, but if reported to me then an attempt
X *  will be made to fix them.
X */
X
X#include <stdio.h>
X#include <strings.h>
X#include <setjmp.h>
X#include <sys/fcntl.h>
X#include "bltstuff.h"
X#include "patchlevel.h"
X#include "sidtool.h"
X#include <suntool/sunview.h>
X#include <suntool/canvas.h>
X
XCanvas canvas ;
XFrame base_frame ;
XPixwin *pw ;
X
Xjmp_buf exception ;
Xint val ;
X
Xextern etext() ;
Xextern restore_screen() ;
X
XNotify_value main_loop() ;
Xvoid event_proc() ;
X
Xshort sid_image[] = {
X#include "sidtool.icon"
X} ;
XDEFINE_ICON_FROM_IMAGE(sid_icon,sid_image) ;
X
Xstruct scorerec allhighscores[11] ;
Xstruct startrec startpos[4] ;
Xstruct bugrec bugs[4] ;
X
Xchar but_names[7][8] =    /*  Control panel stuff. */
X     {
X       " Auto  ",
X       " Help  ",
X       " Level ",
X       "Players",
X       " Quit  ",
X       " Scores",
X       " Start "
X     } ;
X
Xchar names[4][MAXLINE] =
X     {
X       "Time Dependencies",
X       "Uninitialized Variables",
X       "Fence Posts",
X       "Multiple Process Interaction"
X     } ;
X
Xchar old_key_vals[4][MAXLINE] ;       /* Function key string values to save. */
Xchar new_key_vals[4][MAXLINE] =       /* Function key values used by sidtool. */
X     {
X       "u",                  /* R8  - UPARROW. */
X       "d",                  /* R14 - DOWNARROW. */
X       "l",                  /* R10 - LEFTARROW. */
X       "r",                  /* R12 - RIGHTARROW. */
X     } ;
X
Xchar maze[XSIZE+2][YSIZE+2] ;
Xchar sc,buffer[MAXLINE] ;
Xchar s_name[MAXLINE] ;     /* Score file name. */
Xchar a_name[MAXLINE] ;     /* Animate file name. */
Xchar h_name[MAXLINE] ;     /* Help file name. */
Xchar m_name[MAXLINE] ;     /* Maze file name. */
Xchar thisscore[MAXLINE] ;  /* User name for new high score. */
Xchar titlestring[MAXLINE] ;
X
Xint blueblink,blueincblink,boxx,boxy,fruittime,fruitx,fruity,numplayers ;
Xint skilllevel,circatchup,pausetime,highplayer,autoscore,lastnumplayers ;
Xint curbluetime[MAXNUMPLAYERS+1],score[MAXNUMPLAYERS+1] ;
Xint numcir[MAXNUMPLAYERS+1],fruitmaze[MAXNUMPLAYERS+1] ;
Xint numdots[MAXNUMPLAYERS+1],fruitchances[MAXNUMPLAYERS+1] ;
Xint fruitsgotten[MAXNUMPLAYERS+1][9] ;
Xint highscore,player,cirmx,cirmy,bugssincedot ;
Xint walls[XSIZE+6][YSIZE+1] ;
Xint dots[MAXNUMPLAYERS+1][XSIZE+4][YSIZE+2] ;
Xint tunnel[XSIZE+4][YSIZE+2] ;
X
Xint key_stations[9] = {69, 113, 91, 93} ;
X
Xint button ;       /* Indicates users selection from control panel. */
Xint c ;            /* Contains latest mouse or keyboard interaction. */
Xint canvasfd ;     /* File descriptor for canvas subwindow. */
Xint curdir ;       /* Current direction of the screen. */
Xint oldcurdir ;    /* Old direction of the screen. */
Xint g,newdir,posx,posy,x,y,nx,ny,count,inc ;
Xint orgx,orgy,width,height ;    /* Position and dimension of window. */
Xint oldcx,oldcy ;  /* Old position of the screen. */
Xint on = 0 ;       /* Current blinking state of score. */
Xint canvasflags ;  /* Used to setup no delay for canvas. */
Xint credits ;      /* Direction of credits if on. */
Xint cirx ;         /* X position of screen during credits. */
Xint ciry ;         /* Y position of screen during credits. */
Xint dotx ;         /* X position of BIGDOT during credits. */
Xint doty ;         /* Y position of BIGDOT during credits. */
Xint movei,movej,movex ; /* Used to animate screen during credits. */
Xint progstate ;    /* State machine for main loop. */
Xint redraw;        /* If non-zero, then screen should be redrawn. */
Xint savedstate ;   /* State machine value after Ctrl S. */
Xint scorei ;       /* No of chars in high score user name. */
Xint speed ;        /* Class (speed) of this Sun machine. */
Xint started ;      /* Indicates if we have started a game. */
X
XBOOLEAN autoplay ;
XBOOLEAN demomode ;
XBOOLEAN fruiton ;
XBOOLEAN gamestate ;     /* State of the game, 1 = remove circle. */
XBOOLEAN remove ;        /* Whether Sun screen should be removed. */
X 
XFILE *fopen() ;
X
Xextern int sfunc ;      /* Used by SCHRFUNC for cursor function. */
Xextern Pixfont *pf ;
X
X
Xdrawbox(mx,my)
Xint mx,my ;
X
X/*  Draws a box starting at maze position mx, my. Mx, my should be an
X *  s or S position in maze. Travels around path until reach x or s.
X */
X
X{
X  int last ;
X
X  last = 'r' ;
X  PPAUSE(pausetime*20) ;
X  walls[mx+2][my] = 1 ;
X  if (maze[mx][my] == 's') drawcorner(mx,my,UR) ;
X  else if (maze[mx][my] == 'S') ddrawline(mx,my,'r') ;
X  else if (maze[mx][my] == 'T')
X    {
X      ddrawline(mx,my,'l') ;
X      mx -= 2 ;
X      last = 'l' ;
X    }
X   mx++ ;
X   for (;;)
X     {
X       PPAUSE(2*pausetime) ;
X       walls[mx+2][my] = 1 ;
X       switch (maze[mx][my])
X         {
X           case 's' :
X           case 'S' :
X           case 'T' : return ;
X           case 'd' : if (last == 'r') drawcorner(mx,my,RD) ;
X                      else if (last == 'l') drawcorner(mx,my,UR) ;
X                      else ddrawline(mx,my,'d') ;
X                      last = 'd' ;
X                      my++ ;
X                      break ;
X           case 'l' : if (last == 'd') drawcorner(mx,my,DL) ;
X                      else if (last == 'u') drawcorner(mx,my,RD) ;
X                      else ddrawline(mx,my,'l') ;
X                      last = 'l' ;
X                      mx-- ;
X                      break ;
X           case 'r' :
X           case 'R' : if (last == 'u') drawcorner(mx,my,UR) ;
X                      else if (last == 'd') drawcorner(mx,my,LU) ;
X                      else ddrawline(mx,my,maze[mx][my]) ;
X                      last = 'r' ;
X                      mx++ ;
X                      break ;
X           case 'u' : if (last == 'l') drawcorner(mx,my,LU) ;
X                      else if (last == 'r') drawcorner(mx,my,DL) ;
X                      else ddrawline(mx,my,'u') ;
X                      last = 'u' ;
X                      my-- ;
X                      break ;
X           case 'x' : ddrawline(mx,my,last) ;
X                      return ;
X         }
X      }   
X}
X
X
Xsetdots(player)
Xint player ;
X
X{
X  int x,y ;
X
X  for (y = 1; y <= YSIZE; y++)
X    {
X      dots[player][0][y] = NODOT ;
X      dots[player][1][y] = NODOT ;
X      dots[player][XSIZE+2][y] = NODOT ;
X      dots[player][XSIZE+3][y] = NODOT ;
X      for (x = 1; x <= XSIZE; x++)
X        if (maze[x][y] == '.')
X          {
X            dots[player][x+1][y] = SMALLDOT ;
X            numdots[player]++ ;
X          }
X        else if (maze[x][y] == '*')
X          {
X            dots[player][x+1][y] = BIGDOT ;
X            numdots[player]++ ;
X          }
X        else dots[player][x+1][y] = NODOT ;
X    }
X}
X
X
Xreadallhighscores()
X
X/*  Reads all high scores and names into the global table allhighscores.
X *  If file not found, then sets all high scores to zero.
X */
X
X{
X  int hsfile,level ;
X
X  if ((hsfile = open(s_name,2)) == -1)
X    {
X      if ((hsfile = creat(s_name,0777)) == -1)
X        {
X          FPRINTF(stderr,"sidtool: unable to create highscores file.\n") ;
X          return ;
X        }
X
X      for (level = 0; level <= 10; level++)
X        {
X          allhighscores[level].score = 0 ;
X          STRCPY(allhighscores[level].who," ") ;
X          puths(hsfile,allhighscores[level]) ;
X        }
X    }
X  else
X    for (level = 1; level <= 10; level++) geths(hsfile,&allhighscores[level]) ;
X  CLOSE(hsfile) ;
X}
X
X
Xwritehighscore()
X
X/*  If highscore is better than old high score for this skill level then
X *  asks for player's name and enters name and score into table and writes file.
X */
X
X{
X  if ((highscore >= allhighscores[skilllevel].score) &&
X        (highplayer != -1) && (!demomode))
X    {
X      clear_screen() ;
X      SPRINTF(buffer,"Player %1d has beaten the high score for skill level %1d.",
X                     highplayer,skilllevel) ;
X      WRITELN(100,140,buffer) ;
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          WRITELN(100,160,buffer) ;
X        }
X      SPRINTF(buffer,"Type player %1d's name or initials: ",highplayer) ;
X      WRITELN(100,200,buffer) ;
X      scorei = 0 ;
X      c = 0 ;
X      thisscore[scorei] = '_' ;
X      thisscore[scorei+1] = '\0' ;
X      WRITELN(370,200,thisscore) ;
X      progstate = NEXTLINE ;
X    }
X  else progstate = DOCREDIT ;
X}
X
X
Xgetnewscore(x,y)      /* Get new user name for highscore. */
Xint x,y ;
X
X{
X  if (c)
X    {
X      switch (c)
X        {
X          case BSPACE :
X          case DEL    : if (scorei)
X                          {   
X                            scorei-- ;
X                            thisscore[scorei] = ' ' ;
X                            thisscore[scorei+1] = '\0' ;
X                            WRITELN(x,y,thisscore) ;
X                            thisscore[scorei] = '\0' ;
X                          } 
X                        break ;
X          case CR     : thisscore[scorei] = '\0' ;
X                        if (!scorei) WRITELN(100,220,"   ** No name given. **") ;
X                        else
X                          {
X                            STRCPY(allhighscores[skilllevel].who,thisscore) ;
X                            savescorefile() ;
X                            progstate = DOCREDIT ;
X                          }
X                        break ;
X          default     : if (c < ' ') break ;
X                        thisscore[scorei++] = c ;
X                        thisscore[scorei] = '\0' ;
X                        WRITELN(x,y,thisscore) ;
X        }
X      c = 0 ;
X    }
X}
X
X
Xsavescorefile()     /* Write away new highscore values. */
X
X{
X  int fd,level ;
X
X  allhighscores[skilllevel].score = highscore ;
X  if ((fd = open(s_name,1)) == -1)
X    FPRINTF(stderr,"sidtool: unable to open highscores file.\n") ;
X  else
X    { 
X      for (level = 1; level <= 10; level++) puths(fd,allhighscores[level]) ;
X      CLOSE(fd) ;
X    }
X}
X
X
Xinitgame()
X
X{
X  int i,j ;
X
X  if (autoplay) autoscore = 0 ;
X  pausetime = -skilllevel * 20 + (speed * 100) ;
X  circatchup = -skilllevel * 4 + 46 ;
X  highplayer = -1 ;
X  for (j = 1; j < MAXNUMPLAYERS; j++)
X    {
X      numdots[j] = 0 ;
X      numcir[j] = 3 ;
X      fruitchances[j] = 0 ;
X      setdots(j) ;
X      curbluetime[j] = 1 + (-skilllevel * 60 + 900) ;
X      if (!autoplay)
X        {
X          score[j] = 0 ;
X          if (demomode) fruitmaze[j] = 8 ;
X          else fruitmaze[j] = 1 ;
X          for (i = 1; i < 8; i++)
X            if (demomode) fruitsgotten[j][i] = 1 ;
X            else fruitsgotten[j][i] = 0 ;
X        }
X    }
X}
X
X
Xshowplayerscore(player)
Xint player ;
X
X{
X  int x,y ;
X
X  SCHRFUNC(RXOR) ;
X  x = (player % 2) ? 190 : 570 ;
X  y = (player < 3) ? 25  : 65 ;
X  SPRINTF(buffer,"  Player %1d ",player) ;
X  WRITELN(x,y,buffer) ;
X  if (!score[player]) WRITELN(x+27,y+15,"0") ;
X  else
X    {
X      SPRINTF(buffer,"%1d0",score[player]) ;
X      WRITELN(x+27,y+15,buffer) ;
X    }
X  SCHRFUNC(RRPL) ;
X}
X
X
Xblinkpause()
X
X/*  Wait a while and check keyboard for commands while blinking current players score. */
X
X{
X  int i,j ;
X
X  on = 1 ;
X  if (!autoplay)
X    for (i = 1; i <= 16; i++)
X      {
X        showplayerscore(player) ;
X        on = !on ;
X        for (j = 0; j < 10; j++) LONGPAUSE() ;
X      }
X}
X
X
Xdoinc(dir,posx,posy,mx,my,x,y,nx,ny)
Xint dir,posx,posy,mx,my,*x,*y,*nx,*ny ;
X
X{
X  register int status,tx,ty ;
X
X  *x = posx ;
X  *y = posy ;
X  tx = mx ;
X  ty = my ;
X
X  switch (dir)
X    {
X      case UP    : *y = posy - 2 ;
X                   ty = my - 1 ;
X                   break ;
X      case DOWN  : *y = posy + 2 ;
X                   ty = my + 1 ;
X                   break ;
X      case LEFT  : *x = posx - 2 ;
X                   tx = mx - 1 ;
X                   break ;
X      case RIGHT : *x = posx + 2 ;
X                   tx = mx + 1 ;
X                   break ;
X    }
X  UNTRANSPT(*x,*y,*nx,*ny) ;
X  if (tx == -2) tx = XSIZE + 2 ;
X  else if (tx == XSIZE + 3) tx = -1 ;
X  status = 1 ;
X
X  if ((*nx == -2) && (dir == LEFT))
X    {
X      *nx = XSIZE + 2 ;
X      TRANSPT(*nx,*ny,*x,*y) ;
X    }
X  else if ((*nx == XSIZE + 3) && (dir == RIGHT))
X    {
X      *nx = -1 ;
X      TRANSPT(*nx,*ny,*x,*y) ;
X    }
X  else if (!(walls[*nx+2][*ny] ||
X            (GCENTERED(posx,posy) && walls[tx+2][ty]))) /* do nothing. */ ;
X  else status = 0 ;
X  return(status) ;
X}
X
X
Xheadto(destx,desty,scrx,scry,mx,my,dir,x,y,nx,ny)   /* Only called when GCENTERED. */
Xint *dir,destx,desty,scrx,scry,mx,my,*x,*y,*nx,*ny ;
X
X{
X  int dirar[5],rev,i,s,xinc,yinc ;
X
X  rev = REVERSEDIR(*dir) ;
X  xinc = mx - destx ;
X  yinc = my - desty ;
X  if (abs(xinc) > abs(yinc)) s = 2 ;
X  else s = 1 ;
X  if (xinc < 0)
X    {
X      dirar[3-s] = RIGHT ;
X      dirar[s+2] = LEFT ;
X    }
X  else
X    {
X      dirar[3-s] = LEFT ;
X      dirar[s+2] = RIGHT ;
X    }
X  if (yinc < 0)
X    {
X      dirar[s] = DOWN ;
X      dirar[5-s] = UP ;
X    }
X  else
X    {
X      dirar[s] = UP ;
X      dirar[5-s] = DOWN ;
X    }
X
X  for (i = 1; i <= 4; i++)     /* Adjust so reverse is last choice. */
X    if (dirar[i] == rev)
X      {
X        for (s = i; s <= 3; s++) dirar[s] = dirar[s+1] ;
X        dirar[4] = rev ;
X        break ;
X      }
X
X  for (s = 1; s <= 4; s++)
X    {
X      if (checkinc(dirar[s],mx,my))
X        {
X          *dir = dirar[s] ;
X          DOINC(*dir,scrx,scry,mx,my,x,y,nx,ny) ;
X          return ;
X        }
X    }
X}
X
X
Xdorandomdir(dir,scrx,scry,mx,my,x,y,nx,ny,ranrange)
Xint dir,scrx,scry,mx,my,*x,*y,*nx,*ny,ranrange ;
X
X{
X  int i,test,newdir,rev,status ;
X
X  test = randomrange(1,ranrange) ;
X  rev = REVERSEDIR(dir) ;
X  if ((test == 1) || (!checkinc(dir,mx,my)))
X    {
X      newdir = randomrange(0,3) ;
X      for (i = 0; i <= 3; i++)
X        {
X          if (newdir != rev)
X            if (checkinc(newdir,mx,my))
X              {
X                status = newdir ;
X                DOINC(newdir,scrx,scry,mx,my,x,y,nx,ny) ;
X                return(status) ;
X              }
X          newdir = (newdir + 1) % 4 ;
X        }
X    }
X  else
X    {
X      DOINC(dir,scrx,scry,mx,my,x,y,nx,ny) ;
X      status = dir ;
X    }
X  return(status) ;
X}
X
X
Xupdatebugs()
X
X/* Move each bug one bit in appropriate direction; change direction if appropriate. */
X
X{
X  register struct bugrec *g ;
X  int bemean ;
X
X  for (g = &bugs[POKEY]; g <= &bugs[SHADOW]; g++)
X    {
X      g->count++ ;
X      if (g->inbox || g->intunnel)
X        if (g->count % 2 == 0) return ;               /* Slow in box. */
X
X      if (g->bluetime > 0)
X        {
X          if (g->count % CATCHUP == 0) return ;       /* Go slower if blue. */
X          drawbug(g) ;                        /* Erase old before change blueTime. */
X          g->bluetime-- ;
X        }
X      else drawbug(g) ;                    /* Erase old. */
X
X      if (g->count % 7 == 0) g->pic = (g->pic + 1) % 2 ;
X
X      if (GCENTERED(g->scrx,g->scry))
X        {
X          g->intunnel = tunnel[g->mx+1][g->my] ;
X
X          if (!g->bluetime)
X            if (skilllevel < 5)
X              bemean = randomrange(0,10-skilllevel-GIND(g)) == 0 ;
X            else bemean = randomrange(0,skilllevel-5+GIND(g)) != 0 ;
X          else bemean = FALSE ;
X
X          if (g->inbox)
X            if ((g->mx == boxx) && (g->my == boxy)) g->inbox = FALSE ;
X
X          if (g->eyesonly)
X            {
X              if ((!g->enteringbox) && (g->mx == boxx) && (g->my == boxy))
X                {
X                  g->dir = DOWN ;
X                  g->enteringbox = TRUE ;
X                  DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ; 
X                }
X              else if (g->enteringbox)
X                if ((g->my > boxy + 2) &&
X                    (!doinc(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny)))
X                  {
X                    g->dir = UP ;
X                    g->enteringbox = FALSE ;
X                    g->inbox = TRUE ;
X                    g->eyesonly = FALSE ;
X                    DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ;
X                  }
X                else DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ;
X              else headto(boxx,boxy,g->scrx,g->scry,g->mx,g->my,&g->dir,&x,&y,&nx,&ny) ;
X            }
X          else if (g->boxtime)          /* Inbox should be true also. */
X            {
X              g->boxtime-- ;
X              if (g->boxtime < 0)       /* Heading to exit. */
X                {
X                  if (g->mx == boxx)    /* Found exit. */
X                    {
X                      g->boxtime = 0 ;
X                      g->dir = UP ;
X                      DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ;
X                    }
X                  else headto(boxx,boxy,g->scrx,g->scry,g->mx,g->my,&g->dir,&x,&y,&nx,&ny) ;
X                }
X              else if (!g->boxtime)      /* Start heading to exit. */
X                {
X                  g->boxtime = -1 ;
X                  headto(boxx,boxy,g->scrx,g->scry,g->mx,g->my,&g->dir,&x,&y,&nx,&ny) ;
X                }
X              else if (!doinc(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny))
X                {
X                  g->dir = REVERSEDIR(g->dir) ; /* Bounce up a down a while. */
X                  DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ;
X                }
X            }
X           else if (g->inbox)     /* Must be leaving the box; just keep going. */
X                  DOINC(g->dir,g->scrx,g->scry,
X                        g->mx,g->my,&x,&y,&nx,&ny) ;
X           else if (bemean)              /* Chase the circle. */
X             headto(cirmx,cirmy,g->scrx,g->scry,g->mx,g->my,&g->dir,&x,&y,&nx,&ny) ;
X           else g->dir = dorandomdir(g->dir,g->scrx,g->scry,
X                                            g->mx,g->my,&x,&y,&nx,&ny,3) ;
X         }
X       else DOINC(g->dir,g->scrx,g->scry,g->mx,g->my,&x,&y,&nx,&ny) ;
X
X       g->scrx = x ;
X       g->scry = y ;
X       g->mx = nx ;
X       g->my = ny ;
X       drawbug(g) ;                /* Draw new. */
X    }
X}
X
X
Xmain(argc,argv)
Xint argc ;
Xchar *argv[] ;
X
X{
X  get_options(argc,argv) ;          /* Get command line options. */
X  function_keys(KEY_SET) ;          /* Set direction arrow function keys. */
X
X  if ((pf = pf_open("/usr/lib/fonts/fixedwidthfonts/screen.r.14")) == NULL)
X    {
X      FPRINTF("Can't open screen.r.14 font.\n") ;
X      function_keys(KEY_RESET) ;
X      exit(1) ;
X    }
X
X  base_frame = window_create(NULL, FRAME,
X                             FRAME_LABEL, titlestring,
X                             FRAME_ICON, &sid_icon,
X                             WIN_X, orgx,
X                             WIN_Y, orgy,
X                             WIN_WIDTH, width,
X                             WIN_HEIGHT, height,
X                             WIN_FONT, pf,
X                             FRAME_ARGS, argc, argv,
X                             0) ;
X  canvas = window_create(base_frame, CANVAS,
X                         CANVAS_RETAINED, FALSE,
X                         CANVAS_FAST_MONO, TRUE,
X                         CANVAS_REPAINT_PROC, restore_screen,
X                         WIN_EVENT_PROC, event_proc,
X                         0) ;
X
X  window_set(canvas, WIN_CONSUME_KBD_EVENTS, WIN_ASCII_EVENTS, 0) ;
X  window_set(canvas, WIN_CONSUME_KBD_EVENTS, WIN_LEFT_KEYS, 0) ;
X  window_set(canvas,WIN_IGNORE_PICK_EVENT,LOC_MOVE,0) ;
X
X  pw = canvas_pixwin(canvas) ;
X
X/* Set up no delay for events within the canvas. */
X  canvasfd = (int) window_get(canvas,WIN_FD) ;
X  canvasflags = fcntl(canvasfd,F_GETFL,0) ;
X  canvasflags |= FNDELAY ;
X  FCNTL(canvasfd,F_SETFL,canvasflags) ;
X
X  sfunc = PIX_SRC ;                  /* Used by WRITELN. */
X  iocursormode(OFFCURSOR) ;
X
X  initrandom() ;
X  numplayers = 1 ;
X  skilllevel = 5 ;
X  lastnumplayers = 1 ;
X  autoplay = FALSE ;
X  initgame() ;
X  initialize() ;
X  redraw = 0 ;                       /* Don't redraw the screen, the first time. */
X  started = 1 ;
X  autoplay = 1 ;
X  progstate = STARTUP ;
X
X  (void) notify_set_itimer_func(base_frame, main_loop, ITIMER_REAL,
X                        &NOTIFY_POLLING_ITIMER, ((struct itimerval *) 0)) ;
X  window_main_loop(base_frame) ;
X  function_keys(KEY_RESET) ;         /* Restore direction arrow function keys. */
X  exit(0) ;
X}
X
X
X/*ARGSUSED*/
Xvoid
Xevent_proc(window,event,arg)
XWindow *window ;
XEvent *event ;
Xcaddr_t arg ;
X
X{
X  int x,y ;     /* Position of mouse when button pressed. */
X  int i ;
X
X  if (event_is_ascii(event))
X    {
X      c = event_id(event) ;
X      if (progstate == NEXTLINE) return ;
X      if ((c == DEL) && !demomode)
X        {
X          c = 0 ;
X          started = 0 ;
X          progstate = DELHIT ;
X          return ;
X        }
X      else if (c == CTRLS)
X        {
X          savedstate = progstate ;
X          progstate = CTRLSHIT ;
X          return ;
X        }
X      else if (c == CTRLQ)
X        {
X          progstate = savedstate ;
X          return ;
X        }
X      else if (!autoplay) sc = c ;
X    }
X  else if (event_is_down(event) && event_is_button(event))
X    {
X      x = event_x(event) ;
X      y = event_y(event) ;
X      if (y > BUTYOFF && y < BUTYOFF+2*SQUARE)
X        for (i = BUT_AUTO; i <= BUT_START; i++)
X          if (x > BUTXOFF+i*100 && x < BUTXOFF+i*100+120) c = i+2 ;
X    }
X}
X
X
X/*ARGSUSED*/
Xstatic Notify_value
Xmain_loop(client, itimer_type)
XNotify_client client ;
Xint itimer_type ;
X
X{
X  int i ;
X
X  switch (progstate)
X    {
X      case STARTUP   : SETJMP(exception) ;
X                       if (progstate) break ;
X                       else progstate = INITGAME ;
X                       break ;
X      case INITGAME  : initgame() ;
X                       progstate = PLAY ;
X                       break ;
X      case PLAY      : play() ;
X                       progstate = DOPLAY ;
X                       break ;
X      case DOPLAY    : doplay() ;
X                       progstate = MAKEPLAY ;
X                       break ;
X      case MAKEPLAY  : make_play() ;
X                       break ;
X      case DOREST    : numplayers = 1 ;
X                       progstate = HIGHSCORE ;
X                       break ;
X      case HIGHSCORE : writehighscore() ;
X                       break ;
X      case NEXTLINE  : getnewscore(365,200) ;
X                       break ;
X      case DOCREDIT  : if (!demomode)
X                         {
X                           dohighscores() ;
X                           WRITELN(5,860,"Type DEL to begin") ;
X                           for (i = 1; i <= 200; i++) LONGPAUSE() ;
X                         }
X                       docredits() ;
X                       break ;
X      case MOVELEFT  : move_left() ;
X                       break ;
X      case MOVERIGHT : move_right() ;
X                       break ;
X      case DELHIT    : autoplay = FALSE ;
X                       iocursormode(TRACKCURSOR) ;
X                       make_control_panel() ;
X                       display_settings() ;
X                       progstate = GETBUT ;
X                       break ;
X      case GETBUT    : get_button_option() ;
X                       break ;
X      case MAKESEL   : make_selection() ;
X                       break ;
X      case DOLEAVE   : SCHRFUNC(RRPL) ;
X                       autoplay = TRUE ;
X                       progstate = DOREST ;
X                       break ;
X      case RESETGAME : remove = gamestate ;
X                       progstate = DOPLAY ;
X                       break ;
X      case CTRLSHIT  : break ;
X    } 
X}
END_OF_sid_main.c
if test 23265 -ne `wc -c <sid_main.c`; then
    echo shar: \"sid_main.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 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