X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=sst.h;h=fc7ecc5355ffeb93a1c1ccda178919b261d3f404;hb=25f221b092e0e9d85aa5d3e6863043f2ab4d7c43;hp=c93fbc5deccba64d4934c4c3259879e204a8ca3a;hpb=48763357ef69f0b711fc332b13e2170ab914d881;p=super-star-trek.git diff --git a/sst.h b/sst.h index c93fbc5..fc7ecc5 100644 --- a/sst.h +++ b/sst.h @@ -8,21 +8,26 @@ #define EXTERN #endif +#define min(x, y) ((x)<(y)?(x):(y)) +#define max(x, y) ((x)>(y)?(x):(y)) + // #define DEBUG -#define ndevice (15) // Number of devices -#define phasefac (2.0) +#define NDEVICES (15) // Number of devices +#define PHASEFAC (2.0) #define PLNETMAX (10) #define NEVENTS (8) typedef struct { - int x; /* Quadrant location of planet */ - int y; - int pclass; /* class M, N, or O (1, 2, or 3) */ - int crystals; /* has crystals */ - int known; /* =1 contents known, =2 shuttle on this planet */ + int x; /* Quadrant location of planet */ + int y; + enum {M=0, N=1, O=2} pclass; + int crystals; /* has crystals */ + enum {unknown, known, shuttle_down} known; } planet; +#define DESTROY(pl) memset(pl, '\0', sizeof(planet)) + typedef struct { int snap, // snapshot taken remkl, // remaining klingons @@ -43,7 +48,7 @@ typedef struct { nromrem, // Romulans remaining nsckill, // super commanders killed nplankl; // destroyed planets - planet plnets[PLNETMAX+1]; // Planet information + planet plnets[PLNETMAX]; // Planet information double date, // stardate remres, // remaining resources remtime; // remaining time @@ -54,14 +59,17 @@ typedef struct { // original names. Gee, I could have done this with the d structure, // but I just didn't think of it back when I started. -EXTERN struct foo2 { +#define SSTMAGIC "SST2.0\n" + +EXTERN struct { + char magic[sizeof(SSTMAGIC)]; snapshot state; snapshot snapsht; char quad[11][11]; // contents of our quadrant double kpower[21]; // enemy energy levels double kdist[21]; // enemy distances double kavgd[21]; // average distances - double damage[ndevice+1]; // damage encountered + double damage[NDEVICES+1]; // damage encountered double future[NEVENTS+1]; // future events char passwd[10]; // Self Destruct password int kx[21]; // enemy sector locations @@ -246,9 +254,7 @@ EXTERN struct foo2 { #define nprobes game.nprobes // number of probes available /* the following global state doesn't need to be saved */ -EXTERN int fromcommandline; // Game start from command line options -EXTERN char *device[ndevice+1]; -EXTERN planet nulplanet; // zeroed planet structure +EXTERN char *device[NDEVICES+1]; EXTERN int iscore, iskill; // Common PLAQ EXTERN double perdate; EXTERN double aaitem; @@ -259,6 +265,7 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET, FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE, FHOLE} FINTYPE ; +enum loctype {neither, quadrant, sector}; /* Define devices */ #define DSRSENS 1 @@ -290,8 +297,7 @@ typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE, #define FDSPROB 8 // Move deep space probe #ifdef INCLUDED -planet nulplanet = {0}; -char *device[ndevice+1] = { +char *device[NDEVICES+1] = { "", "S. R. Sensors", "L. R. Sensors", @@ -336,8 +342,8 @@ char *device[ndevice+1] = { /* Function prototypes */ void prelim(void); void attack(int); -int choose(void); -void setup(void); +int choose(int); +void setup(int); void score(void); void atover(int); void srscan(int); @@ -370,14 +376,14 @@ int scan(void); void chew(void); void chew2(void); void skip(int); -void prout(char *s); -void proutn(char *s); +void prout(char *, ...); +void proutn(char *, ...); void stars(void); void newqad(int); int ja(void); void cramen(int); void crmshp(void); -void cramlc(int, int, int); +char *cramlc(enum loctype, int, int); double expran(double); double Rand(void); void iran8(int *, int *); @@ -393,15 +399,14 @@ void deadkl(int, int, int, int, int); void timwrp(void); void movcom(void); void torpedo(double, double, int, int, double *); -void cramf(double, int, int); -void crami(int, int); void huh(void); void pause(int); void nova(int, int); void snova(int, int); void scom(int *); void hittem(double *); -void prouts(char *); +void prouts(char *, ...); +void proutc(char *); int isit(char *); void preport(void); void orbit(void); @@ -415,3 +420,6 @@ void debugme(void); void attakreport(void); void movetho(void); void probe(void); +void clearscreen(void); +void iostart(void); +