More collecting of globals.

This commit is contained in:
Eric S. Raymond 2017-06-07 06:38:40 -04:00
parent c1f1f2f79f
commit 0b02763bf0
10 changed files with 99 additions and 96 deletions

View file

@ -156,8 +156,8 @@ L5190: if((VERB == FIND || VERB == INVENT) && WD2 <= 0) goto L5010;
/* Carry, no object given yet. OK if only one object present. */ /* Carry, no object given yet. OK if only one object present. */
L8010: if(ATLOC[LOC] == 0 || LINK[ATLOC[LOC]] != 0 || ATDWRF(LOC) > 0) return(8000); L8010: if(game.atloc[LOC] == 0 || game.link[game.atloc[LOC]] != 0 || ATDWRF(LOC) > 0) return(8000);
OBJ=ATLOC[LOC]; OBJ=game.atloc[LOC];
/* Transitive carry/drop are in separate file. */ /* Transitive carry/drop are in separate file. */
@ -231,9 +231,9 @@ L9048: if(VERB == LOCK) goto L9049;
if(PROP[CHAIN] == 0)SPK=37; if(PROP[CHAIN] == 0)SPK=37;
if(SPK != 171) return(2011); if(SPK != 171) return(2011);
PROP[CHAIN]=0; PROP[CHAIN]=0;
FIXED[CHAIN]=0; game.fixed[CHAIN]=0;
if(PROP[BEAR] != 3)PROP[BEAR]=2; if(PROP[BEAR] != 3)PROP[BEAR]=2;
FIXED[BEAR]=2-PROP[BEAR]; game.fixed[BEAR]=2-PROP[BEAR];
return(2011); return(2011);
L9049: SPK=172; L9049: SPK=172;
@ -242,7 +242,7 @@ L9049: SPK=172;
if(SPK != 172) return(2011); if(SPK != 172) return(2011);
PROP[CHAIN]=2; PROP[CHAIN]=2;
if(TOTING(CHAIN))DROP(CHAIN,LOC); if(TOTING(CHAIN))DROP(CHAIN,LOC);
FIXED[CHAIN]= -1; game.fixed[CHAIN]= -1;
return(2011); return(2011);
/* Light. Applicable only to lamp and urn. */ /* Light. Applicable only to lamp and urn. */
@ -292,7 +292,7 @@ L9090: if((!TOTING(OBJ)) && (OBJ != ROD || !TOTING(ROD2)))SPK=29;
if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (game.closng || !AT(FISSUR)))) if(OBJ != ROD || !TOTING(OBJ) || (!HERE(BIRD) && (game.closng || !AT(FISSUR))))
return(2011); return(2011);
if(HERE(BIRD))SPK=206+MOD(PROP[BIRD],2); if(HERE(BIRD))SPK=206+MOD(PROP[BIRD],2);
if(SPK == 206 && LOC == PLACE[STEPS] && PROP[JADE] < 0) goto L9094; if(SPK == 206 && LOC == game.place[STEPS] && PROP[JADE] < 0) goto L9094;
if(game.closed) return(18999); if(game.closed) return(18999);
if(game.closng || !AT(FISSUR)) return(2011); if(game.closng || !AT(FISSUR)) return(2011);
if(HERE(BIRD))RSPEAK(SPK); if(HERE(BIRD))RSPEAK(SPK);
@ -320,7 +320,7 @@ L9130: if(OBJ == BOTTLE || OBJ == 0)OBJ=LIQ(0);
if(OBJ != OIL && OBJ != WATER) return(2011); if(OBJ != OIL && OBJ != WATER) return(2011);
if(HERE(URN) && PROP[URN] == 0) goto L9134; if(HERE(URN) && PROP[URN] == 0) goto L9134;
PROP[BOTTLE]=1; PROP[BOTTLE]=1;
PLACE[OBJ]=0; game.place[OBJ]=0;
SPK=77; SPK=77;
if(!(AT(PLANT) || AT(DOOR))) return(2011); if(!(AT(PLANT) || AT(DOOR))) return(2011);
@ -364,7 +364,7 @@ L9150: if(OBJ == 0 && LIQLOC(LOC) != WATER && (LIQ(0) != WATER || !HERE(BOTTLE))
if(OBJ != 0 && OBJ != WATER)SPK=110; if(OBJ != 0 && OBJ != WATER)SPK=110;
if(SPK == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011); if(SPK == 110 || LIQ(0) != WATER || !HERE(BOTTLE)) return(2011);
PROP[BOTTLE]=1; PROP[BOTTLE]=1;
PLACE[WATER]=0; game.place[WATER]=0;
SPK=74; SPK=74;
return(2011); return(2011);
@ -453,10 +453,10 @@ L8250: K=VOCAB(WD1,3);
L8252: game.foobar=K; L8252: game.foobar=K;
if(K != 4) return(2009); if(K != 4) return(2009);
game.foobar=0; game.foobar=0;
if(PLACE[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && LOC == PLAC[EGGS])) if(game.place[EGGS] == PLAC[EGGS] || (TOTING(EGGS) && LOC == PLAC[EGGS]))
return(2011); return(2011);
/* Bring back troll if we steal the eggs back from him before crossing. */ /* Bring back troll if we steal the eggs back from him before crossing. */
if(PLACE[EGGS] == 0 && PLACE[TROLL] == 0 && PROP[TROLL] == if(game.place[EGGS] == 0 && game.place[TROLL] == 0 && PROP[TROLL] ==
0)PROP[TROLL]=1; 0)PROP[TROLL]=1;
K=2; K=2;
if(HERE(EGGS))K=1; if(HERE(EGGS))K=1;
@ -499,7 +499,7 @@ L9280: if(OBJ == MIRROR)SPK=148;
L9282: SPK=198; L9282: SPK=198;
if(TOTING(VASE))DROP(VASE,LOC); if(TOTING(VASE))DROP(VASE,LOC);
PROP[VASE]=2; PROP[VASE]=2;
FIXED[VASE]= -1; game.fixed[VASE]= -1;
return(2011); return(2011);
/* Wake. Only use is to disturb the dwarves. */ /* Wake. Only use is to disturb the dwarves. */
@ -541,15 +541,15 @@ L8305: DATIME(&I,&K);
SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,game.zzword,OBJSND[BIRD]); SAVWDS(VERB,WD1,WD1X,WD2,game.wzdark,game.zzword,OBJSND[BIRD]);
SAVWDS(OBJTXT[SIGN],game.clshnt,game.novice,K,K,K,K); SAVWDS(OBJTXT[SIGN],game.clshnt,game.novice,K,K,K,K);
SAVARR(game.abbrev,LOCSIZ); SAVARR(game.abbrev,LOCSIZ);
SAVARR(ATLOC,LOCSIZ); SAVARR(game.atloc,LOCSIZ);
SAVARR(game.dloc,NDWARVES); SAVARR(game.dloc,NDWARVES);
SAVARR(game.dseen,NDWARVES); SAVARR(game.dseen,NDWARVES);
SAVARR(FIXED,NOBJECTS); SAVARR(game.fixed,NOBJECTS);
SAVARR(HINTED,HNTSIZ); SAVARR(game.hinted,HNTSIZ);
SAVARR(HINTLC,HNTSIZ); SAVARR(HINTLC,HNTSIZ);
SAVARR(LINK,NOBJECTS*2); SAVARR(game.link,NOBJECTS*2);
SAVARR(game.odloc,NDWARVES); SAVARR(game.odloc,NDWARVES);
SAVARR(PLACE,NOBJECTS); SAVARR(game.place,NOBJECTS);
SAVARR(PROP,NOBJECTS); SAVARR(PROP,NOBJECTS);
SAVWRD(KK,K); SAVWRD(KK,K);
if(K != 0) goto L8318; if(K != 0) goto L8318;
@ -587,7 +587,7 @@ L9320: if(OBJ != RUG) return(2011);
if(PROP[RUG] != 2) return(2011); if(PROP[RUG] != 2) return(2011);
game.oldlc2=game.oldloc; game.oldlc2=game.oldloc;
game.oldloc=LOC; game.oldloc=LOC;
game.newloc=PLACE[RUG]+FIXED[RUG]-LOC; game.newloc=game.place[RUG]+game.fixed[RUG]-LOC;
SPK=226; SPK=226;
if(PROP[SAPPH] >= 0)SPK=227; if(PROP[SAPPH] >= 0)SPK=227;
RSPEAK(SPK); RSPEAK(SPK);
@ -613,7 +613,7 @@ L8335: /*etc*/ ;
/* Z'ZZZ (word gets recomputed at startup; different each game). */ /* Z'ZZZ (word gets recomputed at startup; different each game). */
L8340: if(!AT(RESER) && LOC != FIXED[RESER]-1) return(2011); L8340: if(!AT(RESER) && LOC != game.fixed[RESER]-1) return(2011);
PSPEAK(RESER,PROP[RESER]+1); PSPEAK(RESER,PROP[RESER]+1);
PROP[RESER]=1-PROP[RESER]; PROP[RESER]=1-PROP[RESER];
if(AT(RESER)) return(2012); if(AT(RESER)) return(2012);

