From: Eric S. Raymond Date: Wed, 24 May 2017 00:22:35 +0000 (-0400) Subject: More global-to-structure moves. X-Git-Tag: seed~75 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=c3add5c2066face7535108706bb86dc41971ad9f;p=open-adventure.git More global-to-structure moves. --- diff --git a/actions1.c b/actions1.c index 5ae13cb..280a4f7 100644 --- a/actions1.c +++ b/actions1.c @@ -23,7 +23,7 @@ int action(FILE *input, long STARTAT) { BUG(99); L4000: VERB=K; - SPK=ACTSPK[VERB]; + game.spk=ACTVERB[VERB]; if(WD2 > 0 && VERB != SAY) return(2800); if(VERB == SAY)OBJ=WD2; if(OBJ > 0) goto L4090; @@ -96,7 +96,7 @@ L5120: if(OBJ != PLANT || !AT(PLANT2) || PROP[PLANT2] == 0) goto L5130; goto L5010; L5130: if(OBJ != KNIFE || game.knfloc != LOC) goto L5140; game.knfloc= -1; - SPK=116; + game.spk=116; return(2011); L5140: if(OBJ != ROD || !HERE(ROD2)) goto L5190; OBJ=ROD2; @@ -141,7 +141,7 @@ L9035: WD2=0; /* Lock, unlock, no object given. Assume various things if present. */ -L8040: SPK=28; +L8040: game.spk=28; if(HERE(CLAM))OBJ=CLAM; if(HERE(OYSTER))OBJ=OYSTER; if(AT(DOOR))OBJ=DOOR; @@ -153,12 +153,12 @@ L8040: SPK=28; /* Lock, unlock object. Special stuff for opening clam/oyster and for chain. */ L9040: if(OBJ == CLAM || OBJ == OYSTER) goto L9046; - if(OBJ == DOOR)SPK=111; - if(OBJ == DOOR && PROP[DOOR] == 1)SPK=54; - if(OBJ == CAGE)SPK=32; - if(OBJ == KEYS)SPK=55; - if(OBJ == GRATE || OBJ == CHAIN)SPK=31; - if(SPK != 31 || !HERE(KEYS)) return(2011); + if(OBJ == DOOR)game.spk=111; + if(OBJ == DOOR && PROP[DOOR] == 1)game.spk=54; + if(OBJ == CAGE)game.spk=32; + if(OBJ == KEYS)game.spk=55; + if(OBJ == GRATE || OBJ == CHAIN)game.spk=31; + if(game.spk != 31 || !HERE(KEYS)) return(2011); if(OBJ == CHAIN) goto L9048; if(!game.closng) goto L9043; K=130; @@ -175,11 +175,11 @@ L9043: K=34+PROP[GRATE]; /* Clam/Oyster. */ L9046: K=0; if(OBJ == OYSTER)K=1; - SPK=124+K; - if(TOTING(OBJ))SPK=120+K; - if(!TOTING(TRIDNT))SPK=122+K; - if(VERB == LOCK)SPK=61; - if(SPK != 124) return(2011); + game.spk=124+K; + if(TOTING(OBJ))game.spk=120+K; + if(!TOTING(TRIDNT))game.spk=122+K; + if(VERB == LOCK)game.spk=61; + if(game.spk != 124) return(2011); DSTROY(CLAM); DROP(OYSTER,LOC); DROP(PEARL,105); @@ -187,20 +187,20 @@ L9046: K=0; /* Chain. */ L9048: if(VERB == LOCK) goto L9049; - SPK=171; - if(PROP[BEAR] == 0)SPK=41; - if(PROP[CHAIN] == 0)SPK=37; - if(SPK != 171) return(2011); + game.spk=171; + if(PROP[BEAR] == 0)game.spk=41; + if(PROP[CHAIN] == 0)game.spk=37; + if(game.spk != 171) return(2011); PROP[CHAIN]=0; FIXED[CHAIN]=0; if(PROP[BEAR] != 3)PROP[BEAR]=2; FIXED[BEAR]=2-PROP[BEAR]; return(2011); -L9049: SPK=172; - if(PROP[CHAIN] != 0)SPK=34; - if(LOC != PLAC[CHAIN])SPK=173; - if(SPK != 172) return(2011); +L9049: game.spk=172; + if(PROP[CHAIN] != 0)game.spk=34; + if(LOC != PLAC[CHAIN])game.spk=173; + if(game.spk != 172) return(2011); PROP[CHAIN]=2; if(TOTING(CHAIN))DROP(CHAIN,LOC); FIXED[CHAIN]= -1; @@ -214,16 +214,16 @@ L8070: if(HERE(LAMP) && PROP[LAMP] == 0 && game.limit >= 0)OBJ=LAMP; L9070: if(OBJ == URN) goto L9073; if(OBJ != LAMP) return(2011); - SPK=184; + game.spk=184; if(game.limit < 0) return(2011); PROP[LAMP]=1; RSPEAK(39); if(game.wzdark) return(2000); return(2012); -L9073: SPK=38; +L9073: game.spk=38; if(PROP[URN] == 0) return(2011); - SPK=209; + game.spk=209; PROP[URN]=2; return(2011); @@ -235,11 +235,11 @@ L8080: if(HERE(LAMP) && PROP[LAMP] == 1)OBJ=LAMP; L9080: if(OBJ == URN) goto L9083; if(OBJ == LAMP) goto L9086; - if(OBJ == DRAGON || OBJ == VOLCAN)SPK=146; + if(OBJ == DRAGON || OBJ == VOLCAN)game.spk=146; return(2011); L9083: PROP[URN]=PROP[URN]/2; - SPK=210; + game.spk=210; return(2011); L9086: PROP[LAMP]=0; @@ -249,22 +249,22 @@ L9086: PROP[LAMP]=0; /* Wave. No effect unless waving rod at fissure or at bird. */ -L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))SPK=29; +L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))game.spk=29; if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (game.closng || !AT(FISSUR)))) return(2011); - if(HERE(BIRD))SPK=206+MOD(PROP[BIRD],2); - if(SPK == 206 && LOC == PLACE[STEPS] && PROP[JADE] < 0) goto L9094; + if(HERE(BIRD))game.spk=206+MOD(PROP[BIRD],2); + if(game.spk == 206 && LOC == PLACE[STEPS] && PROP[JADE] < 0) goto L9094; if(game.closed) return(18999); if(game.closng || !AT(FISSUR)) return(2011); - if(HERE(BIRD))RSPEAK(SPK); + if(HERE(BIRD))RSPEAK(game.spk); PROP[FISSUR]=1-PROP[FISSUR]; PSPEAK(FISSUR,2-PROP[FISSUR]); return(2012); L9094: DROP(JADE,LOC); PROP[JADE]=0; - TALLY=TALLY-1; - SPK=208; + game.tally=game.tally-1; + game.spk=208; return(2011); /* Attack also moved into separate module. */ @@ -277,16 +277,16 @@ L9120: return(attack(input)); L9130: if(OBJ == BOTTLE || OBJ == 0)OBJ=LIQ(0); if(OBJ == 0) return(8000); if(!TOTING(OBJ)) return(2011); - SPK=78; + game.spk=78; if(OBJ != OIL && OBJ != WATER) return(2011); if(HERE(URN) && PROP[URN] == 0) goto L9134; PROP[BOTTLE]=1; PLACE[OBJ]=0; - SPK=77; + game.spk=77; if(!(AT(PLANT) || AT(DOOR))) return(2011); if(AT(DOOR)) goto L9132; - SPK=112; + game.spk=112; if(OBJ != WATER) return(2011); PSPEAK(PLANT,PROP[PLANT]+3); PROP[PLANT]=MOD(PROP[PLANT]+1,3); @@ -296,7 +296,7 @@ L9130: if(OBJ == BOTTLE || OBJ == 0)OBJ=LIQ(0); L9132: PROP[DOOR]=0; if(OBJ == OIL)PROP[DOOR]=1; - SPK=113+PROP[DOOR]; + game.spk=113+PROP[DOOR]; return(2011); L9134: OBJ=URN; @@ -307,13 +307,13 @@ L9134: OBJ=URN; L8140: if(!HERE(FOOD)) return(8000); L8142: DSTROY(FOOD); - SPK=72; + game.spk=72; return(2011); L9140: if(OBJ == FOOD) goto L8142; if(OBJ == BIRD || OBJ == SNAKE || OBJ == CLAM || OBJ == OYSTER || OBJ == DWARF || OBJ == DRAGON || OBJ == TROLL || OBJ == BEAR || OBJ == - OGRE)SPK=71; + OGRE)game.spk=71; return(2011); /* Drink. If no object, assume water and look for it here. If water is in @@ -322,29 +322,29 @@ L9140: if(OBJ == FOOD) goto L8142; L9150: if(OBJ == 0 && LIQLOC(LOC) != WATER && (LIQ(0) != WATER || !HERE(BOTTLE))) return(8000); if(OBJ == BLOOD) goto L9153; - if(OBJ != 0 && OBJ != WATER)SPK=110; - if(SPK == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011); + if(OBJ != 0 && OBJ != WATER)game.spk=110; + if(game.spk == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011); PROP[BOTTLE]=1; PLACE[WATER]=0; - SPK=74; + game.spk=74; return(2011); L9153: DSTROY(BLOOD); PROP[DRAGON]=2; OBJSND[BIRD]=OBJSND[BIRD]+3; - SPK=240; + game.spk=240; return(2011); /* Rub. Yields various snide remarks except for lit urn. */ -L9160: if(OBJ != LAMP)SPK=76; +L9160: if(OBJ != LAMP)game.spk=76; if(OBJ != URN || PROP[URN] != 2) return(2011); DSTROY(URN); DROP(AMBER,LOC); PROP[AMBER]=1; - TALLY=TALLY-1; + game.tally=game.tally-1; DROP(CAVITY,LOC); - SPK=216; + game.spk=216; return(2011); /* Throw moved into separate module. */ @@ -359,24 +359,24 @@ L8180: if(YES(input,22,54,54)) score(1); /* Find. Might be carrying it, or it might be here. Else give caveat. */ L9190: if(AT(OBJ) || (LIQ(0) == OBJ && AT(BOTTLE)) || K == LIQLOC(LOC) || (OBJ == - DWARF && ATDWRF(LOC) > 0))SPK=94; - if(game.closed)SPK=138; - if(TOTING(OBJ))SPK=24; + DWARF && ATDWRF(LOC) > 0))game.spk=94; + if(game.closed)game.spk=138; + if(TOTING(OBJ))game.spk=24; return(2011); /* Inventory. If object, treat same as find. Else report on current burden. */ -L8200: SPK=98; +L8200: game.spk=98; /* 8201 */ for (I=1; I<=100; I++) { if(I == BEAR || !TOTING(I)) goto L8201; - if(SPK == 98)RSPEAK(99); + if(game.spk == 98)RSPEAK(99); game.blklin=false; PSPEAK(I,-1); game.blklin=true; - SPK=0; + game.spk=0; L8201: /*etc*/ ; } /* end loop */ - if(TOTING(BEAR))SPK=141; + if(TOTING(BEAR))game.spk=141; return(2011); /* Feed/fill are in the other module. */ @@ -397,7 +397,7 @@ L9230: if(PROP[ROD2] < 0 || !game.closed) return(2011); L8240: score(-1); SETPRM(1,SCORE,MXSCOR); - SETPRM(3,TURNS,TURNS); + SETPRM(3,game.turns,game.turns); RSPEAK(259); return(2012); @@ -406,9 +406,9 @@ L8240: score(-1); * WORD ZIPS THE EGGS BACK TO THE GIANT ROOM (UNLESS ALREADY THERE). */ L8250: K=VOCAB(WD1,3); - SPK=42; + game.spk=42; if(game.foobar == 1-K) goto L8252; - if(game.foobar != 0)SPK=151; + if(game.foobar != 0)game.spk=151; return(2011); L8252: game.foobar=K; @@ -428,7 +428,7 @@ L8252: game.foobar=K; /* Brief. Intransitive only. Suppress long descriptions after first time. */ -L8260: SPK=156; +L8260: game.spk=156; game.abbnum=10000; game.detail=3; return(2011); @@ -451,13 +451,13 @@ L9275: CLSHNT=YES(input,192,193,54); /* Break. Only works for mirror in repository and, of course, the vase. */ -L9280: if(OBJ == MIRROR)SPK=148; +L9280: if(OBJ == MIRROR)game.spk=148; if(OBJ == VASE && PROP[VASE] == 0) goto L9282; if(OBJ != MIRROR || !game.closed) return(2011); - SPK=197; + game.spk=197; return(18999); -L9282: SPK=198; +L9282: game.spk=198; if(TOTING(VASE))DROP(VASE,LOC); PROP[VASE]=2; FIXED[VASE]= -1; @@ -466,14 +466,14 @@ L9282: SPK=198; /* Wake. Only use is to disturb the dwarves. */ L9290: if(OBJ != DWARF || !game.closed) return(2011); - SPK=199; + game.spk=199; return(18999); /* Suspend. Offer to save things in a file, but charging some points (so * can't win by using saved games to retry battles or to start over after * learning zzword). */ -L8300: SPK=201; +L8300: game.spk=201; RSPEAK(260); if(!YES(input,200,54,54)) return(2012); game.saved=game.saved+5; @@ -497,8 +497,8 @@ L8305: DATIME(I,K); SAVWDS(game.abbnum,game.blklin,game.bonus,game.clock1,game.clock2,game.closed,game.closng); SAVWDS(game.detail,game.dflag,game.dkill,game.dtotal,game.foobar,game.holdng,game.iwest); SAVWDS(game.knfloc,game.limit,LL,game.lmwarn,LOC,game.newloc,game.numdie); - SAVWDS(OBJ,game.oldlc2,game.oldloc,game.oldobj,game.panic,game.saved,SETUP); - SAVWDS(SPK,TALLY,THRESH,TRNDEX,TRNLUZ,TURNS,OBJTXT[OYSTER]); + SAVWDS(OBJ,game.oldlc2,game.oldloc,game.oldobj,game.panic,game.saved,game.setup); + SAVWDS(game.spk,game.tally,game.thresh,game.trndex,game.trnluz,game.turns,OBJTXT[OYSTER]); SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,ZZWORD,OBJSND[BIRD]); SAVWDS(OBJTXT[SIGN],CLSHNT,game.novice,K,K,K,K); SAVARR(ABB,LOCSIZ); @@ -538,35 +538,35 @@ L8318: RSPEAK(270); /* Fly. Snide remarks unless hovering rug is here. */ -L8320: if(PROP[RUG] != 2)SPK=224; - if(!HERE(RUG))SPK=225; - if(SPK/2 == 112) return(2011); +L8320: if(PROP[RUG] != 2)game.spk=224; + if(!HERE(RUG))game.spk=225; + if(game.spk/2 == 112) return(2011); OBJ=RUG; L9320: if(OBJ != RUG) return(2011); - SPK=223; + game.spk=223; if(PROP[RUG] != 2) return(2011); game.oldlc2=game.oldloc; game.oldloc=LOC; game.newloc=PLACE[RUG]+FIXED[RUG]-LOC; - SPK=226; - if(PROP[SAPPH] >= 0)SPK=227; - RSPEAK(SPK); + game.spk=226; + if(PROP[SAPPH] >= 0)game.spk=227; + RSPEAK(game.spk); return(2); /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */ -L8330: SPK=228; +L8330: game.spk=228; K=LOCSND[LOC]; if(K == 0) goto L8332; RSPEAK(IABS(K)); if(K < 0) return(2012); - SPK=0; + game.spk=0; L8332: SETPRM(1,ZZWORD-MESH*2,0); /* 8335 */ for (I=1; I<=100; I++) { if(!HERE(I) || OBJSND[I] == 0 || PROP[I] < 0) goto L8335; PSPEAK(I,OBJSND[I]+PROP[I]); - SPK=0; + game.spk=0; if(I == BIRD && OBJSND[I]+PROP[I] == 8)DSTROY(BIRD); L8335: /*etc*/ ; } /* end loop */ diff --git a/actions2.c b/actions2.c index 698319f..23c8584 100644 --- a/actions2.c +++ b/actions2.c @@ -9,17 +9,17 @@ int carry(void) { if(TOTING(OBJ)) return(2011); - SPK=25; - if(OBJ == PLANT && PROP[PLANT] <= 0)SPK=115; - if(OBJ == BEAR && PROP[BEAR] == 1)SPK=169; - if(OBJ == CHAIN && PROP[BEAR] != 0)SPK=170; - if(OBJ == URN)SPK=215; - if(OBJ == CAVITY)SPK=217; - if(OBJ == BLOOD)SPK=239; - if(OBJ == RUG && PROP[RUG] == 2)SPK=222; - if(OBJ == SIGN)SPK=196; + game.spk=25; + if(OBJ == PLANT && PROP[PLANT] <= 0)game.spk=115; + if(OBJ == BEAR && PROP[BEAR] == 1)game.spk=169; + if(OBJ == CHAIN && PROP[BEAR] != 0)game.spk=170; + if(OBJ == URN)game.spk=215; + if(OBJ == CAVITY)game.spk=217; + if(OBJ == BLOOD)game.spk=239; + if(OBJ == RUG && PROP[RUG] == 2)game.spk=222; + if(OBJ == SIGN)game.spk=196; if(OBJ != MESSAG) goto L9011; - SPK=190; + game.spk=190; DSTROY(MESSAG); L9011: if(FIXED[OBJ] != 0) return(2011); if(OBJ != WATER && OBJ != OIL) goto L9017; @@ -27,16 +27,16 @@ L9011: if(FIXED[OBJ] != 0) return(2011); OBJ=BOTTLE; if(HERE(BOTTLE) && LIQ(0) == K) goto L9017; if(TOTING(BOTTLE) && PROP[BOTTLE] == 1) return(fill()); - if(PROP[BOTTLE] != 1)SPK=105; - if(!TOTING(BOTTLE))SPK=104; + if(PROP[BOTTLE] != 1)game.spk=105; + if(!TOTING(BOTTLE))game.spk=104; return(2011); -L9017: SPK=92; +L9017: game.spk=92; if(game.holdng >= 7) return(2011); if(OBJ != BIRD || PROP[BIRD] == 1 || -1-PROP[BIRD] == 1) goto L9014; if(PROP[BIRD] == 2) goto L9015; - if(!TOTING(CAGE))SPK=27; - if(TOTING(ROD))SPK=26; - if(SPK/2 == 13) return(2011); + if(!TOTING(CAGE))game.spk=27; + if(TOTING(ROD))game.spk=26; + if(game.spk/2 == 13) return(2011); PROP[BIRD]=1; L9014: if((OBJ == BIRD || OBJ == CAGE) && (PROP[BIRD] == 1 || -1-PROP[BIRD] == 1))CARRY(BIRD+CAGE-OBJ,LOC); @@ -48,7 +48,7 @@ L9014: if((OBJ == BIRD || OBJ == CAGE) && (PROP[BIRD] == 1 || -1-PROP[BIRD] == PROP[CAVITY]=1; return(2009); -L9015: SPK=238; +L9015: game.spk=238; DSTROY(BIRD); return(2011); } @@ -83,11 +83,11 @@ L9023: if(!(GSTONE(OBJ) && AT(CAVITY) && PROP[CAVITY] != 0)) goto L9024; PROP[CAVITY]=0; if(!HERE(RUG) || !((OBJ == EMRALD && PROP[RUG] != 2) || (OBJ == RUBY && PROP[RUG] == 2))) goto L9021; - SPK=219; - if(TOTING(RUG))SPK=220; - if(OBJ == RUBY)SPK=221; - RSPEAK(SPK); - if(SPK == 220) goto L9021; + game.spk=219; + if(TOTING(RUG))game.spk=220; + if(OBJ == RUBY)game.spk=221; + RSPEAK(game.spk); + if(game.spk == 220) goto L9021; K=2-PROP[RUG]; PROP[RUG]=K; if(K == 2)K=PLAC[SAPPH]; @@ -149,26 +149,26 @@ int attack(FILE *input) { if(HERE(CLAM) || HERE(OYSTER))OBJ=100*OBJ+CLAM; if(OBJ > 100) return(8000); L9124: if(OBJ != BIRD) goto L9125; - SPK=137; + game.spk=137; if(game.closed) return(2011); DSTROY(BIRD); PROP[BIRD]=0; - SPK=45; + game.spk=45; L9125: if(OBJ != VEND) goto L9126; PSPEAK(VEND,PROP[VEND]+2); PROP[VEND]=3-PROP[VEND]; return(2012); -L9126: if(OBJ == 0)SPK=44; - if(OBJ == CLAM || OBJ == OYSTER)SPK=150; - if(OBJ == SNAKE)SPK=46; - if(OBJ == DWARF)SPK=49; +L9126: if(OBJ == 0)game.spk=44; + if(OBJ == CLAM || OBJ == OYSTER)game.spk=150; + if(OBJ == SNAKE)game.spk=46; + if(OBJ == DWARF)game.spk=49; if(OBJ == DWARF && game.closed) return(19000); - if(OBJ == DRAGON)SPK=167; - if(OBJ == TROLL)SPK=157; - if(OBJ == OGRE)SPK=203; + if(OBJ == DRAGON)game.spk=167; + if(OBJ == TROLL)game.spk=157; + if(OBJ == OGRE)game.spk=203; if(OBJ == OGRE && I > 0) goto L9128; - if(OBJ == BEAR)SPK=165+(PROP[BEAR]+1)/2; + if(OBJ == BEAR)game.spk=165+(PROP[BEAR]+1)/2; if(OBJ != DRAGON || PROP[DRAGON] != 0) return(2011); /* Fun stuff for dragon. If he insists on attacking it, win! Set PROP to dead, * move dragon to central loc (still fixed), move rug there (not fixed), and @@ -195,7 +195,7 @@ L9126: if(OBJ == 0)SPK=44; K=NUL; return(8); -L9128: RSPEAK(SPK); +L9128: RSPEAK(game.spk); RSPEAK(6); DSTROY(OGRE); K=0; @@ -206,7 +206,7 @@ L9128: RSPEAK(SPK); DSEEN[I]=false; L9129: /*etc*/ ; } /* end loop */ - SPK=SPK+1+1/K; + game.spk=game.spk+1+1/K; return(2011); } @@ -222,30 +222,30 @@ int throw(FILE *cmdin) { if(OBJ != AXE) return(discard(false)); I=ATDWRF(LOC); if(I > 0) goto L9172; - SPK=152; + game.spk=152; if(AT(DRAGON) && PROP[DRAGON] == 0) goto L9175; - SPK=158; + game.spk=158; if(AT(TROLL)) goto L9175; - SPK=203; + game.spk=203; if(AT(OGRE)) goto L9175; if(HERE(BEAR) && PROP[BEAR] == 0) goto L9176; OBJ=0; return(attack(cmdin)); -L9172: SPK=48; +L9172: game.spk=48; if(RAN(7) < game.dflag) goto L9175; DSEEN[I]=false; DLOC[I]=0; - SPK=47; + game.spk=47; game.dkill=game.dkill+1; - if(game.dkill == 1)SPK=149; -L9175: RSPEAK(SPK); + if(game.dkill == 1)game.spk=149; +L9175: RSPEAK(game.spk); DROP(AXE,LOC); K=NUL; return(8); /* This'll teach him to throw the axe at the bear! */ -L9176: SPK=164; +L9176: game.spk=164; DROP(AXE,LOC); FIXED[AXE]= -1; PROP[AXE]=1; @@ -256,7 +256,7 @@ L9176: SPK=164; L9177: OBJ=BEAR; return(feed()); -L9178: SPK=159; +L9178: game.spk=159; /* Snarf a treasure for the troll. */ DROP(OBJ,0); MOVE(TROLL,0); @@ -272,41 +272,41 @@ L9178: SPK=159; int feed() { if(OBJ != BIRD) goto L9212; - SPK=100; + game.spk=100; return(2011); L9212: if(OBJ != SNAKE && OBJ != DRAGON && OBJ != TROLL) goto L9213; - SPK=102; - if(OBJ == DRAGON && PROP[DRAGON] != 0)SPK=110; - if(OBJ == TROLL)SPK=182; + game.spk=102; + if(OBJ == DRAGON && PROP[DRAGON] != 0)game.spk=110; + if(OBJ == TROLL)game.spk=182; if(OBJ != SNAKE || game.closed || !HERE(BIRD)) return(2011); - SPK=101; + game.spk=101; DSTROY(BIRD); PROP[BIRD]=0; return(2011); L9213: if(OBJ != DWARF) goto L9214; if(!HERE(FOOD)) return(2011); - SPK=103; + game.spk=103; game.dflag=game.dflag+2; return(2011); L9214: if(OBJ != BEAR) goto L9215; - if(PROP[BEAR] == 0)SPK=102; - if(PROP[BEAR] == 3)SPK=110; + if(PROP[BEAR] == 0)game.spk=102; + if(PROP[BEAR] == 3)game.spk=110; if(!HERE(FOOD)) return(2011); DSTROY(FOOD); PROP[BEAR]=1; FIXED[AXE]=0; PROP[AXE]=0; - SPK=168; + game.spk=168; return(2011); L9215: if(OBJ != OGRE) goto L9216; - if(HERE(FOOD))SPK=202; + if(HERE(FOOD))game.spk=202; return(2011); -L9216: SPK=14; +L9216: game.spk=14; return(2011); } @@ -317,33 +317,33 @@ int fill() { if(OBJ == URN) goto L9224; if(OBJ != 0 && OBJ != BOTTLE) return(2011); if(OBJ == 0 && !HERE(BOTTLE)) return(8000); - SPK=107; - if(LIQLOC(LOC) == 0)SPK=106; - if(HERE(URN) && PROP[URN] != 0)SPK=214; - if(LIQ(0) != 0)SPK=105; - if(SPK != 107) return(2011); + game.spk=107; + if(LIQLOC(LOC) == 0)game.spk=106; + if(HERE(URN) && PROP[URN] != 0)game.spk=214; + if(LIQ(0) != 0)game.spk=105; + if(game.spk != 107) return(2011); PROP[BOTTLE]=MOD(COND[LOC],4)/2*2; K=LIQ(0); if(TOTING(BOTTLE))PLACE[K]= -1; - if(K == OIL)SPK=108; + if(K == OIL)game.spk=108; return(2011); -L9222: SPK=29; - if(LIQLOC(LOC) == 0)SPK=144; +L9222: game.spk=29; + if(LIQLOC(LOC) == 0)game.spk=144; if(LIQLOC(LOC) == 0 || !TOTING(VASE)) return(2011); RSPEAK(145); PROP[VASE]=2; FIXED[VASE]= -1; return(discard(true)); -L9224: SPK=213; +L9224: game.spk=213; if(PROP[URN] != 0) return(2011); - SPK=144; + game.spk=144; K=LIQ(0); if(K == 0 || !HERE(BOTTLE)) return(2011); PLACE[K]=0; PROP[BOTTLE]=1; if(K == OIL)PROP[URN]=1; - SPK=211+PROP[URN]; + game.spk=211+PROP[URN]; return(2011); } diff --git a/init.c b/init.c index ae42f25..eed89a4 100644 --- a/init.c +++ b/init.c @@ -19,7 +19,7 @@ * 185 locations (LTEXT, STEXT, KEY, COND, ABB, ATLOC, LOCSND, LOCSIZ). * 100 objects (PLAC, PLACE, FIXD, FIXED, LINK (TWICE), PTEXT, PROP, * OBJSND, OBJTXT). - * 35 "action" verbs (ACTSPK, VRBSIZ). + * 35 "action" verbs (ACTVERB, VRBSIZ). * 277 random messages (RTEXT, RTXSIZ). * 12 different player classifications (CTEXT, CVAL, CLSMAX). * 20 hints (HINTLC, HINTED, HINTS, HNTSIZ). @@ -324,11 +324,11 @@ L1050: OBJ=GETNUM(OPENED); FIXD[OBJ]=GETNUM(NULL); goto L1050; -/* Read default message numbers for action verbs, store in ACTSPK. */ +/* Read default message numbers for action verbs, store in ACTVERB. */ L1060: VERB=GETNUM(OPENED); if(VERB == -1) goto L1002; - ACTSPK[VERB]=GETNUM(NULL); + ACTVERB[VERB]=GETNUM(NULL); goto L1060; /* Read info about available liquids and other conditions, store in COND. */ @@ -417,14 +417,14 @@ L1106: /*etc*/ ; /* Treasures, as noted earlier, are objects 50 through MAXTRS (CURRENTLY 79). * Their props are initially -1, and are set to 0 the first time they are - * described. TALLY keeps track of how many are not yet found, so we know + * described. game.tally keeps track of how many are not yet found, so we know * when to close the cave. */ MAXTRS=79; - TALLY=0; + game.tally=0; for (I=50; I<=MAXTRS; I++) { if(PTEXT[I] != 0)PROP[I]= -1; - TALLY=TALLY-PROP[I]; + game.tally=game.tally-PROP[I]; } /* end loop */ /* Clear the hint stuff. HINTLC(I) is how long he's been at LOC with cond bit @@ -559,17 +559,17 @@ L1106: /*etc*/ ; * game.limit Lifetime of lamp (not set here) * MAXDIE Number of reincarnation messages available (up to 5) * game.numdie Number of times killed so far - * THRESH Next #turns threshhold (-1 if none) - * TRNDEX Index in TRNVAL of next threshhold (section 14 of database) - * TRNLUZ # points lost so far due to number of turns used - * TURNS Tallies how many commands he's given (ignores yes/no) + * game.thresh Next #turns threshhold (-1 if none) + * game.trndex Index in TRNVAL of next threshhold (section 14 of database) + * game.trnluz # points lost so far due to number of turns used + * game.turns Tallies how many commands he's given (ignores yes/no) * Logicals were explained earlier */ - TURNS=0; - TRNDEX=1; - THRESH= -1; - if(TRNVLS > 0)THRESH=MOD(TRNVAL[1],100000)+1; - TRNLUZ=0; + game.turns=0; + game.trndex=1; + game.thresh= -1; + if(TRNVLS > 0)game.thresh=MOD(TRNVAL[1],100000)+1; + game.trnluz=0; game.lmwarn=false; IGO=0; game.iwest=0; @@ -593,7 +593,7 @@ L1106: /*etc*/ ; game.closed=false; CLSHNT=false; game.novice=false; - SETUP=1; + game.setup=1; /* if we can ever think of how, we should save it at this point */ @@ -697,7 +697,7 @@ static void quick_io(void) { quick_array(ATAB,TABSIZ); quick_array(PLAC,100); quick_array(FIXD,100); - quick_array(ACTSPK,VRBSIZ); + quick_array(ACTVERB,VRBSIZ); quick_array((long *)HINTS,(HNTMAX+1)*5-1); } diff --git a/main.c b/main.c index 55dfb4e..0ccfcce 100644 --- a/main.c +++ b/main.c @@ -15,10 +15,10 @@ long ABB[186], ATAB[331], ATLOC[186], DLOC[7], FIXED[101], KTAB[331], *LINES, LINK[201], LNLENG, LNPOSN, PARMS[26], PLACE[101], PTEXT[101], RTEXT[278], - SETUP = 0, TABSIZ = 330; + TABSIZ = 330; signed char INLINE[LINESIZE+1], MAP1[129], MAP2[129]; -long ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, +long ACTVERB[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, CLAM, CLSHNT, CLSMAX = 12, CLSSES, COINS, COND[186], CONDS, CTEXT[13], CVAL[13], DALTLC, @@ -33,10 +33,10 @@ long ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, OBJTXT[101], ODLOC[7], OGRE, OIL, OYSTER, PEARL, PILLOW, PLAC[101], PLANT, PLANT2, PROP[101], PYRAM, RESER, ROD, ROD2, RTXSIZ = 277, RUBY, RUG, SAPPH, SAY, - SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STEXT[186], STICK, - STREAM, TABNDX, TALLY, THRESH, THROW, TK[21], TRAVEL[886], TRIDNT, - TRNDEX, TRNLUZ, TRNSIZ = 5, TRNVAL[6], TRNVLS, TROLL, TROLL2, TRVS, - TRVSIZ = 885, TTEXT[6], TURNS, URN, V1, V2, VASE, VEND, VERB, + SCORE, SECT, SIGN, SNAKE, STEPS, STEXT[186], STICK, + STREAM, TABNDX, THROW, TK[21], TRAVEL[886], TRIDNT, + TRNSIZ = 5, TRNVAL[6], TRNVLS, TROLL, TROLL2, TRVS, + TRVSIZ = 885, TTEXT[6], URN, V1, V2, VASE, VEND, VERB, VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X, ZZWORD; struct game_t game = {.blklin = true}; @@ -102,8 +102,8 @@ int main(int argc, char *argv[]) { } MAP2[1] = 0; - if(!SETUP)initialise(); - if(SETUP > 0) goto L1; + if(!game.setup)initialise(); + if(game.setup > 0) goto L1; /* Unlike earlier versions, adventure is no longer restartable. (This * lets us get away with modifying things such as OBJSND(BIRD) without @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) { /* Start-up, dwarf stuff */ -L1: SETUP= -1; +L1: game.setup= -1; I=RAN(-1); ZZWORD=RNDVOC(3,0)+MESH*2; game.novice=YES(stdin, 65,1,0); @@ -234,7 +234,7 @@ L6016: TK[J]=ODLOC[I]; if(TOTING(J)) goto L6021; L6020: if(HERE(J))K=1; } /* end loop */ - if(TALLY == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP] + if(game.tally == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP] == 1) goto L6025; if(ODLOC[6] != DLOC[6] && PCT(20))RSPEAK(127); goto L6030; @@ -327,7 +327,7 @@ L2004: if(I == 0) goto L2012; if(game.closed) goto L2008; PROP[OBJ]=0; if(OBJ == RUG || OBJ == CHAIN)PROP[OBJ]=1; - TALLY=TALLY-1; + game.tally=game.tally-1; /* Note: There used to be a test here to see whether the player had blown it * so badly that he could never ever see the remaining treasures, and if so * the lamp was zapped to 35 turns. But the tests were too simple-minded; @@ -346,8 +346,8 @@ L2008: I=LINK[I]; goto L2004; L2009: K=54; -L2010: SPK=K; -L2011: RSPEAK(SPK); +L2010: game.spk=K; +L2011: RSPEAK(game.spk); L2012: VERB=0; game.oldobj=OBJ; @@ -387,16 +387,16 @@ L2605: game.wzdark=DARK(0); * make neg. If neg, he skipped a word, so make it zero. */ L2607: game.foobar=(game.foobar>0 ? -game.foobar : 0); - TURNS=TURNS+1; - if(TURNS != THRESH) goto L2608; - SPEAK(TTEXT[TRNDEX]); - TRNLUZ=TRNLUZ+TRNVAL[TRNDEX]/100000; - TRNDEX=TRNDEX+1; - THRESH= -1; - if(TRNDEX <= TRNVLS)THRESH=MOD(TRNVAL[TRNDEX],100000)+1; + game.turns=game.turns+1; + if(game.turns != game.thresh) goto L2608; + SPEAK(TTEXT[game.trndex]); + game.trnluz=game.trnluz+TRNVAL[game.trndex]/100000; + game.trndex=game.trndex+1; + game.thresh= -1; + if(game.trndex <= TRNVLS)game.thresh=MOD(TRNVAL[game.trndex],100000)+1; L2608: if(VERB == SAY && WD2 > 0)VERB=0; if(VERB == SAY) goto L4090; - if(TALLY == 0 && INDEEP(LOC) && LOC != 33)game.clock1=game.clock1-1; + if(game.tally == 0 && INDEEP(LOC) && LOC != 33)game.clock1=game.clock1-1; if(game.clock1 == 0) goto L10000; if(game.clock1 < 0)game.clock2=game.clock2-1; if(game.clock2 == 0) goto L11000; @@ -581,8 +581,9 @@ L30310: game.newloc=PLAC[TROLL]+FIXD[TROLL]-LOC; /* End of specials. */ -/* Handle "go back". Look for verb which goes from LOC to game.oldloc, or to game.oldlc2 - * If game.oldloc has forced-motion. K2 saves entry -> forced loc -> previous loc. */ +/* Handle "go back". Look for verb which goes from LOC to + * game.oldloc, or to game.oldlc2 If game.oldloc has forced-motion. + * K2 saves entry -> forced loc -> previous loc. */ L20: K=game.oldloc; if(FORCED(K))K=game.oldlc2; @@ -631,15 +632,15 @@ L40: K=58; /* Non-applicable motion. Various messages depending on word given. */ -L50: SPK=12; - if(K >= 43 && K <= 50)SPK=52; - if(K == 29 || K == 30)SPK=52; - if(K == 7 || K == 36 || K == 37)SPK=10; - if(K == 11 || K == 19)SPK=11; - if(VERB == FIND || VERB == INVENT)SPK=59; - if(K == 62 || K == 65)SPK=42; - if(K == 17)SPK=80; - RSPEAK(SPK); +L50: game.spk=12; + if(K >= 43 && K <= 50)game.spk=52; + if(K == 29 || K == 30)game.spk=52; + if(K == 7 || K == 36 || K == 37)game.spk=10; + if(K == 11 || K == 19)game.spk=11; + if(VERB == FIND || VERB == INVENT)game.spk=59; + if(K == 62 || K == 65)game.spk=42; + if(K == 17)game.spk=80; + RSPEAK(game.spk); return; @@ -755,7 +756,7 @@ L40900: I=ATDWRF(LOC); if(HERE(OGRE) && I == 0) goto L40010; goto L40030; -L41000: if(TALLY == 1 && PROP[JADE] < 0) goto L40010; +L41000: if(game.tally == 1 && PROP[JADE] < 0) goto L40010; goto L40020; @@ -875,10 +876,10 @@ L12000: RSPEAK(188); L12200: if(game.lmwarn || !HERE(LAMP)) goto L19999; game.lmwarn=true; - SPK=187; - if(PLACE[BATTER] == 0)SPK=183; - if(PROP[BATTER] == 1)SPK=189; - RSPEAK(SPK); + game.spk=187; + if(PLACE[BATTER] == 0)game.spk=183; + if(PROP[BATTER] == 1)game.spk=189; + RSPEAK(game.spk); goto L19999; L12400: game.limit= -1; @@ -888,7 +889,7 @@ L12400: game.limit= -1; /* Oh dear, he's disturbed the dwarves. */ -L18999: RSPEAK(SPK); +L18999: RSPEAK(game.spk); L19000: RSPEAK(136); score(0); } diff --git a/main.h b/main.h index 0e4feb0..c7b40b5 100644 --- a/main.h +++ b/main.h @@ -39,6 +39,13 @@ struct game_t { long oldobj; long panic; long saved; + long setup; + long spk; + long tally; + long thresh; + long trndex; + long trnluz; + long turns; /* more state will go here */ long wzdark; /* more state will go here */ diff --git a/score.c b/score.c index 3940dd1..1b3736e 100644 --- a/score.c +++ b/score.c @@ -85,7 +85,7 @@ L20020: MXSCOR=MXSCOR+45; } /* end loop */ if(game.novice)SCORE=SCORE-5; if(CLSHNT)SCORE=SCORE-10; - SCORE=SCORE-TRNLUZ-game.saved; + SCORE=SCORE-game.trnluz-game.saved; /* Return to score command if that's where we came from. */ @@ -93,25 +93,25 @@ L20020: MXSCOR=MXSCOR+45; /* that should be good enough. Let's tell him all about it. */ - if(SCORE+TRNLUZ+1 >= MXSCOR && TRNLUZ != 0)RSPEAK(242); + if(SCORE+game.trnluz+1 >= MXSCOR && game.trnluz != 0)RSPEAK(242); if(SCORE+game.saved+1 >= MXSCOR && game.saved != 0)RSPEAK(143); SETPRM(1,SCORE,MXSCOR); - SETPRM(3,TURNS,TURNS); + SETPRM(3,game.turns,game.turns); RSPEAK(262); for (I=1; I<=CLSSES; I++) { if(CVAL[I] >= SCORE) goto L20210; /*etc*/ ; } /* end loop */ - SPK=265; + game.spk=265; goto L25000; L20210: SPEAK(CTEXT[I]); - SPK=264; + game.spk=264; if(I >= CLSSES) goto L25000; I=CVAL[I]+1-SCORE; SETPRM(1,I,I); - SPK=263; -L25000: RSPEAK(SPK); + game.spk=263; +L25000: RSPEAK(game.spk); exit(0); } diff --git a/share.h b/share.h index 4d4058a..4f5b5ba 100644 --- a/share.h +++ b/share.h @@ -1,5 +1,5 @@ extern void score(long); -extern long ACTSPK[], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, +extern long ACTVERB[], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2, CLAM, CLSHNT, CLSMAX, CLSSES, @@ -15,9 +15,9 @@ extern long ACTSPK[], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, OBJTXT[], ODLOC[], OGRE, OIL, OYSTER, PEARL, PILLOW, PLAC[], PLANT, PLANT2, PROP[], PYRAM, RESER, ROD, ROD2, RTXSIZ, RUBY, RUG, SAPPH, SAY, - SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STEXT[], STICK, - STREAM, TABNDX, TALLY, THRESH, THROW, TK[], TRAVEL[], TRIDNT, - TRNDEX, TRNLUZ, TRNSIZ, TRNVAL[], TRNVLS, TROLL, TROLL2, TRVS, - TRVSIZ, TTEXT[], TURNS, URN, V1, V2, VASE, VEND, VERB, + SCORE, SECT, SIGN, SNAKE, STEPS, STEXT[], STICK, + STREAM, TABNDX, THROW, TK[], TRAVEL[], TRIDNT, + TRNSIZ, TRNVAL[], TRNVLS, TROLL, TROLL2, TRVS, + TRVSIZ, TTEXT[], URN, V1, V2, VASE, VEND, VERB, VOLCAN, VRBSIZ, VRSION, WATER, WD1, WD1X, WD2, WD2X, ZZWORD;