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