View file

@ -19,7 +19,7 @@ int carry(void) {
if(OBJ != MESSAG) goto L9011; if(OBJ != MESSAG) goto L9011;
SPK=190; SPK=190;
DSTROY(MESSAG); DSTROY(MESSAG);
L9011: if(FIXED[OBJ] != 0) return(2011); L9011: if(game.fixed[OBJ] != 0) return(2011);
if(OBJ != WATER && OBJ != OIL) goto L9017; if(OBJ != WATER && OBJ != OIL) goto L9017;
K=OBJ; K=OBJ;
OBJ=BOTTLE; OBJ=BOTTLE;
@ -40,7 +40,7 @@ L9014: if((OBJ == BIRD || OBJ == CAGE) && (PROP[BIRD] == 1 || -1-PROP[BIRD] ==
1))CARRY(BIRD+CAGE-OBJ,LOC); 1))CARRY(BIRD+CAGE-OBJ,LOC);
CARRY(OBJ,LOC); CARRY(OBJ,LOC);
K=LIQ(0); K=LIQ(0);
if(OBJ == BOTTLE && K != 0)PLACE[K]= -1; if(OBJ == BOTTLE && K != 0)game.place[K]= -1;
if(!GSTONE(OBJ) || PROP[OBJ] == 0) return(2009); if(!GSTONE(OBJ) || PROP[OBJ] == 0) return(2009);
PROP[OBJ]=0; PROP[OBJ]=0;
PROP[CAVITY]=1; PROP[CAVITY]=1;
@ -67,7 +67,7 @@ int discard(bool just_do_it) {
PROP[SNAKE]=1; PROP[SNAKE]=1;
L9021: K=LIQ(0); L9021: K=LIQ(0);
if(K == OBJ)OBJ=BOTTLE; if(K == OBJ)OBJ=BOTTLE;
if(OBJ == BOTTLE && K != 0)PLACE[K]=0; if(OBJ == BOTTLE && K != 0)game.place[K]=0;
if(OBJ == CAGE && PROP[BIRD] == 1)DROP(BIRD,LOC); if(OBJ == CAGE && PROP[BIRD] == 1)DROP(BIRD,LOC);
DROP(OBJ,LOC); DROP(OBJ,LOC);
if(OBJ != BIRD) return(2012); if(OBJ != BIRD) return(2012);
@ -121,7 +121,7 @@ L9027: if(OBJ == VASE && LOC != PLAC[PILLOW]) goto L9028;
L9028: PROP[VASE]=2; L9028: PROP[VASE]=2;
if(AT(PILLOW))PROP[VASE]=0; if(AT(PILLOW))PROP[VASE]=0;
PSPEAK(VASE,PROP[VASE]+1); PSPEAK(VASE,PROP[VASE]+1);
if(PROP[VASE] != 0)FIXED[VASE]= -1; if(PROP[VASE] != 0)game.fixed[VASE]= -1;
goto L9021; goto L9021;
} }
@ -187,7 +187,7 @@ L9126: if(OBJ == 0)SPK=44;
MOVE(RUG,K); MOVE(RUG,K);
DROP(BLOOD,K); DROP(BLOOD,K);
for (OBJ=1; OBJ<=NOBJECTS; OBJ++) { for (OBJ=1; OBJ<=NOBJECTS; OBJ++) {
if(PLACE[OBJ] == PLAC[DRAGON] || PLACE[OBJ] == FIXD[DRAGON])MOVE(OBJ,K); if(game.place[OBJ] == PLAC[DRAGON] || game.place[OBJ] == FIXD[DRAGON])MOVE(OBJ,K);
/*etc*/ ; /*etc*/ ;
} /* end loop */ } /* end loop */
LOC=K; LOC=K;
@ -246,7 +246,7 @@ L9175: RSPEAK(SPK);
/* This'll teach him to throw the axe at the bear! */ /* This'll teach him to throw the axe at the bear! */
L9176: SPK=164; L9176: SPK=164;
DROP(AXE,LOC); DROP(AXE,LOC);
FIXED[AXE]= -1; game.fixed[AXE]= -1;
PROP[AXE]=1; PROP[AXE]=1;
JUGGLE(BEAR); JUGGLE(BEAR);
return(2011); return(2011);
@ -296,7 +296,7 @@ L9214: if(OBJ != BEAR) goto L9215;
if(!HERE(FOOD)) return(2011); if(!HERE(FOOD)) return(2011);
DSTROY(FOOD); DSTROY(FOOD);
PROP[BEAR]=1; PROP[BEAR]=1;
FIXED[AXE]=0; game.fixed[AXE]=0;
PROP[AXE]=0; PROP[AXE]=0;
SPK=168; SPK=168;
return(2011); return(2011);
@ -323,7 +323,7 @@ int fill() {
if(SPK != 107) return(2011); if(SPK != 107) return(2011);
PROP[BOTTLE]=MOD(COND[LOC],4)/2*2; PROP[BOTTLE]=MOD(COND[LOC],4)/2*2;
K=LIQ(0); K=LIQ(0);
if(TOTING(BOTTLE))PLACE[K]= -1; if(TOTING(BOTTLE))game.place[K]= -1;
if(K == OIL)SPK=108; if(K == OIL)SPK=108;
return(2011); return(2011);
@ -332,7 +332,7 @@ L9222: SPK=29;
if(LIQLOC(LOC) == 0 || !TOTING(VASE)) return(2011); if(LIQLOC(LOC) == 0 || !TOTING(VASE)) return(2011);
RSPEAK(145); RSPEAK(145);
PROP[VASE]=2; PROP[VASE]=2;
FIXED[VASE]= -1; game.fixed[VASE]= -1;
return(discard(true)); return(discard(true));
L9224: SPK=213; L9224: SPK=213;
@ -340,7 +340,7 @@ L9224: SPK=213;
SPK=144; SPK=144;
K=LIQ(0); K=LIQ(0);
if(K == 0 || !HERE(BOTTLE)) return(2011); if(K == 0 || !HERE(BOTTLE)) return(2011);
PLACE[K]=0; game.place[K]=0;
PROP[BOTTLE]=1; PROP[BOTTLE]=1;
if(K == OIL)PROP[URN]=1; if(K == OIL)PROP[URN]=1;
SPK=211+PROP[URN]; SPK=211+PROP[URN];

View file

@ -54,14 +54,19 @@ struct game_t {
long wzdark; long wzdark;
long zzword; long zzword;
long abbrev[LOCSIZ+1]; long abbrev[LOCSIZ+1];
long atloc[LOCSIZ+1];
long dseen[NDWARVES+1]; long dseen[NDWARVES+1];
long dloc[NDWARVES+1]; long dloc[NDWARVES+1];
long odloc[NDWARVES+1]; long odloc[NDWARVES+1];
long fixed[NOBJECTS+1];
long link[NOBJECTS*2 + 1];
long place[NOBJECTS+1];
long hinted[HNTSIZ+1];
}; };
extern struct game_t game; extern struct game_t game;
extern long ATLOC[], FIXED[], LINK[], LNLENG, LNPOSN, PARMS[], PLACE[]; extern long LNLENG, LNPOSN, PARMS[];
extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[]; extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[];
extern FILE *logfp; extern FILE *logfp;
extern bool oldstyle; extern bool oldstyle;
@ -127,7 +132,7 @@ extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS, CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD,
GRATE, HINT, HINTED[], HINTLC[], GRATE, HINT, HINTLC[],
I, INVENT, IGO, J, JADE, K, K2, KEYS, KK, I, INVENT, IGO, J, JADE, K, K2, KEYS, KK,
KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK, KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK,
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, NUGGET, NUL, OBJ, MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, NUGGET, NUL, OBJ,

