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