8 #define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */
9 #define DALTLC 18 /* alternate dwarf location; low room */
14 #define INTRANSITIVE -1 /* illegal object number */
16 typedef struct lcg_state
18 unsigned long a, c, m, x;
21 typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */
22 typedef long vocab_t; /* index into a vocabulary array */
63 long abbrev[LOCSIZ+1];
65 long dseen[NDWARVES+1];
66 long dloc[NDWARVES+1];
67 long odloc[NDWARVES+1];
68 long fixed[NOBJECTS+1];
69 long link[NOBJECTS*2 + 1];
70 long place[NOBJECTS+1];
71 long hinted[HNTSIZ+1];
72 long hintlc[HNTSIZ+1];
73 long prop[NOBJECTS+1];
76 extern struct game_t game;
78 extern long LNLENG, LNPOSN, PARMS[];
79 extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[];
82 extern lcg_state lcgstate;
84 /* b is not needed for POSIX but harmless */
85 #define READ_MODE "rb"
86 #define WRITE_MODE "wb"
88 extern void SPEAK(vocab_t);
89 extern void PSPEAK(vocab_t,int);
90 extern void RSPEAK(vocab_t);
91 extern void SETPRM(long,long,long);
93 extern bool fGETIN(FILE *,token_t*,token_t*,token_t*,token_t*);
94 #define GETIN(input,WORD1,WORD1X,WORD2,WORD2X) fGETIN(input,&WORD1,&WORD1X,&WORD2,&WORD2X)
96 extern long YES(FILE *,vocab_t,vocab_t,vocab_t);
97 extern long GETTXT(bool,bool,bool);
98 extern token_t MAKEWD(long);
100 extern void fPUTTXT(token_t,long*,long);
101 #define PUTTXT(WORD,STATE,CASE) fPUTTXT(WORD,&STATE,CASE)
103 extern void SHFTXT(long,long);
104 extern void TYPE0(void);
106 extern void fSAVWDS(long*,long*,long*,long*,long*,long*,long*);
107 #define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7)
108 extern void fSAVARR(long*,long);
109 #define SAVARR(ARR,N) fSAVARR(ARR,N)
110 extern void fSAVWRD(long,long*);
111 #define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD)
113 extern long VOCAB(long,long);
114 extern void DSTROY(long);
115 extern void JUGGLE(long);
116 extern void MOVE(long,long);
117 extern long PUT(long,long,long);
118 extern void CARRY(long,long);
119 extern void DROP(long,long);
120 extern long ATDWRF(long);
121 extern long SETBIT(long);
122 extern bool TSTBIT(long,int);
123 extern long RNDVOC(long,long);
124 extern void BUG(long) __attribute__((noreturn));
125 extern void MAPLIN(FILE *);
126 extern void TYPE(void);
127 extern void MPINIT(void);
129 extern void fSAVEIO(long,long,long*);
130 #define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR)
131 extern void DATIME(long*, long*);
133 extern long MOD(long,long);
135 extern void set_seed(long);
136 extern unsigned long get_next_lcg_value(void);
137 extern long randrange(long);
138 extern void score(long);
139 extern int carry(long);
140 extern int discard(long, bool);
141 extern int attack(FILE *, long, long);
142 extern int throw(FILE *, long, long);
143 extern int feed(long);
144 extern int fill(long);
146 /* Statement functions
148 * AT(OBJ) = true if on either side of two-placed object
149 * CNDBIT(L,N) = true if COND(L) has bit n set (bit 0 is units bit)
150 * DARK(DUMMY) = true if location "LOC" is dark
151 * FORCED(LOC) = true if LOC moves without asking for input (COND=2)
152 * FOREST(LOC) = true if LOC is part of the forest
153 * GSTONE(OBJ) = true if OBJ is a gemstone
154 * HERE(OBJ) = true if the OBJ is at "LOC" (or is being carried)
155 * LIQ(DUMMY) = object number of liquid in bottle
156 * LIQLOC(LOC) = object number of liquid (if any) at LOC
157 * PCT(N) = true N% of the time (N integer from 0 to 100)
158 * TOTING(OBJ) = true if the OBJ is being carried */
160 #define TOTING(OBJ) (game.place[OBJ] == -1)
161 #define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
162 #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
163 #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
164 #define LIQ(DUMMY) (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE]))
165 #define LIQLOC(LOC) (LIQ2((MOD(COND[LOC]/2*2,8)-5)*MOD(COND[LOC]/4,2)+1))
166 #define CNDBIT(L,N) (TSTBIT(COND[L],N))
167 #define FORCED(LOC) (COND[LOC] == 2)
168 #define DARK(DUMMY) ((!CNDBIT(game.loc,0)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
169 #define PCT(N) (randrange(100) < (N))
170 #define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
171 #define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166)
172 #define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
174 /* The following two functions were added to fix a bug (game.clock1 decremented
175 * while in forest). They should probably be replaced by using another
176 * "cond" bit. For now, however, a quick fix... OUTSID(LOC) is true if
177 * LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
178 * of mists or deeper). Note special kludges for "Foof!" locs. */
180 #define OUTSID(LOC) ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
181 #define INDEEP(LOC) ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
183 /* vocabulary items */
184 extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
185 BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
186 CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
187 EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, GRATE, HINT, INVENT,
188 JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGZIN, MESSAG, MIRROR, NUGGET, NUL,
189 OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
190 RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SECT, SIGN, SNAKE,
191 STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
192 URN, VASE, VEND, VOLCAN, WATER;
193 /* everything else */
194 extern long I, J, K, L, SPK, VRSION, WD1, WD1X, WD2, WD2X;