View file

@ -12,7 +12,6 @@
#define TRNSIZ 5 #define TRNSIZ 5
#define TABSIZ 330 #define TABSIZ 330
#define VRBSIZ 35 #define VRBSIZ 35
#define HNTSIZ 20
#define TRVSIZ 885 #define TRVSIZ 885
#define TOKLEN 5 #define TOKLEN 5
#define HINTLEN 5 #define HINTLEN 5
@ -510,9 +509,9 @@ void read_sound_text(FILE* database)
/* Having read in the database, certain things are now constructed. /* Having read in the database, certain things are now constructed.
* PROPS are set to zero. We finish setting up COND by checking for * PROPS are set to zero. We finish setting up COND by checking for
* forced-motion travel entries. The PLAC and FIXD arrays are used * forced-motion travel entries. The PLAC and FIXD arrays are used
* to set up ATLOC(N) as the first object at location N, and * to set up game.atloc(N) as the first object at location N, and
* LINK(OBJ) as the next object at the same location as OBJ. * game.link(OBJ) as the next object at the same location as OBJ.
* (OBJ>NOBJECTS indicates that FIXED(OBJ-NOBJECTS)=LOC; LINK(OBJ) is * (OBJ>NOBJECTS indicates that game.fixed(OBJ-NOBJECTS)=LOC; game.link(OBJ) is
* still the correct link to use.) game.abbrev is zeroed; it controls * still the correct link to use.) game.abbrev is zeroed; it controls
* whether the abbreviated description is printed. Counts modulo 5 * whether the abbreviated description is printed. Counts modulo 5
* unless "LOOK" is used. */ * unless "LOOK" is used. */

