X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/462fca95471224f85b85be911e72faee16cd1597..4506ee6421a65ebf465cb3e1124f0ba604dbcb20:/trek/trek.h diff --git a/trek/trek.h b/trek/trek.h index 98b71532..eaede63b 100644 --- a/trek/trek.h +++ b/trek/trek.h @@ -1,6 +1,8 @@ +/* $NetBSD: trek.h,v 1.8 1999/09/17 17:06:08 jsm Exp $ */ + /* - * Copyright (c) 1980 Regents of the University of California. - * All rights reserved. + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -30,8 +32,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * from: @(#)trek.h 5.5 (Berkeley) 6/1/90 - * $Id: trek.h,v 1.2 1993/08/01 18:50:55 mycroft Exp $ + * @(#)trek.h 8.1 (Berkeley) 5/31/93 */ /* @@ -44,23 +45,9 @@ ** ** 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 */ -extern double franf(); /* floating random number function */ -extern double sqrt(); /* square root */ -extern double sin(), cos(); /* trig functions */ -extern double atan2(); /* fancy arc tangent function */ -extern double log(); /* log base e */ -extern double pow(); /* power function */ -extern double fabs(); /* absolute value function */ -extern double exp(); /* exponential function */ /********************* GALAXY **************************/ @@ -71,11 +58,11 @@ extern double exp(); /* exponential function */ struct quad /* definition for each quadrant */ { - char bases; /* number of bases in this quadrant */ + 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 */ int scanned; /* star chart entry (see below) */ - char stars; /* number of stars in this quadrant */ + short stars; /* number of stars in this quadrant */ char qsystemname; /* starsystem name (see below) */ }; @@ -97,10 +84,10 @@ struct quad /* definition for each quadrant */ */ /* ascii names of systems */ -extern char *Systemname[NINHAB]; +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 '.' @@ -113,7 +100,8 @@ struct quad Quad[NQUADS][NQUADS]; # define HOLE ' ' /* current sector map */ -char Sect[NSECTS][NSECTS]; +extern char Sect[NSECTS][NSECTS]; + /************************ DEVICES ******************************/ @@ -139,11 +127,11 @@ char Sect[NSECTS][NSECTS]; /* device names */ struct device { - char *name; /* device name */ - char *person; /* the person who fixes it */ + const char *name; /* device name */ + const char *person; /* the person who fixes it */ }; -struct device Device[NDEV]; +extern const struct device Device[NDEV]; /*************************** EVENTS ****************************/ @@ -166,10 +154,10 @@ struct device Device[NDEV]; struct event { - char x, y; /* coordinates */ - double date; /* trap stardate */ - char evcode; /* event type */ - char systemname; /* starsystem name */ + unsigned char x, y; /* coordinates */ + double date; /* trap stardate */ + char evcode; /* event type */ + unsigned char systemname; /* starsystem name */ }; /* systemname conventions: * 1 -> NINHAB index into Systemname table for reported distress calls @@ -183,13 +171,13 @@ struct event # define MAXEVENTS 25 /* max number of concurrently pending events */ -struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ +extern struct event Event[MAXEVENTS]; /* dynamic event list; one entry per pending event */ /***************************** KLINGONS *******************************/ struct kling { - char x, y; /* coordinates */ + unsigned char x, y; /* coordinates */ int power; /* power left */ double dist; /* distance to Enterprise */ double avgdist; /* average over this move */ @@ -217,10 +205,13 @@ struct kling struct xy { - char x, y; /* coordinates */ + 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!!!! @@ -228,7 +219,7 @@ struct xy /* information regarding the state of the starship */ -struct +struct Ship_struct { double warp; /* warp factor */ double warp2; /* warp factor squared */ @@ -246,17 +237,18 @@ struct int quady; /* quadrant y coord */ int sectx; /* sector x coord */ int secty; /* sector y coord */ - char cond; /* condition code */ + unsigned char cond; /* condition code */ char sinsbad; /* Space Inertial Navigation System condition */ - char *shipname; /* name of current starship */ + 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 */ @@ -272,10 +264,11 @@ 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 */ @@ -283,12 +276,13 @@ struct 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 { - char bases; /* number of starbases */ + unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ double time; /* time left */ @@ -317,14 +311,15 @@ 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 { - char bases; /* number of starbases */ + unsigned char bases; /* number of starbases */ char klings; /* number of klingons */ double date; /* stardate */ double time; /* time left */ @@ -332,19 +327,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 Etc_struct { struct kling klingon[MAXKLQUAD]; /* sorted Klingon list */ - char nkling; /* number of Klingons in this sector */ + 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; +}; +extern struct Etc_struct Etc; /* * eventptr is a pointer to the event[] entry of the last @@ -378,4 +375,158 @@ struct /* Trace info */ # define xTRACE 1 -int Trace; +extern int Trace; + +/* abandon.c */ +void abandon __P((int)); + +/* attack.c */ +void attack __P((int)); + +/* autover.c */ +void autover __P((void)); + +/* capture.c */ +void capture __P((int)); +struct kling *selectklingon __P((void)); + +/* cgetc.c */ +char cgetc __P((int)); + +/* check_out.c */ +int check_out __P((int)); + +/* checkcond.c */ +void checkcond __P((void)); + +/* compkl.c */ +void compkldist __P((int)); + +/* computer.c */ +void computer __P((int)); + +/* damage.c */ +void damage __P((int, double)); + +/* damaged.c */ +int damaged __P((int)); + +/* dcrept.c */ +void dcrept __P((int)); + +/* destruct.c */ +void destruct __P((int)); + +/* dock.c */ +void dock __P((int)); +void undock __P((int)); + +/* dumpgame.c */ +void dumpgame __P((int)); +int restartgame __P((void)); + +/* dumpme.c */ +void dumpme __P((int)); + +/* dumpssradio.c */ +int dumpssradio __P((void)); + +/* events.c */ +int events __P((int)); + +/* externs.c */ + +/* getcodi.c */ +int getcodi __P((int *, double *)); + +/* help.c */ +void help __P((int)); + +/* impulse.c */ +void impulse __P((int)); + +/* initquad.c */ +void initquad __P((int)); +void sector __P((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)); + +/* klmove.c */ +void klmove __P((int)); + +/* lose.c */ +void lose __P((int)) __attribute__((__noreturn__)); + +/* lrscan.c */ +void lrscan __P((int)); + +/* move.c */ +double move __P((int, int, double, double)); + +/* nova.c */ +void nova __P((int, int )); + +/* out.c */ +void out __P((int)); + +/* phaser.c */ +void phaser __P((int)); + +/* play.c */ +void myreset __P((int)) __attribute__((__noreturn__)); +void play __P((void)) __attribute__((__noreturn__)); + +/* ram.c */ +void ram __P((int, int )); + +/* ranf.c */ +int ranf __P((int)); +double franf __P((void)); + +/* rest.c */ +void rest __P((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)); + +/* score.c */ +long score __P((void)); + +/* setup.c */ +void setup __P((void)); + +/* setwarp.c */ +void setwarp __P((int)); + +/* shield.c */ +void shield __P((int)); + +/* snova.c */ +void snova __P((int, int )); + +/* srscan.c */ +void srscan __P((int)); + +/* systemname.c */ +const char *systemname __P((const struct quad *)); + +/* torped.c */ +void torped __P((int)); + +/* visual.c */ +void visual __P((int)); + +/* warp.c */ +void dowarp __P((int)); +void warp __P((int, int, double)); + +/* win.c */ +void win __P((void)) __attribute__((__noreturn__));