]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/externs.h
from Lite
[bsdgames-darwin.git] / battlestar / externs.h
1 /* $NetBSD: externs.h,v 1.4 1995/03/21 15:07:25 cgd Exp $ */
2
3 /*
4 * Copyright (c) 1983, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)externs.h 8.1 (Berkeley) 5/31/93
36 */
37
38 #include <signal.h>
39 #include <stdio.h>
40
41 #define BITS (8 * sizeof (int))
42
43 #define OUTSIDE (position > 68 && position < 246 && position != 218)
44 #define rnd(x) (rand() % (x))
45 #define max(a,b) ((a) < (b) ? (b) : (a))
46 #define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
47 #define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
48 #define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
49
50 /* well known rooms */
51 #define FINAL 275
52 #define GARDEN 197
53 #define POOLS 126
54 #define DOCK 93
55
56 /* word types */
57 #define VERB 0
58 #define OBJECT 1
59 #define NOUNS 2
60 #define PREPS 3
61 #define ADJS 4
62 #define CONJ 5
63
64 /* words numbers */
65 #define KNIFE 0
66 #define SWORD 1
67 #define LAND 2
68 #define WOODSMAN 3
69 #define TWO_HANDED 4
70 #define CLEAVER 5
71 #define BROAD 6
72 #define MAIL 7
73 #define HELM 8
74 #define SHIELD 9
75 #define MAID 10
76 #define BODY 10
77 #define VIPER 11
78 #define LAMPON 12
79 #define SHOES 13
80 #define CYLON 14
81 #define PAJAMAS 15
82 #define ROBE 16
83 #define AMULET 17
84 #define MEDALION 18
85 #define TALISMAN 19
86 #define DEADWOOD 20
87 #define MALLET 21
88 #define LASER 22
89 #define BATHGOD 23
90 #define NORMGOD 24
91 #define GRENADE 25
92 #define CHAIN 26
93 #define ROPE 27
94 #define LEVIS 28
95 #define MACE 29
96 #define SHOVEL 30
97 #define HALBERD 31
98 #define COMPASS 32
99 #define CRASH 33
100 #define ELF 34
101 #define FOOT 35
102 #define COINS 36
103 #define MATCHES 37
104 #define MAN 38
105 #define PAPAYAS 39
106 #define PINEAPPLE 40
107 #define KIWI 41
108 #define COCONUTS 42
109 #define MANGO 43
110 #define RING 44
111 #define POTION 45
112 #define BRACELET 46
113 #define GIRL 47
114 #define GIRLTALK 48
115 #define DARK 49
116 #define TIMER 50
117 #define CHAR 53
118 #define BOMB 54
119 #define DEADGOD 55
120 #define DEADTIME 56
121 #define DEADNATIVE 57
122 #define NATIVE 58
123 #define HORSE 59
124 #define CAR 60
125 #define POT 61
126 #define BAR 62
127 #define BLOCK 63
128 #define NUMOFOBJECTS 64
129 /* non-objects below */
130 #define UP 1000
131 #define DOWN 1001
132 #define AHEAD 1002
133 #define BACK 1003
134 #define RIGHT 1004
135 #define LEFT 1005
136 #define TAKE 1006
137 #define USE 1007
138 #define LOOK 1008
139 #define QUIT 1009
140 #define NORTH 1010
141 #define SOUTH 1011
142 #define EAST 1012
143 #define WEST 1013
144 #define SU 1014
145 #define DROP 1015
146 #define TAKEOFF 1016
147 #define DRAW 1017
148 #define PUTON 1018
149 #define WEARIT 1019
150 #define PUT 1020
151 #define INVEN 1021
152 #define EVERYTHING 1022
153 #define AND 1023
154 #define KILL 1024
155 #define RAVAGE 1025
156 #define UNDRESS 1026
157 #define THROW 1027
158 #define LAUNCH 1028
159 #define LANDIT 1029
160 #define LIGHT 1030
161 #define FOLLOW 1031
162 #define KISS 1032
163 #define LOVE 1033
164 #define GIVE 1034
165 #define SMITE 1035
166 #define SHOOT 1036
167 #define ON 1037
168 #define OFF 1038
169 #define TIME 1039
170 #define SLEEP 1040
171 #define DIG 1041
172 #define EAT 1042
173 #define SWIM 1043
174 #define DRINK 1044
175 #define DOOR 1045
176 #define SAVE 1046
177 #define RIDE 1047
178 #define DRIVE 1048
179 #define SCORE 1049
180 #define BURY 1050
181 #define JUMP 1051
182 #define KICK 1052
183
184 /* injuries */
185 #define ARM 6 /* broken arm */
186 #define RIBS 7 /* broken ribs */
187 #define SPINE 9 /* broken back */
188 #define SKULL 11 /* fractured skull */
189 #define INCISE 10 /* deep incisions */
190 #define NECK 12 /* broken NECK */
191 #define NUMOFINJURIES 13
192
193 /* notes */
194 #define CANTLAUNCH 0
195 #define LAUNCHED 1
196 #define CANTSEE 2
197 #define CANTMOVE 3
198 #define JINXED 4
199 #define DUG 5
200 #define NUMOFNOTES 6
201
202 /* fundamental constants */
203 #define NUMOFROOMS 275
204 #define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
205 #define LINELENGTH 81
206
207 #define TODAY 0
208 #define TONIGHT 1
209 #define CYCLE 100
210
211 /* initial variable values */
212 #define TANKFULL 250
213 #define TORPEDOES 10
214 #define MAXWEIGHT 60
215 #define MAXCUMBER 10
216
217 struct room {
218 char *name;
219 int link[8];
220 #define north link[0]
221 #define south link[1]
222 #define east link[2]
223 #define west link[3]
224 #define up link[4]
225 #define access link[5]
226 #define down link[6]
227 #define flyhere link[7]
228 char *desc;
229 unsigned int objects[NUMOFWORDS];
230 };
231 struct room dayfile[];
232 struct room nightfile[];
233 struct room *location;
234
235 /* object characteristics */
236 char *objdes[NUMOFOBJECTS];
237 char *objsht[NUMOFOBJECTS];
238 char *ouch[NUMOFINJURIES];
239 int objwt[NUMOFOBJECTS];
240 int objcumber[NUMOFOBJECTS];
241
242 /* current input line */
243 #define NWORD 20 /* words per line */
244 char words[NWORD][15];
245 int wordvalue[NWORD];
246 int wordtype[NWORD];
247 int wordcount, wordnumber;
248
249 char *truedirec(), *rate();
250 char *getcom(), *getword();
251
252 /* state of the game */
253 int time;
254 int position;
255 int direction;
256 int left, right, ahead, back;
257 int clock, fuel, torps;
258 int carrying, encumber;
259 int rythmn;
260 int followfight;
261 int ate;
262 int snooze;
263 int meetgirl;
264 int followgod;
265 int godready;
266 int win;
267 int wintime;
268 int wiz;
269 int tempwiz;
270 int matchlight, matchcount;
271 int loved;
272 int pleasure, power, ego;
273 int WEIGHT;
274 int CUMBER;
275 int notes[NUMOFNOTES];
276 unsigned int inven[NUMOFWORDS];
277 unsigned int wear[NUMOFWORDS];
278 char beenthere[NUMOFROOMS+1];
279 char injuries[NUMOFINJURIES];
280
281 char uname[9];
282
283 struct wlist {
284 char *string;
285 int value, article;
286 struct wlist *next;
287 };
288 #define HASHSIZE 256
289 #define HASHMUL 81
290 #define HASHMASK (HASHSIZE - 1)
291 struct wlist *hashtab[HASHSIZE];
292 struct wlist wlist[];
293
294 struct objs {
295 short room;
296 short obj;
297 };
298 struct objs dayobjs[];
299 struct objs nightobjs[];