X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/82852318e37fa7eddacc3dd162a2d16d3a7487b9..47fc54cf8d89647aa672981142e32ce0a4c12519:/trek/trek.h?ds=sidebyside diff --git a/trek/trek.h b/trek/trek.h index db330782..99c61e48 100644 --- a/trek/trek.h +++ b/trek/trek.h @@ -1,4 +1,4 @@ -/* $NetBSD: trek.h,v 1.7 1999/09/08 21:45:33 jsm Exp $ */ +/* $NetBSD: trek.h,v 1.18 2009/08/12 08:54:54 dholland Exp $ */ /* * Copyright (c) 1980, 1993 @@ -12,11 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -45,12 +41,6 @@ ** ** So far as I know, nothing in here must be preinitialized to ** zero. -** -** You may have problems from the loader if you move this to a -** different machine. These things actually get allocated in each -** source file, which UNIX allows; however, you may (on other -** systems) have to change everything in here to be "extern" and -** actually allocate stuff in "externs.c" */ /* external function definitions */ @@ -58,12 +48,12 @@ /********************* GALAXY **************************/ /* galactic parameters */ -# define NSECTS 10 /* dimensions of quadrant in sectors */ -# define NQUADS 8 /* dimension of galazy in quadrants */ -# define NINHAB 32 /* number of quadrants which are inhabited */ +#define NSECTS 10 /* dimensions of quadrant in sectors */ +#define NQUADS 8 /* dimension of galazy in quadrants */ +#define NINHAB 32 /* number of quadrants which are inhabited */ -struct quad /* definition for each quadrant */ -{ +/* definition for each quadrant */ +struct quad { unsigned char bases; /* number of bases in this quadrant */ char klings; /* number of Klingons in this quadrant */ char holes; /* number of black holes in this quadrant */ @@ -72,10 +62,11 @@ struct quad /* definition for each quadrant */ char qsystemname; /* starsystem name (see below) */ }; -# define Q_DISTRESSED 0200 -# define Q_SYSTEM 077 +#define Q_DISTRESSED 0200 +#define Q_SYSTEM 077 -/* systemname conventions: +/* + * systemname conventions: * 1 -> NINHAB index into Systemname table for live system. * + Q_DISTRESSED distressed starsystem -- systemname & Q_SYSTEM * is the index into the Event table which will @@ -87,85 +78,85 @@ struct quad /* definition for each quadrant */ * -1 not yet scanned ("...") * 1000 supernova ("///") * 1001 starbase + ??? (".1.") -*/ + */ /* ascii names of systems */ extern const char *const Systemname[NINHAB]; /* quadrant definition */ -struct quad Quad[NQUADS][NQUADS]; +extern struct quad Quad[NQUADS][NQUADS]; /* defines for sector map (below) */ -# define EMPTY '.' -# define STAR '*' -# define BASE '#' -# define ENTERPRISE 'E' -# define QUEENE 'Q' -# define KLINGON 'K' -# define INHABIT '@' -# define HOLE ' ' +#define EMPTY '.' +#define STAR '*' +#define BASE '#' +#define ENTERPRISE 'E' +#define QUEENE 'Q' +#define KLINGON 'K' +#define INHABIT '@' +#define HOLE ' ' /* current sector map */ -char Sect[NSECTS][NSECTS]; +extern char Sect[NSECTS][NSECTS]; /************************ DEVICES ******************************/ -# define NDEV 16 /* max number of devices */ +#define NDEV 16 /* max number of devices */ /* device tokens */ -# define WARP 0 /* warp engines */ -# define SRSCAN 1 /* short range scanners */ -# define LRSCAN 2 /* long range scanners */ -# define PHASER 3 /* phaser control */ -# define TORPED 4 /* photon torpedo control */ -# define IMPULSE 5 /* impulse engines */ -# define SHIELD 6 /* shield control */ -# define COMPUTER 7 /* on board computer */ -# define SSRADIO 8 /* subspace radio */ -# define LIFESUP 9 /* life support systems */ -# define SINS 10 /* Space Inertial Navigation System */ -# define CLOAK 11 /* cloaking device */ -# define XPORTER 12 /* transporter */ -# define SHUTTLE 13 /* shuttlecraft */ +#define WARP 0 /* warp engines */ +#define SRSCAN 1 /* short range scanners */ +#define LRSCAN 2 /* long range scanners */ +#define PHASER 3 /* phaser control */ +#define TORPED 4 /* photon torpedo control */ +#define IMPULSE 5 /* impulse engines */ +#define SHIELD 6 /* shield control */ +#define COMPUTER 7 /* on board computer */ +#define SSRADIO 8 /* subspace radio */ +#define LIFESUP 9 /* life support systems */ +#define SINS 10 /* Space Inertial Navigation System */ +#define CLOAK 11 /* cloaking device */ +#define XPORTER 12 /* transporter */ +#define SHUTTLE 13 /* shuttlecraft */ /* device names */ -struct device -{ +struct device { const char *name; /* device name */ const char *person; /* the person who fixes it */ }; -const struct device Device[NDEV]; +extern const struct device Device[NDEV]; /*************************** EVENTS ****************************/ -# define NEVENTS 12 /* number of different event types */ - -# define E_LRTB 1 /* long range tractor beam */ -# define E_KATSB 2 /* Klingon attacks starbase */ -# define E_KDESB 3 /* Klingon destroys starbase */ -# define E_ISSUE 4 /* distress call is issued */ -# define E_ENSLV 5 /* Klingons enslave a quadrant */ -# define E_REPRO 6 /* a Klingon is reproduced */ -# define E_FIXDV 7 /* fix a device */ -# define E_ATTACK 8 /* Klingon attack during rest period */ -# define E_SNAP 9 /* take a snapshot for time warp */ -# define E_SNOVA 10 /* supernova occurs */ - -# define E_GHOST 0100 /* ghost of a distress call if ssradio out */ -# define E_HIDDEN 0200 /* event that is unreportable because ssradio out */ -# define E_EVENT 077 /* mask to get event code */ - -struct event -{ +#define NEVENTS 12 /* number of different event types */ + +#define E_LRTB 1 /* long range tractor beam */ +#define E_KATSB 2 /* Klingon attacks starbase */ +#define E_KDESB 3 /* Klingon destroys starbase */ +#define E_ISSUE 4 /* distress call is issued */ +#define E_ENSLV 5 /* Klingons enslave a quadrant */ +#define E_REPRO 6 /* a Klingon is reproduced */ +#define E_FIXDV 7 /* fix a device */ +#define E_ATTACK 8 /* Klingon attack during rest period */ +#define E_SNAP 9 /* take a snapshot for time warp */ +#define E_SNOVA 10 /* supernova occurs */ + +#define E_GHOST 0100 /* ghost of a distress call if ssradio out */ +#define E_HIDDEN 0200 /* event unreportable because ssradio out */ +#define E_EVENT 077 /* mask to get event code */ + +struct event { unsigned char x, y; /* coordinates */ double date; /* trap stardate */ char evcode; /* event type */ unsigned char systemname; /* starsystem name */ }; -/* systemname conventions: + +/* + * systemname conventions: * 1 -> NINHAB index into Systemname table for reported distress calls * * evcode conventions: @@ -175,14 +166,15 @@ struct event * 0 unallocated */ -# define MAXEVENTS 25 /* max number of concurrently pending events */ +/* max number of concurrently pending events */ +#define MAXEVENTS 25 -struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ +/* dynamic event list; one entry per pending event */ +extern struct event Event[MAXEVENTS]; /***************************** KLINGONS *******************************/ -struct kling -{ +struct kling { unsigned char x, y; /* coordinates */ int power; /* power left */ double dist; /* distance to Enterprise */ @@ -190,34 +182,30 @@ struct kling char srndreq; /* set if surrender has been requested */ }; -# define MAXKLQUAD 9 /* maximum klingons per quadrant */ +#define MAXKLQUAD 9 /* maximum klingons per quadrant */ /********************** MISCELLANEOUS ***************************/ /* condition codes */ -# define GREEN 0 -# define DOCKED 1 -# define YELLOW 2 -# define RED 3 +#define GREEN 0 +#define DOCKED 1 +#define YELLOW 2 +#define RED 3 /* starbase coordinates */ -# define MAXBASES 9 /* maximum number of starbases in galaxy */ +#define MAXBASES 9 /* maximum number of starbases in galaxy */ /* distress calls */ -# define MAXDISTR 5 /* maximum concurrent distress calls */ +#define MAXDISTR 5 /* maximum concurrent distress calls */ /* phaser banks */ -# define NBANKS 6 /* number of phaser banks */ +#define NBANKS 6 /* number of phaser banks */ -struct xy -{ +struct xy { unsigned char x, y; /* coordinates */ }; -extern const struct cvntab Skitab[]; -extern const struct cvntab Lentab[]; - /* * note that much of the stuff in the following structs CAN NOT * be moved around!!!! @@ -225,8 +213,7 @@ extern const struct cvntab Lentab[]; /* information regarding the state of the starship */ -struct -{ +struct Ship_struct { double warp; /* warp factor */ double warp2; /* warp factor squared */ double warp3; /* warp factor cubed */ @@ -244,17 +231,17 @@ struct int sectx; /* sector x coord */ int secty; /* sector y coord */ unsigned char cond; /* condition code */ - char sinsbad; /* Space Inertial Navigation System condition */ + /* sinsbad is set if SINS is working but not calibrated */ + char sinsbad; /* Space Inertial Navigation System condition*/ const char *shipname; /* name of current starship */ char ship; /* current starship */ int distressed; /* number of distress calls */ -} Ship; +}; +extern struct Ship_struct Ship; -/* sinsbad is set if SINS is working but not calibrated */ /* game related information, mostly scoring */ -struct -{ +struct Game_struct { int killk; /* number of klingons killed */ int deaths; /* number of deaths onboard Enterprise */ char negenbar; /* number of hits on negative energy barrier */ @@ -269,22 +256,22 @@ struct char snap; /* set if snapshot taken */ char helps; /* number of help calls */ int captives; /* total number of captives taken */ -} Game; +}; +extern struct Game_struct Game; /* per move information */ -struct -{ +struct Move_struct { char free; /* set if a move is free */ char endgame; /* end of game flag */ char shldchg; /* set if shields changed this move */ char newquad; /* set if just entered this quadrant */ char resting; /* set if this move is a rest */ double time; /* time used this move */ -} Move; +}; +extern struct Move_struct Move; /* parametric information */ -struct -{ +struct Param_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ @@ -314,13 +301,13 @@ struct int klingcrew; /* number of Klingons in a crew */ double srndrprob; /* surrender probability */ int energylow; /* low energy mark (cond YELLOW) */ -} Param; +}; +extern struct Param_struct Param; /* Sum of damage probabilities must add to 1000 */ /* other information kept in a snapshot */ -struct -{ +struct Now_struct { unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ @@ -329,19 +316,21 @@ struct char distressed; /* number of currently distressed quadrants */ struct event *eventptr[NEVENTS]; /* pointer to event structs */ struct xy base[MAXBASES]; /* locations of starbases */ -} Now; +}; +extern struct Now_struct Now; /* Other stuff, not dumped in a snapshot */ -struct -{ - struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ - short nkling; /* number of Klingons in this sector */ - /* < 0 means automatic override mode */ - char fast; /* set if speed > 300 baud */ - struct xy starbase; /* starbase in current quadrant */ - char snapshot[sizeof Quad + sizeof Event + sizeof Now]; /* snapshot for time warp */ - char statreport; /* set to get a status report on a srscan */ -} Etc; +struct Etc_struct { + struct kling klingon[MAXKLQUAD];/* sorted Klingon list */ + short nkling; /* number of Klingons in this sector */ + /* < 0 means automatic override mode */ + char fast; /* set if speed > 300 baud */ + struct xy starbase; /* starbase in current quadrant */ + char snapshot[sizeof Quad + sizeof Event + sizeof Now]; + /* snapshot for time warp */ + char statreport; /* set to get a status report on a srscan */ +}; +extern struct Etc_struct Etc; /* * eventptr is a pointer to the event[] entry of the last @@ -349,184 +338,181 @@ struct */ /* Klingon move indicies */ -# define KM_OB 0 /* Old quadrant, Before attack */ -# define KM_OA 1 /* Old quadrant, After attack */ -# define KM_EB 2 /* Enter quadrant, Before attack */ -# define KM_EA 3 /* Enter quadrant, After attack */ -# define KM_LB 4 /* Leave quadrant, Before attack */ -# define KM_LA 5 /* Leave quadrant, After attack */ +#define KM_OB 0 /* Old quadrant, Before attack */ +#define KM_OA 1 /* Old quadrant, After attack */ +#define KM_EB 2 /* Enter quadrant, Before attack */ +#define KM_EA 3 /* Enter quadrant, After attack */ +#define KM_LB 4 /* Leave quadrant, Before attack */ +#define KM_LA 5 /* Leave quadrant, After attack */ /* you lose codes */ -# define L_NOTIME 1 /* ran out of time */ -# define L_NOENGY 2 /* ran out of energy */ -# define L_DSTRYD 3 /* destroyed by a Klingon */ -# define L_NEGENB 4 /* ran into the negative energy barrier */ -# define L_SUICID 5 /* destroyed in a nova */ -# define L_SNOVA 6 /* destroyed in a supernova */ -# define L_NOLIFE 7 /* life support died (so did you) */ -# define L_NOHELP 8 /* you could not be rematerialized */ -# define L_TOOFAST 9 /* pretty stupid going at warp 10 */ -# define L_STAR 10 /* ran into a star */ -# define L_DSTRCT 11 /* self destructed */ -# define L_CAPTURED 12 /* captured by Klingons */ -# define L_NOCREW 13 /* you ran out of crew */ +#define L_NOTIME 1 /* ran out of time */ +#define L_NOENGY 2 /* ran out of energy */ +#define L_DSTRYD 3 /* destroyed by a Klingon */ +#define L_NEGENB 4 /* ran into the negative energy barrier */ +#define L_SUICID 5 /* destroyed in a nova */ +#define L_SNOVA 6 /* destroyed in a supernova */ +#define L_NOLIFE 7 /* life support died (so did you) */ +#define L_NOHELP 8 /* you could not be rematerialized */ +#define L_TOOFAST 9 /* pretty stupid going at warp 10 */ +#define L_STAR 10 /* ran into a star */ +#define L_DSTRCT 11 /* self destructed */ +#define L_CAPTURED 12 /* captured by Klingons */ +#define L_NOCREW 13 /* you ran out of crew */ /****************** COMPILE OPTIONS ***********************/ /* Trace info */ -# define xTRACE 1 -int Trace; +#define xTRACE 1 +extern int Trace; + +#define TOOLARGE (DBL_MAX / 2) /* < DOUBLE_MAX for everyone */ /* abandon.c */ -void abandon __P((int)); +void abandon(int); /* attack.c */ -void attack __P((int)); +void attack(int); /* autover.c */ -void autover __P((void)); +void autover(void); /* capture.c */ -void capture __P((int)); -struct kling *selectklingon __P((void)); - -/* cgetc.c */ -char cgetc __P((int)); +void capture(int); /* check_out.c */ -int check_out __P((int)); +int check_out(int); /* checkcond.c */ -void checkcond __P((void)); +void checkcond(void); /* compkl.c */ -void compkldist __P((int)); +void compkldist(int); /* computer.c */ -void computer __P((int)); +void computer(int); /* damage.c */ -void damage __P((int, double)); +void damage(int, double); /* damaged.c */ -int damaged __P((int)); +int damaged(int); /* dcrept.c */ -void dcrept __P((int)); +void dcrept(int); /* destruct.c */ -void destruct __P((int)); +void destruct(int); /* dock.c */ -void dock __P((int)); -void undock __P((int)); +void dock(int); +void undock(int); /* dumpgame.c */ -void dumpgame __P((int)); -int restartgame __P((void)); +void dumpgame(int); +int restartgame(void); /* dumpme.c */ -void dumpme __P((int)); +void dumpme(int); /* dumpssradio.c */ -int dumpssradio __P((void)); +int dumpssradio(void); /* events.c */ -int events __P((int)); +int events(int); /* externs.c */ /* getcodi.c */ -int getcodi __P((int *, double *)); +int getcodi(int *, double *); /* help.c */ -void help __P((int)); +void help(int); /* impulse.c */ -void impulse __P((int)); +void impulse(int); /* initquad.c */ -void initquad __P((int)); -void sector __P((int *, int *)); +void initquad(int); +void sector(int *, int *); /* kill.c */ -void killk __P((int, int )); -void killb __P((int, int )); -void kills __P((int, int , int)); -void killd __P((int, int , int)); +void killk(int, int ); +void killb(int, int ); +void kills(int, int , int); +void killd(int, int , int); /* klmove.c */ -void klmove __P((int)); +void klmove(int); /* lose.c */ -void lose __P((int)) __attribute__((__noreturn__)); +void lose(int) __dead; /* lrscan.c */ -void lrscan __P((int)); +void lrscan(int); /* move.c */ -double move __P((int, int, double, double)); +double move(int, int, double, double); /* nova.c */ -void nova __P((int, int )); +void nova(int, int ); /* out.c */ -void out __P((int)); +void out(int); /* phaser.c */ -void phaser __P((int)); +void phaser(int); /* play.c */ -void myreset __P((int)) __attribute__((__noreturn__)); -void play __P((void)) __attribute__((__noreturn__)); +void play(void) __dead; /* ram.c */ -void ram __P((int, int )); +void ram(int, int ); /* ranf.c */ -int ranf __P((int)); -double franf __P((void)); +int ranf(int); +double franf(void); /* rest.c */ -void rest __P((int)); +void rest(int); /* schedule.c */ -struct event *schedule __P((int, double, int, int , int)); -void reschedule __P((struct event *, double)); -void unschedule __P((struct event *)); -struct event *xsched __P((int, int, int, int , int )); -void xresched __P((struct event *, int, int)); +struct event *schedule(int, double, int, int , int); +void reschedule(struct event *, double); +void unschedule(struct event *); +struct event *xsched(int, int, int, int , int ); +void xresched(struct event *, int, int); /* score.c */ -long score __P((void)); +long score(void); /* setup.c */ -void setup __P((void)); +void setup(void); /* setwarp.c */ -void setwarp __P((int)); +void setwarp(int); /* shield.c */ -void shield __P((int)); +void shield(int); /* snova.c */ -void snova __P((int, int )); +void snova(int, int ); /* srscan.c */ -void srscan __P((int)); +void srscan(int); /* systemname.c */ -const char *systemname __P((const struct quad *)); +const char *systemname(const struct quad *); /* torped.c */ -void torped __P((int)); +void torped(int); /* visual.c */ -void visual __P((int)); +void visual(int); /* warp.c */ -void dowarp __P((int)); -void warp __P((int, int, double)); +void dowarp(int); +void warp(int, int, double); /* win.c */ -void win __P((void)) __attribute__((__noreturn__)); +void win(void) __dead;