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];
80 extern const char ascii_to_advent[];
81 extern const char advent_to_ascii[];
84 extern lcg_state lcgstate;
86 /* b is not needed for POSIX but harmless */
87 #define READ_MODE "rb"
88 #define WRITE_MODE "wb"
90 extern void SPEAK(vocab_t);
91 extern void PSPEAK(vocab_t,int);
92 extern void RSPEAK(vocab_t);
93 extern void SETPRM(long,long,long);
94 extern bool GETIN(FILE *,token_t*,token_t*,token_t*,token_t*);
95 extern long YES(FILE *,vocab_t,vocab_t,vocab_t);
96 extern long GETTXT(bool,bool,bool);
97 extern token_t MAKEWD(long);
98 extern void PUTTXT(token_t,long*,long);
99 extern void SHFTXT(long,long);
100 extern void TYPE0(void);
102 extern void fSAVWDS(long*,long*,long*,long*,long*,long*,long*);
103 #define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7)
104 extern void fSAVARR(long*,long);
105 #define SAVARR(ARR,N) fSAVARR(ARR,N)
106 extern void fSAVWRD(long,long*);
107 #define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD)
109 extern long VOCAB(long,long);
110 extern void DSTROY(long);
111 extern void JUGGLE(long);
112 extern void MOVE(long,long);
113 extern long PUT(long,long,long);
114 extern void CARRY(long,long);
115 extern void DROP(long,long);
116 extern long ATDWRF(long);
117 extern long SETBIT(long);
118 extern bool TSTBIT(long,int);
119 extern long RNDVOC(long,long);
120 extern void BUG(long) __attribute__((noreturn));
121 extern bool MAPLIN(FILE *);
122 extern void TYPE(void);
124 extern void fSAVEIO(long,long,long*);
125 #define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR)
126 extern void DATIME(long*, long*);
128 extern long MOD(long,long);
130 extern void set_seed(long);
131 extern unsigned long get_next_lcg_value(void);
132 extern long randrange(long);
133 extern void score(long);
135 /* Statement functions
137 * AT(OBJ) = true if on either side of two-placed object
138 * CNDBIT(L,N) = true if COND(L) has bit n set (bit 0 is units bit)
139 * DARK(DUMMY) = true if location "LOC" is dark
140 * FORCED(LOC) = true if LOC moves without asking for input (COND=2)
141 * FOREST(LOC) = true if LOC is part of the forest
142 * GSTONE(OBJ) = true if OBJ is a gemstone
143 * HERE(OBJ) = true if the OBJ is at "LOC" (or is being carried)
144 * LIQ(DUMMY) = object number of liquid in bottle
145 * LIQLOC(LOC) = object number of liquid (if any) at LOC
146 * PCT(N) = true N% of the time (N integer from 0 to 100)
147 * TOTING(OBJ) = true if the OBJ is being carried */
149 #define TOTING(OBJ) (game.place[OBJ] == -1)
150 #define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
151 #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
152 #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
153 #define LIQ(DUMMY) (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE]))
154 #define LIQLOC(LOC) (LIQ2((MOD(COND[LOC]/2*2,8)-5)*MOD(COND[LOC]/4,2)+1))
155 #define CNDBIT(L,N) (TSTBIT(COND[L],N))
156 #define FORCED(LOC) (COND[LOC] == 2)
157 #define DARK(DUMMY) ((!CNDBIT(game.loc,0)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
158 #define PCT(N) (randrange(100) < (N))
159 #define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
160 #define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166)
161 #define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
163 /* The following two functions were added to fix a bug (game.clock1 decremented
164 * while in forest). They should probably be replaced by using another
165 * "cond" bit. For now, however, a quick fix... OUTSID(LOC) is true if
166 * LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
167 * of mists or deeper). Note special kludges for "Foof!" locs. */
169 #define OUTSID(LOC) ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
170 #define INDEEP(LOC) ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
172 /* vocabulary items */
173 extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
174 BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
175 CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
176 EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, GRATE, HINT, INVENT,
177 JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGZIN, MESSAG, MIRROR, NUGGET, NUL,
178 OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
179 RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
180 STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
181 URN, VASE, VEND, VOLCAN, WATER;
182 /* everything else */
183 extern long K, SPK, WD1, WD1X, WD2, WD2X;
185 enum speechpart {unknown, intransitive, transitive};