12 #define min(x, y) ((x)<(y)?(x):(y))
13 #define max(x, y) ((x)>(y)?(x):(y))
17 #define PHASEFAC (2.0)
24 * These macros hide the difference between 0-origin and 1-origin addressing.
25 * They're a step towards de-FORTRANizing the code.
27 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
28 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
29 #define for_quadrants(i) for (i = 1; i <= GALSIZE; i++)
30 #define for_sectors(i) for (i = 1; i <= QUADSIZE; i++)
31 #define for_commanders(i) for (i = 1; i <= game.state.remcom; i++)
32 #define for_local_enemies(i) for (i = 1; i <= nenhere; i++)
33 #define for_starbases(i) for (i = 1; i <= game.state.rembase; i++)
36 int x; /* Quadrant location of planet */
38 enum {M=0, N=1, O=2} pclass;
39 int crystals; /* has crystals */
40 enum {unknown, known, shuttle_down} known;
43 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
46 int snap, // snapshot taken
47 remkl, // remaining klingons
48 remcom, // remaining commanders
49 nscrem, // remaining super commanders
50 rembase, // remaining bases
51 starkl, // destroyed stars
52 basekl, // destroyed bases
53 cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
54 baseqx[BASEMAX+1], // Base quadrant X
55 baseqy[BASEMAX+1], // Base quadrant Y
56 isx, isy, // Coordinate of Super Commander
57 nromrem, // Romulans remaining
58 nplankl; // destroyed planets
59 planet plnets[PLNETMAX]; // Planet information
60 double date, // stardate
61 remres, // remaining resources
62 remtime; // remaining time
71 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
76 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
77 } snapshot; // Data that is snapshot
79 #define NKILLK (inkling - game.state.remkl)
80 #define NKILLC (incom - game.state.remcom)
81 #define NKILLSC (inscom - game.state.nscrem)
82 #define NKILLROM (inrom - game.state.nromrem)
83 #define KLINGREM (game.state.remkl + game.state.remcom + game.state.nscrem)
84 #define INKLINGTOT (inkling + incom + inscom)
85 #define KLINGKILLED (INKLINGTOT - KLINGREM)
88 #define SKILL_NOVICE 1
91 #define SKILL_EXPERT 4
92 #define SKILL_EMERITUS 5
95 #define OPTION_ALL 0xffffffff
96 #define OPTION_TTY 0x00000001 /* old interface */
97 #define OPTION_CURSES 0x00000002 /* new interface */
98 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
99 #define OPTION_PLANETS 0x00000004 /* planets and mining */
100 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
101 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
102 #define OPTION_PROBE 0x00000020 /* deep-space probes */
103 #define OPTION_SHOWME 0x00000040 /* bracket Enterprise in chart */
104 #define OPTION_RAMMING 0x00000080 /* enemies may ram Enterprise */
105 #define OPTION_MVBADDY 0x00000100 /* more enemies can move */
106 #define OPTION_BLKHOLE 0x00000200 /* black hole may timewarp you */
107 #define OPTION_BASE 0x00000400 /* bases have good shields */
108 #define OPTION_PLAIN 0x01000000 /* user chose plain game */
109 #define OPTION_ALMY 0x02000000 /* user chose Almy variant */
125 #define DDRAY 13 // Added deathray
126 #define DDSP 14 // Added deep space probe
127 #define NDEVICES (15) // Number of devices
131 /* Define future events */
132 #define FSPY 0 // Spy event happens always (no future[] entry)
133 // can cause SC to tractor beam Enterprise
134 #define FSNOVA 1 // Supernova
135 #define FTBEAM 2 // Commander tractor beams Enterprise
136 #define FSNAP 3 // Snapshot for time warp
137 #define FBATTAK 4 // Commander attacks base
138 #define FCDBAS 5 // Commander destroys base
139 #define FSCMOVE 6 // Supercommander moves (might attack base)
140 #define FSCDBAS 7 // Supercommander destroys base
141 #define FDSPROB 8 // Move deep space probe
144 // Scalar variables that are needed for freezing the game
145 // are placed in a structure. #defines are used to access by their
146 // original names. Gee, I could have done this with the d structure,
147 // but I just didn't think of it back when I started.
149 #define SSTMAGIC "SST2.0\n"
151 EXTERN WINDOW *curwnd;
154 char magic[sizeof(SSTMAGIC)];
155 unsigned long options;
158 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
159 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
160 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
161 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
162 double damage[NDEVICES]; // damage encountered
163 double future[NEVENTS]; // future events
164 char passwd[10]; // Self Destruct password
165 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
166 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
167 /* members with macro definitions start here */
258 #define inkling game.inkling // Initial number of klingons
259 #define inbase game.inbase // Initial number of bases
260 #define incom game.incom // Initian number of commanders
261 #define inscom game.inscom // Initian number of commanders
262 #define inrom game.inrom // Initian number of commanders
263 #define instar game.instar // Initial stars
264 #define intorps game.intorps // Initial/Max torpedoes
265 #define condit game.condit // Condition (red/yellow/green/docked)
266 #define torps game.torps // number of torpedoes
267 #define ship game.ship // Ship type -- 'E' is Enterprise
268 #define quadx game.quadx // where we are
269 #define quady game.quady //
270 #define sectx game.sectx // where we are
271 #define secty game.secty //
272 #define length game.length // length of game
273 #define skill game.skill // skill level
274 #define basex game.basex // position of base in current quad
275 #define basey game.basey //
276 #define klhere game.klhere // klingons here
277 #define comhere game.comhere // commanders here
278 #define casual game.casual // causalties
279 #define nhelp game.nhelp // calls for help
280 #define nkinks game.nkinks //
281 #define ididit game.ididit // Action taken -- allows enemy to attack
282 #define gamewon game.gamewon // Finished!
283 #define alive game.alive // We are alive (not killed)
284 #define justin game.justin // just entered quadrant
285 #define alldone game.alldone // game is now finished
286 #define shldchg game.shldchg // shield is changing (affects efficiency)
287 #define plnetx game.plnetx // location of planet in quadrant
288 #define plnety game.plnety //
289 #define inorbit game.inorbit // orbiting
290 #define landed game.landed // party on planet (1), on ship (-1)
291 #define iplnet game.iplnet // planet # in quadrant
292 #define imine game.imine // mining
293 #define inplan game.inplan // initial planets
294 #define nenhere game.nenhere // Number of enemies in quadrant
295 #define ishere game.ishere // Super-commander in quandrant
296 #define neutz game.neutz // Romulan Neutral Zone
297 #define irhere game.irhere // Romulans in quadrant
298 #define icraft game.icraft // Kirk in Galileo
299 #define ientesc game.ientesc // Attempted escape from supercommander
300 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
301 #define isatb game.isatb // =1 if SuperCommander is attacking base
302 #define iscate game.iscate // Super Commander is here
304 #define idebug game.idebug // Debug mode
306 #define iattak game.iattak // attack recursion elimination (was cracks[4])
307 #define icrystl game.icrystl // dilithium crystals aboard
308 #define tourn game.tourn // Tournament number
309 #define thawed game.thawed // Thawed game
310 #define batx game.batx // Base coordinates being attacked
311 #define baty game.baty //
312 #define ithere game.ithere // Tholean is here
313 #define ithx game.ithx // coordinates of tholean
314 #define ithy game.ithy
315 #define iseenit game.iseenit // Seen base attack report
316 #define inresor game.inresor // initial resources
317 #define intime game.intime // initial time
318 #define inenrg game.inenrg // Initial/Max Energy
319 #define inshld game.inshld // Initial/Max Shield
320 #define inlsr game.inlsr // initial life support resources
321 #define indate game.indate // Initial date
322 #define energy game.energy // Energy level
323 #define shield game.shield // Shield level
324 #define shldup game.shldup // Shields are up
325 #define warpfac game.warpfac // Warp speed
326 #define wfacsq game.wfacsq // squared warp factor
327 #define lsupres game.lsupres // life support reserves
328 #define dist game.dist // movement distance
329 #define direc game.direc // movement direction
330 #define Time game.Time // time taken by current operation
331 #define docfac game.docfac // repair factor when docking (constant?)
332 #define resting game.resting // rest time
333 #define damfac game.damfac // damage factor
334 #define lastchart game.lastchart // time star chart was last updated
335 #define cryprob game.cryprob // probability that crystal will work
336 #define probex game.probex // location of probe
337 #define probey game.probey
338 #define probecx game.probecx // current probe quadrant
339 #define probecy game.probecy
340 #define probeinx game.probeinx // Probe x,y increment
341 #define probeiny game.probeiny
342 #define proben game.proben // number of moves for probe
343 #define isarmed game.isarmed // Probe is armed
344 #define nprobes game.nprobes // number of probes available
346 /* the following global state doesn't need to be saved */
347 EXTERN char *device[NDEVICES];
348 EXTERN int iscore, iskill; // Common PLAQ
349 EXTERN double perdate;
350 EXTERN double aaitem;
351 EXTERN char citem[10];
353 /* the Space Thingy's global state should *not* be saved! */
354 EXTERN int thingx, thingy, iqhere, iqengry;
356 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
357 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
358 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
359 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
361 enum loctype {neither, quadrant, sector};
364 char *device[NDEVICES] = {
411 /* Function prototypes */
436 void finish(FINTYPE);
449 void prout(char *, ...);
450 void proutn(char *, ...);
456 char *cramlc(enum loctype, int, int);
457 double expran(double);
459 void iran(int, int *, int *);
460 #define square(i) ((i)*(i))
461 void dropin(int, int*, int*);
465 void ram(int, int, int, int);
466 void crmena(int, int, int, int, int);
467 void deadkl(int, int, int, int, int);
470 void torpedo(double, double, int, int, double *, int, int);
472 void pause_game(int);
474 void snova(int, int);
476 void hittem(double *);
477 void prouts(char *, ...);
482 void drawmaps(short);
485 void usecrystals(void);
489 void attakreport(int);
493 void setwnd(WINDOW *);
495 void boom(int ii, int jj);
496 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
497 void cgetline(char *, int);
499 void setpassword(void);
500 void commandhook(char *, int);
501 void makechart(void);
502 void enqueue(char *);
504 /* mode arguments for srscan() */
506 #define SCAN_REQUEST 2
507 #define SCAN_STATUS 3
508 #define SCAN_NO_LEFTSIDE 4
510 WINDOW *fullscreen_window;
511 WINDOW *srscan_window;
512 WINDOW *report_window;
513 WINDOW *lrscan_window;
514 WINDOW *message_window;
515 WINDOW *prompt_window;
517 extern void clreol(void);
518 extern void clrscr(void);
519 extern void textcolor(int color);
520 extern void highvideo(void);
524 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
525 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
528 #define DAMAGED 128 /* marker for damaged ship in starmap */