ri...@sunk.uucp
unread,Apr 12, 1987, 2:13:54 AM4/12/87You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
----------CUT HERE-----------CUT HERE-------
#! /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 5 (of 5)."
# Contents: sid_main.c
# Wrapped by richb@sunk on Sun Apr 12 15:19:50 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
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\" \(23374 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[9][MAXLINE] ; /* Function key string values to save. */
Xchar new_key_vals[9][MAXLINE] = /* Function key values used by SIDtool. */
X {
X "", /* R7 */
X "u", /* R8 */
X "", /* R9 */
X "l", /* R10 */
X "", /* R11 */
X "r", /* R12 */
X "", /* R13 */
X "d", /* R14 */
X "" /* R15 */
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] = {68, 69, 70, 91, 92, 93, 112, 113, 114} ;
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 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 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 pf = pf_default() ;
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 23374 -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 5 \(of 5\).
cp /dev/null ark5isdone
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
D
D
D