1 /* $NetBSD: extern.h,v 1.31 2005/07/01 06:04:54 jmc Exp $ */
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)externs.h 8.1 (Berkeley) 5/31/93
44 #define BITS (8 * sizeof (int))
46 #define OUTSIDE (position > 68 && position < 246 && position != 218)
47 #define rnd(x) (rand() % (x))
48 #define max(a,b) ((a) < (b) ? (b) : (a))
49 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
50 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
51 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
53 /* well known rooms */
124 #define DEADNATIVE 57
131 #define NUMOFOBJECTS 64
132 /* non-objects below */
155 #define EVERYTHING 1022
192 #define ARM 6 /* broken arm */
193 #define RIBS 7 /* broken ribs */
194 #define SPINE 9 /* broken back */
195 #define SKULL 11 /* fractured skull */
196 #define INCISE 10 /* deep incisions */
197 #define NECK 12 /* broken NECK */
198 #define NUMOFINJURIES 13
209 /* Number of times room description shown. */
212 /* fundamental constants */
213 #define NUMOFROOMS 275
214 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
215 #define LINELENGTH 81
221 /* initial variable values */
228 * These are flags for objects in the objflags array. OBJ_PLURAL means
229 * that the object short name is plural; OBJ_AN that it begins with a
230 * vowel sound so should be preceded by "an" instead of "a"; OBJ_PERSON
231 * that it is a living person; OBJ_NONOBJ that it is not an object (to
232 * which any game action can be applied) at all (e.g. footsteps, asteroids).
233 * Any individual object has at most one of OBJ_PERSON and OBJ_NONOBJ.
243 #define north link[0]
244 #define south link[1]
248 #define access link[5]
250 #define flyhere link[7]
252 unsigned int objects
[NUMOFWORDS
];
254 extern struct room dayfile
[];
255 extern struct room nightfile
[];
256 extern struct room
*location
;
258 /* object characteristics */
259 extern const char *const objdes
[NUMOFOBJECTS
];
260 extern const char *const objsht
[NUMOFOBJECTS
];
261 extern const char *const ouch
[NUMOFINJURIES
];
262 extern const int objwt
[NUMOFOBJECTS
];
263 extern const int objcumber
[NUMOFOBJECTS
];
264 extern const int objflags
[NUMOFOBJECTS
];
265 #define is_plural_object(n) (objflags[(n)] & OBJ_PLURAL)
267 * These macros yield words to use with objects (followed but not preceded
268 * by spaces, or with no spaces if the expansion is the empty string).
270 #define A_OR_AN(n) (objflags[(n)] & OBJ_AN ? "an " : "a ")
271 #define A_OR_AN_OR_THE(n) (is_plural_object((n)) ? "the " : A_OR_AN((n)))
272 #define A_OR_AN_OR_BLANK(n) (is_plural_object((n)) ? "" : A_OR_AN((n)))
273 #define IS_OR_ARE(n) (is_plural_object((n)) ? "are " : "is ")
275 /* current input line */
277 #define NWORD 20 /* words per line */
278 extern char words
[NWORD
][WORDLEN
];
279 extern int wordvalue
[NWORD
];
280 extern int wordtype
[NWORD
];
281 extern int wordcount
, wordnumber
;
283 /* state of the game */
286 extern int direction
;
287 extern int left
, right
, ahead
, back
;
288 extern int ourclock
, fuel
, torps
;
289 extern int carrying
, encumber
;
291 extern int followfight
;
295 extern int followgod
;
301 extern int matchlight
, matchcount
;
303 extern int pleasure
, power
, ego
;
306 extern int notes
[NUMOFNOTES
];
307 extern unsigned int inven
[NUMOFWORDS
];
308 extern unsigned int wear
[NUMOFWORDS
];
309 extern char beenthere
[NUMOFROOMS
+ 1];
310 extern char injuries
[NUMOFINJURIES
];
313 extern const char *username
;
320 extern struct wlist wlist
[];
326 extern const struct objs dayobjs
[];
327 extern const struct objs nightobjs
[];
329 #define DEFAULT_SAVE_FILE ".Bstar"
332 int card(const char *, int);
336 void die(void) __attribute__((__noreturn__
));
337 void diesig(int) __attribute__((__noreturn__
));
343 int drop(const char *);
347 char *getcom(char *, int, const char *, const char *);
348 char *getword(char *, char *, int);
350 void initialize(const char *);
356 void live(void) __attribute__((__noreturn__
));
358 int moveplayer(int, int);
362 void open_score_file(void);
364 void printobjs(void);
367 const char *rate(void);
369 void restore(const char *);
371 void save(const char *);
372 char *save_file_name(const char *, size_t);
374 int take(unsigned int[]);
376 int throw(const char *);
377 const char *truedirec(int, int);
378 int ucard(const unsigned int *);
382 void whichway(struct room
);