View file

@ -15,8 +15,8 @@
* PCT(N) = true N% of the time (N integer from 0 to 100) * PCT(N) = true N% of the time (N integer from 0 to 100)
* TOTING(OBJ) = true if the OBJ is being carried */ * TOTING(OBJ) = true if the OBJ is being carried */
#define TOTING(OBJ) (PLACE[OBJ] == -1) #define TOTING(OBJ) (game.place[OBJ] == -1)
#define AT(OBJ) (PLACE[OBJ] == LOC || FIXED[OBJ] == LOC) #define AT(OBJ) (game.place[OBJ] == LOC || game.fixed[OBJ] == LOC)
#define HERE(OBJ) (AT(OBJ) || TOTING(OBJ)) #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
#define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL)) #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
#define LIQ(DUMMY) (LIQ2(PROP[BOTTLE]<0 ? -1-PROP[BOTTLE] : PROP[BOTTLE])) #define LIQ(DUMMY) (LIQ2(PROP[BOTTLE]<0 ? -1-PROP[BOTTLE] : PROP[BOTTLE]))

26
init.c
View file

@ -15,13 +15,13 @@
* 12600 words of message text (LINES, LINSIZ). * 12600 words of message text (LINES, LINSIZ).
* 885 travel options (TRAVEL, TRVSIZ). * 885 travel options (TRAVEL, TRVSIZ).
* 330 vocabulary words (KTAB, ATAB, TABSIZ). * 330 vocabulary words (KTAB, ATAB, TABSIZ).
* 185 locations (LTEXT, STEXT, KEY, COND, abbrev, ATLOC, LOCSND, LOCSIZ). * 185 locations (LTEXT, STEXT, KEY, COND, abbrev, game.atloc, LOCSND, LOCSIZ).
* 100 objects (PLAC, PLACE, FIXD, FIXED, LINK (TWICE), PTEXT, PROP, * 100 objects (PLAC, game.place, FIXD, game.fixed, game.link (TWICE), PTEXT, PROP,
* OBJSND, OBJTXT). * OBJSND, OBJTXT).
* 35 "action" verbs (ACTSPK, VRBSIZ). * 35 "action" verbs (ACTSPK, VRBSIZ).
* 277 random messages (RTEXT, RTXSIZ). * 277 random messages (RTEXT, RTXSIZ).
* 12 different player classifications (CTEXT, CVAL, CLSMAX). * 12 different player classifications (CTEXT, CVAL, CLSMAX).
* 20 hints (HINTLC, HINTED, HINTS, HNTSIZ). * 20 hints (HINTLC, game.hinted, HINTS, HNTSIZ).
* 5 "# of turns" threshholds (TTEXT, TRNVAL, TRNSIZ). * 5 "# of turns" threshholds (TTEXT, TRNVAL, TRNSIZ).
* There are also limits which cannot be exceeded due to the structure of * There are also limits which cannot be exceeded due to the structure of
* the database. (E.G., The vocabulary uses n/1000 to determine word type, * the database. (E.G., The vocabulary uses n/1000 to determine word type,
@ -180,10 +180,10 @@ void initialise(void) {
static int finish_init(void) { static int finish_init(void) {
for (I=1; I<=100; I++) { for (I=1; I<=100; I++) {
PLACE[I]=0; game.place[I]=0;
PROP[I]=0; PROP[I]=0;
LINK[I]=0; game.link[I]=0;
{long x = I+NOBJECTS; LINK[x]=0;} {long x = I+NOBJECTS; game.link[x]=0;}
} /* end loop */ } /* end loop */
/* 1102 */ for (I=1; I<=LOCSIZ; I++) { /* 1102 */ for (I=1; I<=LOCSIZ; I++) {
@ -191,13 +191,13 @@ static int finish_init(void) {
if(LTEXT[I] == 0 || KEY[I] == 0) goto L1102; if(LTEXT[I] == 0 || KEY[I] == 0) goto L1102;
K=KEY[I]; K=KEY[I];
if(MOD(labs(TRAVEL[K]),1000) == 1)COND[I]=2; if(MOD(labs(TRAVEL[K]),1000) == 1)COND[I]=2;
L1102: ATLOC[I]=0; L1102: game.atloc[I]=0;
} /* end loop */ } /* end loop */
/* Set up the ATLOC and LINK arrays as described above. We'll use the DROP /* Set up the game.atloc and game.link arrays as described above. We'll use the DROP
* subroutine, which prefaces new objects on the lists. Since we want things * subroutine, which prefaces new objects on the lists. Since we want things
* in the other order, we'll run the loop backwards. If the object is in two * in the other order, we'll run the loop backwards. If the object is in two
* locs, we drop it twice. This also sets up "PLACE" and "fixed" as copies of * locs, we drop it twice. This also sets up "game.place" and "fixed" as copies of
* "PLAC" and "FIXD". Also, since two-placed objects are typically best * "PLAC" and "FIXD". Also, since two-placed objects are typically best
* described last, we'll drop them first. */ * described last, we'll drop them first. */
@ -211,7 +211,7 @@ L1106: /*etc*/ ;
for (I=1; I<=NOBJECTS; I++) { for (I=1; I<=NOBJECTS; I++) {
K=NOBJECTS + 1 - I; K=NOBJECTS + 1 - I;
FIXED[K]=FIXD[K]; game.fixed[K]=FIXD[K];
if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]); if(PLAC[K] != 0 && FIXD[K] <= 0)DROP(K,PLAC[K]);
} /* end loop */ } /* end loop */
@ -227,11 +227,11 @@ L1106: /*etc*/ ;
game.tally=game.tally-PROP[I]; game.tally=game.tally-PROP[I];
} /* end loop */ } /* end loop */
/* Clear the hint stuff. HINTLC(I) is how long he's been at LOC with cond bit /* Clear the hint stuff. HINTLC[I] is how long he's been at LOC with cond bit
* I. HINTED(I) is true iff hint I has been used. */ * I. game.hinted[I] is true iff hint I has been used. */
for (I=1; I<=HNTMAX; I++) { for (I=1; I<=HNTMAX; I++) {
HINTED[I]=false; game.hinted[I]=false;
HINTLC[I]=0; HINTLC[I]=0;
} /* end loop */ } /* end loop */

46
main.c
View file

@ -14,16 +14,14 @@
struct game_t game; struct game_t game;
long ATLOC[LOCSIZ+1], FIXED[NOBJECTS+1], long LNLENG, LNPOSN, PARMS[26];
LINK[NOBJECTS*2 + 1], LNLENG, LNPOSN,
PARMS[26], PLACE[NOBJECTS+1];
char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129]; char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129];
long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, long AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD,
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS, CLAM, COINS, DALTLC, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD,
GRATE, HINT, HINTED[21], HINTLC[21], GRATE, HINT, HINTLC[21],
I, INVENT, IGO, J, JADE, K, K2, KEYS, KK, I, INVENT, IGO, J, JADE, K, K2, KEYS, KK,
KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK, KNIFE, KQ, L, LAMP, LL, LOC, LOCK, LOOK,
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR, MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
@ -251,7 +249,7 @@ L6016: TK[J]=game.odloc[I];
/* The pirate's spotted him. He leaves him alone once we've found chest. K /* The pirate's spotted him. He leaves him alone once we've found chest. K
* counts if a treasure is here. If not, and tally=1 for an unseen chest, let * counts if a treasure is here. If not, and tally=1 for an unseen chest, let
* the pirate be spotted. Note that PLACE(CHEST)=0 might mean that he's * the pirate be spotted. Note that game.place(CHEST)=0 might mean that he's
* thrown it to the troll, but in that case he's seen the chest (PROP=0). */ * thrown it to the troll, but in that case he's seen the chest (PROP=0). */
if(LOC == game.chloc || PROP[CHEST] >= 0) goto L6030; if(LOC == game.chloc || PROP[CHEST] >= 0) goto L6030;
@ -262,19 +260,19 @@ L6016: TK[J]=game.odloc[I];
if(TOTING(J)) goto L6021; if(TOTING(J)) goto L6021;
L6020: if(HERE(J))K=1; L6020: if(HERE(J))K=1;
} /* end loop */ } /* end loop */
if(game.tally == 1 && K == 0 && PLACE[CHEST] == 0 && HERE(LAMP) && PROP[LAMP] if(game.tally == 1 && K == 0 && game.place[CHEST] == 0 && HERE(LAMP) && PROP[LAMP]
== 1) goto L6025; == 1) goto L6025;
if(game.odloc[6] != game.dloc[6] && PCT(20))RSPEAK(127); if(game.odloc[6] != game.dloc[6] && PCT(20))RSPEAK(127);
goto L6030; goto L6030;
L6021: if(PLACE[CHEST] != 0) goto L6022; L6021: if(game.place[CHEST] != 0) goto L6022;
/* Install chest only once, to insure it is the last treasure in the list. */ /* Install chest only once, to insure it is the last treasure in the list. */
MOVE(CHEST,game.chloc); MOVE(CHEST,game.chloc);
MOVE(MESSAG,game.chloc2); MOVE(MESSAG,game.chloc2);
L6022: RSPEAK(128); L6022: RSPEAK(128);
/* 6023 */ for (J=50; J<=MAXTRS; J++) { /* 6023 */ for (J=50; J<=MAXTRS; J++) {
if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6023; if(J == PYRAM && (LOC == PLAC[PYRAM] || LOC == PLAC[EMRALD])) goto L6023;
if(AT(J) && FIXED[J] == 0)CARRY(J,LOC); if(AT(J) && game.fixed[J] == 0)CARRY(J,LOC);
if(TOTING(J))DROP(J,game.chloc); if(TOTING(J))DROP(J,game.chloc);
L6023: /*etc*/ ; L6023: /*etc*/ ;
} /* end loop */ } /* end loop */
@ -346,7 +344,7 @@ L2001: if(TOTING(BEAR))RSPEAK(141);
if(DARK(0)) goto L2012; if(DARK(0)) goto L2012;
game.abbrev[LOC]=game.abbrev[LOC]+1; game.abbrev[LOC]=game.abbrev[LOC]+1;
I=ATLOC[LOC]; I=game.atloc[LOC];
L2004: if(I == 0) goto L2012; L2004: if(I == 0) goto L2012;
OBJ=I; OBJ=I;
if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS; if(OBJ > NOBJECTS)OBJ=OBJ-NOBJECTS;
@ -368,9 +366,9 @@ L2004: if(I == 0) goto L2012;
* anyone who makes such a gross blunder isn't likely to find everything * anyone who makes such a gross blunder isn't likely to find everything
* else anyway (so goes the rationalisation). */ * else anyway (so goes the rationalisation). */
L2006: KK=PROP[OBJ]; L2006: KK=PROP[OBJ];
if(OBJ == STEPS && LOC == FIXED[STEPS])KK=1; if(OBJ == STEPS && LOC == game.fixed[STEPS])KK=1;
PSPEAK(OBJ,KK); PSPEAK(OBJ,KK);
L2008: I=LINK[I]; L2008: I=game.link[I];
goto L2004; goto L2004;
L2009: K=54; L2009: K=54;
@ -388,7 +386,7 @@ L2012: VERB=0;
L2600: if(COND[LOC] < game.conds) goto L2603; L2600: if(COND[LOC] < game.conds) goto L2603;
/* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) { /* 2602 */ for (HINT=1; HINT<=HNTMAX; HINT++) {
if(HINTED[HINT]) goto L2602; if(game.hinted[HINT]) goto L2602;
if(!CNDBIT(LOC,HINT+10))HINTLC[HINT]= -1; if(!CNDBIT(LOC,HINT+10))HINTLC[HINT]= -1;
HINTLC[HINT]=HINTLC[HINT]+1; HINTLC[HINT]=HINTLC[HINT]+1;
if(HINTLC[HINT] >= HINTS[HINT][1]) goto L40000; if(HINTLC[HINT] >= HINTS[HINT][1]) goto L40000;
@ -607,7 +605,7 @@ L30310: game.newloc=PLAC[TROLL]+FIXD[TROLL]-LOC;
PROP[CHASM]=1; PROP[CHASM]=1;
PROP[TROLL]=2; PROP[TROLL]=2;
DROP(BEAR,game.newloc); DROP(BEAR,game.newloc);
FIXED[BEAR]= -1; game.fixed[BEAR]= -1;
PROP[BEAR]=3; PROP[BEAR]=3;
game.oldlc2=game.newloc; game.oldlc2=game.newloc;
goto L99; goto L99;
@ -707,8 +705,8 @@ L99: if(game.closng) goto L95;
game.numdie=game.numdie+1; game.numdie=game.numdie+1;
if(!YES(cmdin,79+game.numdie*2,80+game.numdie*2,54)) score(0); if(!YES(cmdin,79+game.numdie*2,80+game.numdie*2,54)) score(0);
if(game.numdie == MAXDIE) score(0); if(game.numdie == MAXDIE) score(0);
PLACE[WATER]=0; game.place[WATER]=0;
PLACE[OIL]=0; game.place[OIL]=0;
if(TOTING(LAMP))PROP[LAMP]=0; if(TOTING(LAMP))PROP[LAMP]=0;
/* 98 */ for (J=1; J<=NOBJECTS; J++) { /* 98 */ for (J=1; J<=NOBJECTS; J++) {
I=NOBJECTS + 1 - J; I=NOBJECTS + 1 - J;
@ -751,8 +749,8 @@ L40010: HINTLC[HINT]=0;
if(!YES(cmdin,HINTS[HINT][3],0,54)) goto L2602; if(!YES(cmdin,HINTS[HINT][3],0,54)) goto L2602;
SETPRM(1,HINTS[HINT][2],HINTS[HINT][2]); SETPRM(1,HINTS[HINT][2],HINTS[HINT][2]);
RSPEAK(261); RSPEAK(261);
HINTED[HINT]=YES(cmdin,175,HINTS[HINT][4],54); game.hinted[HINT]=YES(cmdin,175,HINTS[HINT][4],54);
if(HINTED[HINT] && game.limit > 30)game.limit=game.limit+30*HINTS[HINT][2]; if(game.hinted[HINT] && game.limit > 30)game.limit=game.limit+30*HINTS[HINT][2];
L40020: HINTLC[HINT]=0; L40020: HINTLC[HINT]=0;
L40030: goto L2602; L40030: goto L2602;
@ -761,13 +759,13 @@ L40030: goto L2602;
L40100: if(PROP[GRATE] == 0 && !HERE(KEYS)) goto L40010; L40100: if(PROP[GRATE] == 0 && !HERE(KEYS)) goto L40010;
goto L40020; goto L40020;
L40200: if(PLACE[BIRD] == LOC && TOTING(ROD) && game.oldobj == BIRD) goto L40010; L40200: if(game.place[BIRD] == LOC && TOTING(ROD) && game.oldobj == BIRD) goto L40010;
goto L40030; goto L40030;
L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010; L40300: if(HERE(SNAKE) && !HERE(BIRD)) goto L40010;
goto L40020; goto L40020;
L40400: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0 && game.holdng > L40400: if(game.atloc[LOC] == 0 && game.atloc[game.oldloc] == 0 && game.atloc[game.oldlc2] == 0 && game.holdng >
1) goto L40010; 1) goto L40010;
goto L40020; goto L40020;
@ -779,7 +777,7 @@ L40600: goto L40010;
L40700: if(game.dflag == 0) goto L40010; L40700: if(game.dflag == 0) goto L40010;
goto L40020; goto L40020;
L40800: if(ATLOC[LOC] == 0 && ATLOC[game.oldloc] == 0 && ATLOC[game.oldlc2] == 0) goto L40800: if(game.atloc[LOC] == 0 && game.atloc[game.oldloc] == 0 && game.atloc[game.oldlc2] == 0) goto
L40010; L40010;
goto L40030; goto L40030;
@ -840,9 +838,9 @@ L10000: PROP[GRATE]=0;
JUGGLE(CHASM); JUGGLE(CHASM);
if(PROP[BEAR] != 3)DSTROY(BEAR); if(PROP[BEAR] != 3)DSTROY(BEAR);
PROP[CHAIN]=0; PROP[CHAIN]=0;
FIXED[CHAIN]=0; game.fixed[CHAIN]=0;
PROP[AXE]=0; PROP[AXE]=0;
FIXED[AXE]=0; game.fixed[AXE]=0;
RSPEAK(129); RSPEAK(129);
game.clock1= -1; game.clock1= -1;
game.closng=true; game.closng=true;
@ -883,7 +881,7 @@ L11000: PROP[BOTTLE]=PUT(BOTTLE,115,1);
PROP[PILLOW]=PUT(PILLOW,116,0); PROP[PILLOW]=PUT(PILLOW,116,0);
PROP[MIRROR]=PUT(MIRROR,115,0); PROP[MIRROR]=PUT(MIRROR,115,0);
FIXED[MIRROR]=116; game.fixed[MIRROR]=116;
for (I=1; I<=NOBJECTS; I++) { for (I=1; I<=NOBJECTS; I++) {
if(TOTING(I)) if(TOTING(I))
@ -910,7 +908,7 @@ L12000: RSPEAK(188);
L12200: if(game.lmwarn || !HERE(LAMP)) goto L19999; L12200: if(game.lmwarn || !HERE(LAMP)) goto L19999;
game.lmwarn=true; game.lmwarn=true;
SPK=187; SPK=187;
if(PLACE[BATTER] == 0)SPK=183; if(game.place[BATTER] == 0)SPK=183;
if(PROP[BATTER] == 1)SPK=189; if(PROP[BATTER] == 1)SPK=189;
RSPEAK(SPK); RSPEAK(SPK);
goto L19999; goto L19999;

40
misc.c
View file

@ -509,8 +509,8 @@ long I, J;
/* Juggle an object by picking it up and putting it down again, the purpose /* Juggle an object by picking it up and putting it down again, the purpose
* being to get the object to the front of the chain of things at its loc. */ * being to get the object to the front of the chain of things at its loc. */
I=PLACE[OBJECT]; I=game.place[OBJECT];
J=FIXED[OBJECT]; J=game.fixed[OBJECT];
MOVE(OBJECT,I); MOVE(OBJECT,I);
MOVE(OBJECT+NOBJECTS,J); MOVE(OBJECT+NOBJECTS,J);
return; return;
@ -521,13 +521,13 @@ long FROM;
/* Place any object anywhere by picking it up and dropping it. May already be /* Place any object anywhere by picking it up and dropping it. May already be
* toting, in which case the carry is a no-op. Mustn't pick up objects which * toting, in which case the carry is a no-op. Mustn't pick up objects which
* are not at any loc, since carry wants to remove objects from ATLOC chains. */ * are not at any loc, since carry wants to remove objects from game.atloc chains. */
if(OBJECT > NOBJECTS) goto L1; if(OBJECT > NOBJECTS) goto L1;
FROM=PLACE[OBJECT]; FROM=game.place[OBJECT];
goto L2; goto L2;
L1: {long x = OBJECT-NOBJECTS; FROM=FIXED[x];} L1: {long x = OBJECT-NOBJECTS; FROM=game.fixed[x];}
L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM); L2: if(FROM > 0 && FROM <= 300)CARRY(OBJECT,FROM);
DROP(OBJECT,WHERE); DROP(OBJECT,WHERE);
return; return;
@ -549,35 +549,35 @@ long TEMP;
/* Start toting an object, removing it from the list of things at its former /* Start toting an object, removing it from the list of things at its former
* location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS * location. Incr holdng unless it was already being toted. If OBJECT>NOBJECTS
* (moving "fixed" second loc), don't change PLACE or game.holdng. */ * (moving "fixed" second loc), don't change game.place or game.holdng. */
if(OBJECT > NOBJECTS) goto L5; if(OBJECT > NOBJECTS) goto L5;
if(PLACE[OBJECT] == -1)return; if(game.place[OBJECT] == -1)return;
PLACE[OBJECT]= -1; game.place[OBJECT]= -1;
game.holdng=game.holdng+1; game.holdng=game.holdng+1;
L5: if(ATLOC[WHERE] != OBJECT) goto L6; L5: if(game.atloc[WHERE] != OBJECT) goto L6;
ATLOC[WHERE]=LINK[OBJECT]; game.atloc[WHERE]=game.link[OBJECT];
return; return;
L6: TEMP=ATLOC[WHERE]; L6: TEMP=game.atloc[WHERE];
L7: if(LINK[TEMP] == OBJECT) goto L8; L7: if(game.link[TEMP] == OBJECT) goto L8;
TEMP=LINK[TEMP]; TEMP=game.link[TEMP];
goto L7; goto L7;
L8: LINK[TEMP]=LINK[OBJECT]; L8: game.link[TEMP]=game.link[OBJECT];
return; return;
} }
void DROP(long OBJECT, long WHERE) { void DROP(long OBJECT, long WHERE) {
/* Place an object at a given loc, prefixing it onto the ATLOC list. Decr /* Place an object at a given loc, prefixing it onto the game.atloc list. Decr
* game.holdng if the object was being toted. */ * game.holdng if the object was being toted. */
if(OBJECT > NOBJECTS) goto L1; if(OBJECT > NOBJECTS) goto L1;
if(PLACE[OBJECT] == -1)game.holdng=game.holdng-1; if(game.place[OBJECT] == -1)game.holdng=game.holdng-1;
PLACE[OBJECT]=WHERE; game.place[OBJECT]=WHERE;
goto L2; goto L2;
L1: {long x = OBJECT-NOBJECTS; FIXED[x]=WHERE;} L1: {long x = OBJECT-NOBJECTS; game.fixed[x]=WHERE;}
L2: if(WHERE <= 0)return; L2: if(WHERE <= 0)return;
LINK[OBJECT]=ATLOC[WHERE]; game.link[OBJECT]=game.atloc[WHERE];
ATLOC[WHERE]=OBJECT; game.atloc[WHERE]=OBJECT;
return; return;
} }

View file

@ -40,7 +40,7 @@ void score(long MODE) {
if(I == CHEST)K=14; if(I == CHEST)K=14;
if(I > CHEST)K=16; if(I > CHEST)K=16;
if(PROP[I] >= 0)SCORE=SCORE+2; if(PROP[I] >= 0)SCORE=SCORE+2;
if(PLACE[I] == 3 && PROP[I] == 0)SCORE=SCORE+K-2; if(game.place[I] == 3 && PROP[I] == 0)SCORE=SCORE+K-2;
MXSCOR=MXSCOR+K; MXSCOR=MXSCOR+K;
L20010: /*etc*/ ; L20010: /*etc*/ ;
} /* end loop */ } /* end loop */
@ -69,7 +69,7 @@ L20020: MXSCOR=MXSCOR+45;
/* Did he come to Witt's End as he should? */ /* Did he come to Witt's End as he should? */
if(PLACE[MAGZIN] == 108)SCORE=SCORE+1; if(game.place[MAGZIN] == 108)SCORE=SCORE+1;
MXSCOR=MXSCOR+1; MXSCOR=MXSCOR+1;
/* Round it off. */ /* Round it off. */
@ -80,7 +80,7 @@ L20020: MXSCOR=MXSCOR+45;
/* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */ /* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
for (I=1; I<=HNTMAX; I++) { for (I=1; I<=HNTMAX; I++) {
if(HINTED[I])SCORE=SCORE-HINTS[I][2]; if(game.hinted[I])SCORE=SCORE-HINTS[I][2];
} /* end loop */ } /* end loop */
if(game.novice)SCORE=SCORE-5; if(game.novice)SCORE=SCORE-5;
if(game.clshnt)SCORE=SCORE-10; if(game.clshnt)SCORE=SCORE-10;

View file

@ -2,3 +2,4 @@
#define LOCSIZ 185 #define LOCSIZ 185
#define NOBJECTS 100 #define NOBJECTS 100
#define HNTSIZ 20