]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - trek/trek.h
convert __attribute__s to applicable cdefs.h macros
[bsdgames-darwin.git] / trek / trek.h
1 /* $NetBSD: trek.h,v 1.11 2005/02/15 12:54:50 jsm Exp $ */
2
3 /*
4 * Copyright (c) 1980, 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. 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.
18 *
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
29 * SUCH DAMAGE.
30 *
31 * @(#)trek.h 8.1 (Berkeley) 5/31/93
32 */
33
34 /*
35 ** Global Declarations
36 **
37 ** Virtually all non-local variable declarations are made in this
38 ** file. Exceptions are those things which are initialized, which
39 ** are defined in "externs.c", and things which are local to one
40 ** program file.
41 **
42 ** So far as I know, nothing in here must be preinitialized to
43 ** zero.
44 */
45
46 /* external function definitions */
47
48 /********************* GALAXY **************************/
49
50 /* galactic parameters */
51 # define NSECTS 10 /* dimensions of quadrant in sectors */
52 # define NQUADS 8 /* dimension of galazy in quadrants */
53 # define NINHAB 32 /* number of quadrants which are inhabited */
54
55 struct quad /* definition for each quadrant */
56 {
57 unsigned char bases; /* number of bases in this quadrant */
58 char klings; /* number of Klingons in this quadrant */
59 char holes; /* number of black holes in this quadrant */
60 int scanned; /* star chart entry (see below) */
61 short stars; /* number of stars in this quadrant */
62 char qsystemname; /* starsystem name (see below) */
63 };
64
65 # define Q_DISTRESSED 0200
66 # define Q_SYSTEM 077
67
68 /* systemname conventions:
69 * 1 -> NINHAB index into Systemname table for live system.
70 * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM
71 * is the index into the Event table which will
72 * have the system name
73 * 0 dead or nonexistent starsystem
74 *
75 * starchart ("scanned") conventions:
76 * 0 -> 999 taken as is
77 * -1 not yet scanned ("...")
78 * 1000 supernova ("///")
79 * 1001 starbase + ??? (".1.")
80 */
81
82 /* ascii names of systems */
83 extern const char *const Systemname[NINHAB];
84
85 /* quadrant definition */
86 extern struct quad Quad[NQUADS][NQUADS];
87
88 /* defines for sector map (below) */
89 # define EMPTY '.'
90 # define STAR '*'
91 # define BASE '#'
92 # define ENTERPRISE 'E'
93 # define QUEENE 'Q'
94 # define KLINGON 'K'
95 # define INHABIT '@'
96 # define HOLE ' '
97
98 /* current sector map */
99 extern char Sect[NSECTS][NSECTS];
100
101
102
103 /************************ DEVICES ******************************/
104
105 # define NDEV 16 /* max number of devices */
106
107 /* device tokens */
108 # define WARP 0 /* warp engines */
109 # define SRSCAN 1 /* short range scanners */
110 # define LRSCAN 2 /* long range scanners */
111 # define PHASER 3 /* phaser control */
112 # define TORPED 4 /* photon torpedo control */
113 # define IMPULSE 5 /* impulse engines */
114 # define SHIELD 6 /* shield control */
115 # define COMPUTER 7 /* on board computer */
116 # define SSRADIO 8 /* subspace radio */
117 # define LIFESUP 9 /* life support systems */
118 # define SINS 10 /* Space Inertial Navigation System */
119 # define CLOAK 11 /* cloaking device */
120 # define XPORTER 12 /* transporter */
121 # define SHUTTLE 13 /* shuttlecraft */
122
123 /* device names */
124 struct device
125 {
126 const char *name; /* device name */
127 const char *person; /* the person who fixes it */
128 };
129
130 extern const struct device Device[NDEV];
131
132 /*************************** EVENTS ****************************/
133
134 # define NEVENTS 12 /* number of different event types */
135
136 # define E_LRTB 1 /* long range tractor beam */
137 # define E_KATSB 2 /* Klingon attacks starbase */
138 # define E_KDESB 3 /* Klingon destroys starbase */
139 # define E_ISSUE 4 /* distress call is issued */
140 # define E_ENSLV 5 /* Klingons enslave a quadrant */
141 # define E_REPRO 6 /* a Klingon is reproduced */
142 # define E_FIXDV 7 /* fix a device */
143 # define E_ATTACK 8 /* Klingon attack during rest period */
144 # define E_SNAP 9 /* take a snapshot for time warp */
145 # define E_SNOVA 10 /* supernova occurs */
146
147 # define E_GHOST 0100 /* ghost of a distress call if ssradio out */
148 # define E_HIDDEN 0200 /* event that is unreportable because ssradio out */
149 # define E_EVENT 077 /* mask to get event code */
150
151 struct event
152 {
153 unsigned char x, y; /* coordinates */
154 double date; /* trap stardate */
155 char evcode; /* event type */
156 unsigned char systemname; /* starsystem name */
157 };
158 /* systemname conventions:
159 * 1 -> NINHAB index into Systemname table for reported distress calls
160 *
161 * evcode conventions:
162 * 1 -> NEVENTS-1 event type
163 * + E_HIDDEN unreported (SSradio out)
164 * + E_GHOST actually already expired
165 * 0 unallocated
166 */
167
168 # define MAXEVENTS 25 /* max number of concurrently pending events */
169
170 extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */
171
172 /***************************** KLINGONS *******************************/
173
174 struct kling
175 {
176 unsigned char x, y; /* coordinates */
177 int power; /* power left */
178 double dist; /* distance to Enterprise */
179 double avgdist; /* average over this move */
180 char srndreq; /* set if surrender has been requested */
181 };
182
183 # define MAXKLQUAD 9 /* maximum klingons per quadrant */
184
185 /********************** MISCELLANEOUS ***************************/
186
187 /* condition codes */
188 # define GREEN 0
189 # define DOCKED 1
190 # define YELLOW 2
191 # define RED 3
192
193 /* starbase coordinates */
194 # define MAXBASES 9 /* maximum number of starbases in galaxy */
195
196 /* distress calls */
197 # define MAXDISTR 5 /* maximum concurrent distress calls */
198
199 /* phaser banks */
200 # define NBANKS 6 /* number of phaser banks */
201
202 struct xy
203 {
204 unsigned char x, y; /* coordinates */
205 };
206
207
208 /*
209 * note that much of the stuff in the following structs CAN NOT
210 * be moved around!!!!
211 */
212
213
214 /* information regarding the state of the starship */
215 struct Ship_struct
216 {
217 double warp; /* warp factor */
218 double warp2; /* warp factor squared */
219 double warp3; /* warp factor cubed */
220 char shldup; /* shield up flag */
221 char cloaked; /* set if cloaking device on */
222 int energy; /* starship's energy */
223 int shield; /* energy in shields */
224 double reserves; /* life support reserves */
225 int crew; /* ship's complement */
226 int brigfree; /* space left in brig */
227 char torped; /* torpedoes */
228 char cloakgood; /* set if we have moved */
229 int quadx; /* quadrant x coord */
230 int quady; /* quadrant y coord */
231 int sectx; /* sector x coord */
232 int secty; /* sector y coord */
233 unsigned char cond; /* condition code */
234 char sinsbad; /* Space Inertial Navigation System condition */
235 const char *shipname; /* name of current starship */
236 char ship; /* current starship */
237 int distressed; /* number of distress calls */
238 };
239 extern struct Ship_struct Ship;
240
241 /* sinsbad is set if SINS is working but not calibrated */
242
243 /* game related information, mostly scoring */
244 struct Game_struct
245 {
246 int killk; /* number of klingons killed */
247 int deaths; /* number of deaths onboard Enterprise */
248 char negenbar; /* number of hits on negative energy barrier */
249 char killb; /* number of starbases killed */
250 int kills; /* number of stars killed */
251 char skill; /* skill rating of player */
252 char length; /* length of game */
253 char killed; /* set if you were killed */
254 char killinhab; /* number of inhabited starsystems killed */
255 char tourn; /* set if a tournament game */
256 char passwd[15]; /* game password */
257 char snap; /* set if snapshot taken */
258 char helps; /* number of help calls */
259 int captives; /* total number of captives taken */
260 };
261 extern struct Game_struct Game;
262
263 /* per move information */
264 struct Move_struct
265 {
266 char free; /* set if a move is free */
267 char endgame; /* end of game flag */
268 char shldchg; /* set if shields changed this move */
269 char newquad; /* set if just entered this quadrant */
270 char resting; /* set if this move is a rest */
271 double time; /* time used this move */
272 };
273 extern struct Move_struct Move;
274
275 /* parametric information */
276 struct Param_struct
277 {
278 unsigned char bases; /* number of starbases */
279 char klings; /* number of klingons */
280 double date; /* stardate */
281 double time; /* time left */
282 double resource; /* Federation resources */
283 int energy; /* starship's energy */
284 int shield; /* energy in shields */
285 double reserves; /* life support reserves */
286 int crew; /* size of ship's complement */
287 int brigfree; /* max possible number of captives */
288 char torped; /* photon torpedos */
289 double damfac[NDEV]; /* damage factor */
290 double dockfac; /* docked repair time factor */
291 double regenfac; /* regeneration factor */
292 int stopengy; /* energy to do emergency stop */
293 int shupengy; /* energy to put up shields */
294 int klingpwr; /* Klingon initial power */
295 int warptime; /* time chewer multiplier */
296 double phasfac; /* Klingon phaser power eater factor */
297 char moveprob[6]; /* probability that a Klingon moves */
298 double movefac[6]; /* Klingon move distance multiplier */
299 double eventdly[NEVENTS]; /* event time multipliers */
300 double navigcrud[2]; /* navigation crudup factor */
301 int cloakenergy; /* cloaking device energy per stardate */
302 double damprob[NDEV]; /* damage probability */
303 double hitfac; /* Klingon attack factor */
304 int klingcrew; /* number of Klingons in a crew */
305 double srndrprob; /* surrender probability */
306 int energylow; /* low energy mark (cond YELLOW) */
307 };
308 extern struct Param_struct Param;
309
310 /* Sum of damage probabilities must add to 1000 */
311
312 /* other information kept in a snapshot */
313 struct Now_struct
314 {
315 unsigned char bases; /* number of starbases */
316 char klings; /* number of klingons */
317 double date; /* stardate */
318 double time; /* time left */
319 double resource; /* Federation resources */
320 char distressed; /* number of currently distressed quadrants */
321 struct event *eventptr[NEVENTS]; /* pointer to event structs */
322 struct xy base[MAXBASES]; /* locations of starbases */
323 };
324 extern struct Now_struct Now;
325
326 /* Other stuff, not dumped in a snapshot */
327 struct Etc_struct
328 {
329 struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */
330 short nkling; /* number of Klingons in this sector */
331 /* < 0 means automatic override mode */
332 char fast; /* set if speed > 300 baud */
333 struct xy starbase; /* starbase in current quadrant */
334 char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */
335 char statreport; /* set to get a status report on a srscan */
336 };
337 extern struct Etc_struct Etc;
338
339 /*
340 * eventptr is a pointer to the event[] entry of the last
341 * scheduled event of each type. Zero if no such event scheduled.
342 */
343
344 /* Klingon move indicies */
345 # define KM_OB 0 /* Old quadrant, Before attack */
346 # define KM_OA 1 /* Old quadrant, After attack */
347 # define KM_EB 2 /* Enter quadrant, Before attack */
348 # define KM_EA 3 /* Enter quadrant, After attack */
349 # define KM_LB 4 /* Leave quadrant, Before attack */
350 # define KM_LA 5 /* Leave quadrant, After attack */
351
352 /* you lose codes */
353 # define L_NOTIME 1 /* ran out of time */
354 # define L_NOENGY 2 /* ran out of energy */
355 # define L_DSTRYD 3 /* destroyed by a Klingon */
356 # define L_NEGENB 4 /* ran into the negative energy barrier */
357 # define L_SUICID 5 /* destroyed in a nova */
358 # define L_SNOVA 6 /* destroyed in a supernova */
359 # define L_NOLIFE 7 /* life support died (so did you) */
360 # define L_NOHELP 8 /* you could not be rematerialized */
361 # define L_TOOFAST 9 /* pretty stupid going at warp 10 */
362 # define L_STAR 10 /* ran into a star */
363 # define L_DSTRCT 11 /* self destructed */
364 # define L_CAPTURED 12 /* captured by Klingons */
365 # define L_NOCREW 13 /* you ran out of crew */
366
367 /****************** COMPILE OPTIONS ***********************/
368
369 /* Trace info */
370 # define xTRACE 1
371 extern int Trace;
372
373 /* abandon.c */
374 void abandon(int);
375
376 /* attack.c */
377 void attack(int);
378
379 /* autover.c */
380 void autover(void);
381
382 /* capture.c */
383 void capture(int);
384 struct kling *selectklingon(void);
385
386 /* cgetc.c */
387 char cgetc(int);
388
389 /* check_out.c */
390 int check_out(int);
391
392 /* checkcond.c */
393 void checkcond(void);
394
395 /* compkl.c */
396 void compkldist(int);
397
398 /* computer.c */
399 void computer(int);
400
401 /* damage.c */
402 void damage(int, double);
403
404 /* damaged.c */
405 int damaged(int);
406
407 /* dcrept.c */
408 void dcrept(int);
409
410 /* destruct.c */
411 void destruct(int);
412
413 /* dock.c */
414 void dock(int);
415 void undock(int);
416
417 /* dumpgame.c */
418 void dumpgame(int);
419 int restartgame(void);
420
421 /* dumpme.c */
422 void dumpme(int);
423
424 /* dumpssradio.c */
425 int dumpssradio(void);
426
427 /* events.c */
428 int events(int);
429
430 /* externs.c */
431
432 /* getcodi.c */
433 int getcodi(int *, double *);
434
435 /* help.c */
436 void help(int);
437
438 /* impulse.c */
439 void impulse(int);
440
441 /* initquad.c */
442 void initquad(int);
443 void sector(int *, int *);
444
445 /* kill.c */
446 void killk(int, int );
447 void killb(int, int );
448 void kills(int, int , int);
449 void killd(int, int , int);
450
451 /* klmove.c */
452 void klmove(int);
453
454 /* lose.c */
455 void lose(int) __attribute__((__noreturn__));
456
457 /* lrscan.c */
458 void lrscan(int);
459
460 /* move.c */
461 double move(int, int, double, double);
462
463 /* nova.c */
464 void nova(int, int );
465
466 /* out.c */
467 void out(int);
468
469 /* phaser.c */
470 void phaser(int);
471
472 /* play.c */
473 void myreset(int) __attribute__((__noreturn__));
474 void play(void) __attribute__((__noreturn__));
475
476 /* ram.c */
477 void ram(int, int );
478
479 /* ranf.c */
480 int ranf(int);
481 double franf(void);
482
483 /* rest.c */
484 void rest(int);
485
486 /* schedule.c */
487 struct event *schedule(int, double, int, int , int);
488 void reschedule(struct event *, double);
489 void unschedule(struct event *);
490 struct event *xsched(int, int, int, int , int );
491 void xresched(struct event *, int, int);
492
493 /* score.c */
494 long score(void);
495
496 /* setup.c */
497 void setup(void);
498
499 /* setwarp.c */
500 void setwarp(int);
501
502 /* shield.c */
503 void shield(int);
504
505 /* snova.c */
506 void snova(int, int );
507
508 /* srscan.c */
509 void srscan(int);
510
511 /* systemname.c */
512 const char *systemname(const struct quad *);
513
514 /* torped.c */
515 void torped(int);
516
517 /* visual.c */
518 void visual(int);
519
520 /* warp.c */
521 void dowarp(int);
522 void warp(int, int, double);
523
524 /* win.c */
525 void win(void) __attribute__((__noreturn__));