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