/* ^Y */ static void tstop() { /* Nothing if inhibited */ if(nosignal) { return; } lcreat((char *)0); clearvt100(); lflush(); signal(SIGTSTP, SIG_DFL); #ifdef SIGVTALRM /* Looks like BSD4.2 or higher - must clr mask for signal to take effect */ sigset_t set; sigprocmask(0, NULL, &set); sigprocmask(~BIT(SIGTSTP) & SIG_BLOCK, &set, NULL); #endif kill(getpid(), SIGTSTP); setupvt100(); signal(SIGTSTP, tstop); if(predostuff == 1) { s2choose(); } else { drawscreen(); } showplayer(); lflush(); }
static void cntlc() /* what to do for a ^C */ { if (nosignal) return; /* don't do anything if inhibited */ signal(SIGQUIT,SIG_IGN); signal(SIGINT,SIG_IGN); quit(); if (predostuff==1) s2choose(); else showplayer(); lflush(); signal(SIGQUIT,cntlc); signal(SIGINT,cntlc); }
static void tstop() /* control Y */ { if (nosignal) return; /* nothing if inhibited */ lcreat((char*)0); clearvt100(); lflush(); signal(SIGTSTP,SIG_DFL); #ifdef SIGVTALRM /* looks like BSD4.2 or higher - must clr mask for signal to take effect*/ sigsetmask(sigblock(0)& ~BIT(SIGTSTP)); #endif kill(getpid(),SIGTSTP); setupvt100(); signal(SIGTSTP,tstop); if (predostuff==1) s2choose(); else drawscreen(); showplayer(); lflush(); }
static void ataxx_init(void) { gridpos p={0,0}; squarestatus s={1, PIECE, 0}; currentplayer=1; ggset(p, s); p.x=p.y=6; ggset(p, s); p.x=0; p.y=6; s.player=2; ggset(p, s); p.x=6; p.y=0; ggset(p, s); showplayer(); }
/* What to do for a ^C */ static void cntlc() { /* Don't do anything if inhibited */ if(nosignal) { return; } signal(SIGQUIT, SIG_IGN); signal(SIGINT, SIG_IGN); quit(); if(predostuff == 1) { s2choose(); } else { showplayer(); } lflush(); signal(SIGQUIT, cntlc); signal(SIGINT, cntlc); }
static void ataxx_drag(int x1, int y1, int x2, int y2) { gridpos fp, tp; squarestatus fs, ts; int i, j; fp.x=x1/SCALE; fp.y=y1/SCALE; fs=gggetstatus(fp); if(fs.player!=currentplayer) return; tp.x=x2/SCALE; tp.y=y2/SCALE; ts=gggetstatus(tp); if(ts.player) return; if(abs(fp.x-tp.x)>2 || abs(fp.y-tp.y)>2) return; ts.player=fs.player; ts.bricktype=fs.bricktype; for(i=-1;i<=1;i++) for(j=-1;j<=1;j++) { fp.x=tp.x+i; fp.y=tp.y+j; fs=gggetstatus(fp); if(fs.player>0 && fs.player!=ts.player) ggmove(tp, fp, ts); } fp.x=x1/SCALE; fp.y=y1/SCALE; ggmove(fp, tp, ts); if(abs(fp.x-tp.x)<2 && abs(fp.y-tp.y)<2) ggmove(fp, fp, ts); /* keep original piece if short move */ currentplayer^=3; showplayer(); }
/* lexical analyzer for larn */ int yylex(void) { char cc; int ic; if (hit2flag) { hit2flag = 0; yrepcount = 0; return (' '); } if (yrepcount > 0) { --yrepcount; return (lastok); } else yrepcount = 0; if (yrepcount == 0) { bottomdo(); showplayer(); } /* show where the player is */ lflush(); while (1) { c[BYTESIN]++; /* check for periodic checkpointing */ if (ckpflag) if ((c[BYTESIN] % CHECKPOINT_INTERVAL) == 0) { #ifndef DOCHECKPOINTS savegame(ckpfile); #else wait(0); /* wait for other forks to finish */ if (fork() == 0) { savegame(ckpfile); exit(0); } #endif #ifdef TIMECHECK if (dayplay == 0) if (playable()) { cursor(1, 19); lprcat("\nSorry, but it is now time for work. Your game has been saved.\n"); beep(); lflush(); savegame(savefilename); wizard = nomove = 1; sleep(4); died(-257); } #endif /* TIMECHECK */ } do { /* if keyboard input buffer is too big, flush some of it */ ioctl(0, FIONREAD, &ic); if (ic > flushno) read(0, &cc, 1); } while (ic > flushno); if (read(0, &cc, 1) != 1) return (lastok = -1); if (cc == 'Y' - 64) { /* control Y -- shell escape */ resetscroll(); clear(); /* scrolling region, home, clear, no attributes */ if ((ic = fork()) == 0) { /* child */ /* revoke */ setgid(getgid()); execl("/bin/csh", "csh", NULL); exit(1); } wait(0); if (ic < 0) { /* error */ write(2, "Can't fork off a shell!\n", 25); sleep(2); } setscroll(); return (lastok = 'L' - 64); /* redisplay screen */ } if ((cc <= '9') && (cc >= '0')) { yrepcount = yrepcount * 10 + cc - '0'; } else { if (yrepcount > 0) --yrepcount; return (lastok = cc); } } }
/* * lexical analyzer for larn */ int yylex(void) { char cc; char firsttime = TRUE; if (hit2flag) { hit2flag=0; yrepcount=0; return(' '); } if (yrepcount>0) { --yrepcount; return(lastok); } else yrepcount=0; if (yrepcount==0) { bottomdo(); showplayer(); /* show where the player is */ move_no_pickup = FALSE; /* clear 'm' flag */ } lflush(); for (;;) { cdesc[BYTESIN]++; cc = ttgetch(); /* get repeat count, showing to player */ if ((cc <= '9') && (cc >= '0')) { yrepcount = yrepcount*10 + cc - '0'; /* show count to player for feedback */ if ( yrepcount >= 10 ) { cursors(); if (firsttime) lprcat("\n"); lprintf("count: %d", (int)yrepcount ); firsttime=FALSE; lflush(); /* show count */ } } else { /* check for multi-character commands and handle. */ if ( cc == 'm') { move_no_pickup = TRUE ; cc = ttgetch(); } if ( yrepcount > 0 ) --yrepcount; return(lastok = cc); } } }
/* function to drink a potion */ void quaffpotion(int pot) { int i,j; int k; if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */ /* first character of potion name starts off as \0. */ /* drinking a certain type of potion changes that to a space */ /* ...and from then on it is printable. */ /* if (potionname[pot][0] == '\0') */ /* potionname[pot][0] = ' '; */ if (potionknown[pot] == 0) potionknown[pot] = 1; lprintf("\nYou drink a potion of %s.", &potionname[pot][1]); switch(pot) { case PSLEEP: lprcat(" You fall asleep..."); lflush(); i=rnd(11)-(c[CONSTITUTION]>>2)+2; while(--i>0) { parse2(); nap(1000); } cursors(); lprcat("\n.. you wake up."); return; case PHEALING: lprcat(" You feel better."); if (c[HP] == c[HPMAX]) raisemhp(1); else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX]; break; case PRAISELEVEL: lprcat(" You feel much more skillful!"); raiselevel(); raisemhp(1); return; case PINCABILITY: lprcat(" You feel strange for a moment."); c[rund(6)]++; break; case PWISDOM: lprcat(" You feel more self-confident!"); c[WISDOM] += rnd(2); break; case PSTRENGTH: lprcat(" Wow! You feel great!"); if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++; break; case PCHARISMA: lprcat(" You feel charismatic!"); c[CHARISMA]++; break; case PDIZZINESS: lprcat(" You become dizzy!"); if (--c[STRENGTH] < 3) c[STRENGTH]=3; break; case PLEARNING: lprcat(" You feel clever!"); c[INTELLIGENCE]++; break; case PGOLDDET: lprcat(" You feel greedy..."); lflush(); nap(2000); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD)) { know[j][i]=1; show1cell(j,i); } showplayer(); return; case PMONSTDET: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) if (mitem[j][i].mon) { know[j][i]=1; show1cell(j,i); } return; case PFORGETFUL: lprcat(" You stagger for a moment..."); lflush(); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=0; nap(2000); draws(0,MAXX,0,MAXY); return; case PWATER: return; case PBLINDNESS: lprcat(" You can't see anything!"); c[BLINDCOUNT]+=500; /* dang, that's a long time. */ /* erase the character, too! */ cursor(playerx+1,playery+1); lprc(' '); cursor(playerx+1,playery+1); return; case PCONFUSION: lprcat(" You feel confused."); c[CONFUSE]+= 20+rnd(9); return; case PHEROISM: lprcat(" WOW! You feel fantastic!"); if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11; c[HERO] += 250; break; case PSTURDINESS: lprcat(" You feel healthier!"); c[CONSTITUTION]++; break; case PGIANTSTR: lprcat(" You now have incredible bulging muscles!"); if (c[GIANTSTR]==0) c[STREXTRA] += 21; c[GIANTSTR] += 700; break; case PFIRERESIST: lprcat(" You feel a chill run up your spine!"); c[FIRERESISTANCE] += 1000; break; case PTREASURE: lprcat(" You feel greedy..."); lflush(); nap(2000); for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) { k=item[j][i]; if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD) || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE)) { know[j][i]=1; show1cell(j,i); } } showplayer(); return; case PINSTHEAL: c[HP] = c[HPMAX]; removecurse(); break; case PCUREDIANTH: lprcat(" You don't seem to be affected."); return; case PPOISON: lprcat(" You feel a sickness engulf you!"); c[HALFDAM] += 200 + rnd(200); return; case PSEEINVIS: lprcat(" You feel your vision sharpen."); c[SEEINVISIBLE] += rnd(1000)+400; monstnamelist[INVISIBLESTALKER] = 'I'; return; }; /* show new stats */ bottomline(); return; }