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 */
15 #define SPECIALBASE 300 /* base umber of special rooms */
17 typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */
18 typedef long vocab_t; /* index into a vocabulary array */
21 unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
59 long abbrev[LOCSIZ+1];
61 long dseen[NDWARVES+1];
62 long dloc[NDWARVES+1];
63 long odloc[NDWARVES+1];
64 long fixed[NOBJECTS+1];
65 long link[NOBJECTS*2 + 1];
66 long place[NOBJECTS+1];
67 long hinted[HNTSIZ+1];
68 long hintlc[HNTSIZ+1];
69 long prop[NOBJECTS+1];
72 extern struct game_t game;
74 extern long LNLENG, LNPOSN, PARMS[];
75 extern char rawbuf[LINESIZE], INLINE[LINESIZE+1];
76 extern const char ascii_to_advent[];
77 extern const char advent_to_ascii[];
79 extern bool oldstyle, editline, prompt;
81 /* b is not needed for POSIX but harmless */
82 #define READ_MODE "rb"
83 #define WRITE_MODE "wb"
84 extern char* xstrdup(const char*);
85 extern void packed_to_token(long, char token[6]);
86 extern void newspeak(char*);
87 extern void PSPEAK(vocab_t,int);
88 extern void RSPEAK(vocab_t);
89 extern void SETPRM(long,long,long);
90 extern bool GETIN(FILE *,token_t*,token_t*,token_t*,token_t*);
91 extern long YES(FILE *,vocab_t,vocab_t,vocab_t);
92 extern long GETTXT(bool,bool,bool);
93 extern token_t MAKEWD(long);
94 extern void TYPE0(void);
95 extern long VOCAB(long,long);
96 extern void DSTROY(long);
97 extern void JUGGLE(long);
98 extern void MOVE(long,long);
99 extern long PUT(long,long,long);
100 extern void CARRY(long,long);
101 extern void DROP(long,long);
102 extern long ATDWRF(long);
103 extern long SETBIT(long);
104 extern bool TSTBIT(long,int);
105 extern long RNDVOC(long,long);
106 extern void BUG(long) __attribute__((noreturn));
107 extern bool MAPLIN(FILE *);
108 extern void TYPE(void);
109 extern void DATIME(long*, long*);
111 extern void set_seed(long);
112 extern unsigned long get_next_lcg_value(void);
113 extern long randrange(long);
114 extern void score(long);
115 extern int saveresume(FILE *, bool);
118 * MOD(N,M) = Arithmetic modulus
119 * AT(OBJ) = true if on either side of two-placed object
120 * CNDBIT(L,N) = true if COND(L) has bit n set (bit 0 is units bit)
121 * DARK(LOC) = true if location "LOC" is dark
122 * FORCED(LOC) = true if LOC moves without asking for input (COND=2)
123 * FOREST(LOC) = true if LOC is part of the forest
124 * GSTONE(OBJ) = true if OBJ is a gemstone
125 * HERE(OBJ) = true if the OBJ is at "LOC" (or is being carried)
126 * LIQUID() = object number of liquid in bottle
127 * LIQLOC(LOC) = object number of liquid (if any) at LOC
128 * PCT(N) = true N% of the time (N integer from 0 to 100)
129 * TOTING(OBJ) = true if the OBJ is being carried */
131 #define MOD(N,M) ((N) % (M))
132 #define TOTING(OBJ) (game.place[OBJ] == -1)
133 #define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
134 #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
135 #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
136 #define LIQUID() (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE]))
137 #define LIQLOC(LOC) (LIQ2((MOD(COND[LOC]/2*2,8)-5)*MOD(COND[LOC]/4,2)+1))
138 #define CNDBIT(L,N) (TSTBIT(COND[L],N))
139 #define FORCED(LOC) (COND[LOC] == 2)
140 #define DARK(DUMMY) ((!CNDBIT(game.loc,LIGHT)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
141 #define PCT(N) (randrange(100) < (N))
142 #define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
143 #define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166)
144 #define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
145 #define SPECIAL(LOC) ((LOC) > SPECIALBASE)
147 /* The following two functions were added to fix a bug (game.clock1 decremented
148 * while in forest). They should probably be replaced by using another
149 * "cond" bit. For now, however, a quick fix... OUTSID(LOC) is true if
150 * LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
151 * of mists or deeper). Note special kludges for "Foof!" locs. */
153 #define OUTSID(LOC) ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
154 #define INDEEP(LOC) ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
156 /* vocabulary items */
157 extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
158 BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
159 CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
160 EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, GRATE, HINT, INVENT,
161 JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGZIN, MESSAG, MIRROR, NUGGET, NUL,
162 OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
163 RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
164 STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
165 URN, VASE, VEND, VOLCAN, WATER;
167 enum speechpart {unknown, intransitive, transitive};
169 /* Phase codes for action returns.
170 * These were at one time FORTRAN line numbers.
171 * The values don't matter, but perturb their order at your peril.
173 #define GO_TERMINATE 2
176 #define GO_CLEAROBJ 2012
177 #define GO_CHECKHINT 2600
178 #define GO_CHECKFOO 2607
179 #define GO_CLOSEJUMP 2610
180 #define GO_DIRECTION 2620
181 #define GO_LOOKUP 2630
182 #define GO_WORD2 2800
183 #define GO_SPECIALS 1900
184 #define GO_UNKNOWN 8000
185 #define GO_ACTION 40000
186 #define GO_DWARFWAKE 19000
188 /* Symbols for cond bits */
189 #define LIGHT 0 /* Light */
190 #define OILY 1 /* If bit 2 is on: on for oil, off for water */
191 #define FLUID 2 /* Liquid asset, see bit 1 */
192 #define NOARRR 3 /* Pirate doesn't go here unless following player */
193 #define NOBACK 4 /* Cannot use "back" to move away */
194 /* Bits past 10 indicate areas of interest to "hint" routines */
195 #define HBASE 10 /* Base for location hint bitss */
196 #define HCAVE 11 /* Trying to get into cave */
197 #define HBIRD 12 /* Trying to catch bird */
198 #define HSNAKE 13 /* Trying to deal with snake */
199 #define HMAZE 14 /* Lost in maze */
200 #define HDARK 15 /* Pondering dark room */
201 #define HWITT 16 /* At Witt's End */
202 #define HCLIFF 17 /* Cliff with urn */
203 #define HWOODS 18 /* Lost in forest */
204 #define HOGRE 19 /* Trying to deal with ogre */
205 #define HJADE 20 /* Found all treasures except jade */
207 /* hack to ignore GCC Unused Result */
208 #define IGNORE(r) do{if (r){}}while(0)