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 */
123 #define DDRAY 13 // Added deathray
124 #define DDSP 14 // Added deep space probe
125 #define NDEVICES (15) // Number of devices
129 /* Define future events */
130 #define FSPY 0 // Spy event happens always (no future[] entry)
131 // can cause SC to tractor beam Enterprise
132 #define FSNOVA 1 // Supernova
133 #define FTBEAM 2 // Commander tractor beams Enterprise
134 #define FSNAP 3 // Snapshot for time warp
135 #define FBATTAK 4 // Commander attacks base
136 #define FCDBAS 5 // Commander destroys base
137 #define FSCMOVE 6 // Supercommander moves (might attack base)
138 #define FSCDBAS 7 // Supercommander destroys base
139 #define FDSPROB 8 // Move deep space probe
142 // Scalar variables that are needed for freezing the game
143 // are placed in a structure. #defines are used to access by their
144 // original names. Gee, I could have done this with the d structure,
145 // but I just didn't think of it back when I started.
147 #define SSTMAGIC "SST2.0\n"
149 EXTERN WINDOW *curwnd;
152 char magic[sizeof(SSTMAGIC)];
153 unsigned long options;
156 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
157 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
158 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
159 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
160 double damage[NDEVICES]; // damage encountered
161 double future[NEVENTS]; // future events
162 char passwd[10]; // Self Destruct password
163 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
164 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
165 /* members with macro definitions start here */
256 #define inkling game.inkling // Initial number of klingons
257 #define inbase game.inbase // Initial number of bases
258 #define incom game.incom // Initian number of commanders
259 #define inscom game.inscom // Initian number of commanders
260 #define inrom game.inrom // Initian number of commanders
261 #define instar game.instar // Initial stars
262 #define intorps game.intorps // Initial/Max torpedoes
263 #define condit game.condit // Condition (red/yellow/green/docked)
264 #define torps game.torps // number of torpedoes
265 #define ship game.ship // Ship type -- 'E' is Enterprise
266 #define quadx game.quadx // where we are
267 #define quady game.quady //
268 #define sectx game.sectx // where we are
269 #define secty game.secty //
270 #define length game.length // length of game
271 #define skill game.skill // skill level
272 #define basex game.basex // position of base in current quad
273 #define basey game.basey //
274 #define klhere game.klhere // klingons here
275 #define comhere game.comhere // commanders here
276 #define casual game.casual // causalties
277 #define nhelp game.nhelp // calls for help
278 #define nkinks game.nkinks //
279 #define ididit game.ididit // Action taken -- allows enemy to attack
280 #define gamewon game.gamewon // Finished!
281 #define alive game.alive // We are alive (not killed)
282 #define justin game.justin // just entered quadrant
283 #define alldone game.alldone // game is now finished
284 #define shldchg game.shldchg // shield is changing (affects efficiency)
285 #define plnetx game.plnetx // location of planet in quadrant
286 #define plnety game.plnety //
287 #define inorbit game.inorbit // orbiting
288 #define landed game.landed // party on planet (1), on ship (-1)
289 #define iplnet game.iplnet // planet # in quadrant
290 #define imine game.imine // mining
291 #define inplan game.inplan // initial planets
292 #define nenhere game.nenhere // Number of enemies in quadrant
293 #define ishere game.ishere // Super-commander in quandrant
294 #define neutz game.neutz // Romulan Neutral Zone
295 #define irhere game.irhere // Romulans in quadrant
296 #define icraft game.icraft // Kirk in Galileo
297 #define ientesc game.ientesc // Attempted escape from supercommander
298 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
299 #define isatb game.isatb // =1 if SuperCommander is attacking base
300 #define iscate game.iscate // Super Commander is here
302 #define idebug game.idebug // Debug mode
304 #define iattak game.iattak // attack recursion elimination (was cracks[4])
305 #define icrystl game.icrystl // dilithium crystals aboard
306 #define tourn game.tourn // Tournament number
307 #define thawed game.thawed // Thawed game
308 #define batx game.batx // Base coordinates being attacked
309 #define baty game.baty //
310 #define ithere game.ithere // Tholean is here
311 #define ithx game.ithx // coordinates of tholean
312 #define ithy game.ithy
313 #define iseenit game.iseenit // Seen base attack report
314 #define inresor game.inresor // initial resources
315 #define intime game.intime // initial time
316 #define inenrg game.inenrg // Initial/Max Energy
317 #define inshld game.inshld // Initial/Max Shield
318 #define inlsr game.inlsr // initial life support resources
319 #define indate game.indate // Initial date
320 #define energy game.energy // Energy level
321 #define shield game.shield // Shield level
322 #define shldup game.shldup // Shields are up
323 #define warpfac game.warpfac // Warp speed
324 #define wfacsq game.wfacsq // squared warp factor
325 #define lsupres game.lsupres // life support reserves
326 #define dist game.dist // movement distance
327 #define direc game.direc // movement direction
328 #define Time game.Time // time taken by current operation
329 #define docfac game.docfac // repair factor when docking (constant?)
330 #define resting game.resting // rest time
331 #define damfac game.damfac // damage factor
332 #define lastchart game.lastchart // time star chart was last updated
333 #define cryprob game.cryprob // probability that crystal will work
334 #define probex game.probex // location of probe
335 #define probey game.probey
336 #define probecx game.probecx // current probe quadrant
337 #define probecy game.probecy
338 #define probeinx game.probeinx // Probe x,y increment
339 #define probeiny game.probeiny
340 #define proben game.proben // number of moves for probe
341 #define isarmed game.isarmed // Probe is armed
342 #define nprobes game.nprobes // number of probes available
344 /* the following global state doesn't need to be saved */
345 EXTERN char *device[NDEVICES];
346 EXTERN int iscore, iskill; // Common PLAQ
347 EXTERN double perdate;
348 EXTERN double aaitem;
349 EXTERN char citem[10];
351 /* the Space Thingy's global state should *not* be saved! */
352 EXTERN int thingx, thingy, iqhere, iqengry;
354 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
355 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
356 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
357 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
359 enum loctype {neither, quadrant, sector};
362 char *device[NDEVICES] = {
409 /* Function prototypes */
434 void finish(FINTYPE);
447 void prout(char *, ...);
448 void proutn(char *, ...);
454 char *cramlc(enum loctype, int, int);
455 double expran(double);
457 void iran(int, int *, int *);
458 #define square(i) ((i)*(i))
459 void dropin(int, int*, int*);
463 void ram(int, int, int, int);
464 void crmena(int, int, int, int, int);
465 void deadkl(int, int, int, int, int);
468 void torpedo(double, double, int, int, double *, int, int);
470 void pause_game(int);
472 void snova(int, int);
474 void hittem(double *);
475 void prouts(char *, ...);
480 void drawmaps(short);
483 void usecrystals(void);
487 void attakreport(int);
491 void setwnd(WINDOW *);
493 void boom(int ii, int jj);
494 void tracktorpedo(int ix, int iy, int l, int i, int n, int iquad);
495 void cgetline(char *, int);
497 void setpassword(void);
498 void commandhook(char *, int);
499 void makechart(void);
500 void enqueue(char *);
502 /* mode arguments for srscan() */
504 #define SCAN_REQUEST 2
505 #define SCAN_STATUS 3
506 #define SCAN_NO_LEFTSIDE 4
508 WINDOW *fullscreen_window;
509 WINDOW *srscan_window;
510 WINDOW *report_window;
511 WINDOW *lrscan_window;
512 WINDOW *message_window;
513 WINDOW *prompt_window;
515 extern void clreol(void);
516 extern void clrscr(void);
517 extern void textcolor(int color);
518 extern void highvideo(void);
522 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
523 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
526 #define DAMAGED 128 /* marker for damaged ship in starmap */