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 */
62 long abbrev[LOCSIZ+1];
64 long dseen[NDWARVES+1];
65 long dloc[NDWARVES+1];
66 long odloc[NDWARVES+1];
67 long fixed[NOBJECTS+1];
68 long link[NOBJECTS*2 + 1];
69 long place[NOBJECTS+1];
70 long hinted[HNTSIZ+1];
71 long hintlc[HNTSIZ+1];
72 long prop[NOBJECTS+1];
75 extern struct game_t game;
77 extern long LNLENG, LNPOSN, PARMS[];
78 extern char rawbuf[LINESIZE], INLINE[LINESIZE+1];
79 extern const char ascii_to_advent[];
80 extern const char advent_to_ascii[];
82 extern bool oldstyle, editline, prompt;
83 extern lcg_state lcgstate;
85 /* b is not needed for POSIX but harmless */
86 #define READ_MODE "rb"
87 #define WRITE_MODE "wb"
88 extern char* xstrdup(const char*);
89 extern void packed_to_token(long, char token[6]);
90 extern void newspeak(char*);
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 TYPE0(void);
99 extern long VOCAB(long,long);
100 extern void DSTROY(long);
101 extern void JUGGLE(long);
102 extern void MOVE(long,long);
103 extern long PUT(long,long,long);
104 extern void CARRY(long,long);
105 extern void DROP(long,long);
106 extern long ATDWRF(long);
107 extern long SETBIT(long);
108 extern bool TSTBIT(long,int);
109 extern long RNDVOC(long,long);
110 extern void BUG(long) __attribute__((noreturn));
111 extern bool MAPLIN(FILE *);
112 extern void TYPE(void);
113 extern void DATIME(long*, long*);
115 extern void set_seed(long);
116 extern unsigned long get_next_lcg_value(void);
117 extern long randrange(long);
118 extern void score(long);
119 extern int saveresume(FILE *, bool);
122 * MOD(N,M) = Arithmetic modulus
123 * AT(OBJ) = true if on either side of two-placed object
124 * CNDBIT(L,N) = true if COND(L) has bit n set (bit 0 is units bit)
125 * DARK(LOC) = true if location "LOC" is dark
126 * FORCED(LOC) = true if LOC moves without asking for input (COND=2)
127 * FOREST(LOC) = true if LOC is part of the forest
128 * GSTONE(OBJ) = true if OBJ is a gemstone
129 * HERE(OBJ) = true if the OBJ is at "LOC" (or is being carried)
130 * LIQUID() = object number of liquid in bottle
131 * LIQLOC(LOC) = object number of liquid (if any) at LOC
132 * PCT(N) = true N% of the time (N integer from 0 to 100)
133 * TOTING(OBJ) = true if the OBJ is being carried */
135 #define MOD(N,M) ((N) % (M))
136 #define TOTING(OBJ) (game.place[OBJ] == -1)
137 #define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
138 #define HERE(OBJ) (AT(OBJ) || TOTING(OBJ))
139 #define LIQ2(PBOTL) ((1-(PBOTL))*WATER+((PBOTL)/2)*(WATER+OIL))
140 #define LIQUID() (LIQ2(game.prop[BOTTLE]<0 ? -1-game.prop[BOTTLE] : game.prop[BOTTLE]))
141 #define LIQLOC(LOC) (LIQ2((MOD(COND[LOC]/2*2,8)-5)*MOD(COND[LOC]/4,2)+1))
142 #define CNDBIT(L,N) (TSTBIT(COND[L],N))
143 #define FORCED(LOC) (COND[LOC] == 2)
144 #define DARK(DUMMY) ((!CNDBIT(game.loc,0)) && (game.prop[LAMP] == 0 || !HERE(LAMP)))
145 #define PCT(N) (randrange(100) < (N))
146 #define GSTONE(OBJ) ((OBJ) == EMRALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
147 #define FOREST(LOC) ((LOC) >= 145 && (LOC) <= 166)
148 #define VOCWRD(LETTRS,SECT) (VOCAB(MAKEWD(LETTRS),SECT))
150 /* The following two functions were added to fix a bug (game.clock1 decremented
151 * while in forest). They should probably be replaced by using another
152 * "cond" bit. For now, however, a quick fix... OUTSID(LOC) is true if
153 * LOC is outside, INDEEP(LOC) is true if LOC is "deep" in the cave (hall
154 * of mists or deeper). Note special kludges for "Foof!" locs. */
156 #define OUTSID(LOC) ((LOC) <= 8 || FOREST(LOC) || (LOC) == PLAC[SAPPH] || (LOC) == 180 || (LOC) == 182)
157 #define INDEEP(LOC) ((LOC) >= 15 && !OUTSID(LOC) && (LOC) != 179)
159 /* vocabulary items */
160 extern long AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
161 BIRD, BLOOD, BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST,
162 CLAM, COINS, DOOR, DPRSSN, DRAGON, DWARF, EGGS,
163 EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOD, GRATE, HINT, INVENT,
164 JADE, KEYS, KNIFE, LAMP, LOCK, LOOK, MAGZIN, MESSAG, MIRROR, NUGGET, NUL,
165 OGRE, OIL, OYSTER, PANIC, PEARL, PILLOW, PLANT, PLANT2, PYRAM,
166 RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAY, SIGN, SNAKE,
167 STEPS, STICK, STREAM, THROW, TRIDNT, TROLL, TROLL2,
168 URN, VASE, VEND, VOLCAN, WATER;
170 enum speechpart {unknown, intransitive, transitive};
172 /* Phase codes for action returns.
173 * These were at one time FORTRAN line numbers.
174 * The values don't matter, but perturb their order at your peril.
176 #define GO_TERMINATE 2
179 #define GO_CLEAROBJ 2012
180 #define GO_CHECKHINT 2600
181 #define GO_CHECKFOO 2607
182 #define GO_CLOSEJUMP 2610
183 #define GO_DIRECTION 2620
184 #define GO_LOOKUP 2630
185 #define GO_WORD2 2800
186 #define GO_SPECIALS 1900
187 #define GO_UNKNOWN 8000
188 #define GO_ACTION 40000
189 #define GO_DWARFWAKE 19000
191 /* hack to ignore GCC Unused Result */
192 #define IGNORE(r) do{if (r){}}while(0)