12 #define min(x, y) ((x)<(y)?(x):(y))
13 #define max(x, y) ((x)>(y)?(x):(y))
17 #define PHASEFAC (2.0)
25 * These macros hide the difference between 0-origin and 1-origin addressing.
26 * They're a step towards de-FORTRANizing the code.
28 #define VALID_QUADRANT(x, y) ((x)>=1 && (x)<=GALSIZE && (y)>=1 && (y)<=GALSIZE)
29 #define VALID_SECTOR(x, y) ((x)>=1 && (x)<=QUADSIZE && (y)>=1 && (y)<=QUADSIZE)
30 #define for_quadrants(i) for (i = 1; i < GALSIZE+1; i++)
31 #define for_sectors(i) for (i = 1; i < QUADSIZE+1; i++)
34 int x; /* Quadrant location of planet */
36 enum {M=0, N=1, O=2} pclass;
37 int crystals; /* has crystals */
38 enum {unknown, known, shuttle_down} known;
41 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
44 int snap, // snapshot taken
45 remkl, // remaining klingons
46 remcom, // remaining commanders
47 rembase, // remaining bases
48 starkl, // destroyed stars
49 basekl, // destroyed bases
50 killk, // Klingons killed
51 killc, // commanders killed
52 cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
53 baseqx[BASEMAX], // Base quadrant X
54 baseqy[BASEMAX], // Base quadrant Y
55 isx, isy, // Coordinate of Super Commander
56 nscrem, // remaining super commanders
57 nromkl, // Romulans killed
58 nromrem, // Romulans remaining
59 nsckill, // super commanders killed
60 nplankl; // destroyed planets
61 planet plnets[PLNETMAX]; // Planet information
62 double date, // stardate
63 remres, // remaining resources
64 remtime; // remaining time
73 } galaxy[GALSIZE+1][GALSIZE+1]; // The Galaxy (subscript 0 not used)
78 } chart[GALSIZE+1][GALSIZE+1]; // the starchart (subscript 0 not used)
79 } snapshot; // Data that is snapshot
82 #define SKILL_NOVICE 1
85 #define SKILL_EXPERT 4
86 #define SKILL_EMERITUS 5
89 #define OPTION_ALL 0xffffffff
90 #define OPTION_TTY 0x00000001 /* old interface */
91 #define OPTION_CURSES 0x00000002 /* new interface */
92 #define OPTION_IOMODES 0x00000003 /* cover both interfaces */
93 #define OPTION_PLANETS 0x00000004 /* planets and mining */
94 #define OPTION_THOLIAN 0x00000008 /* Tholians and their webs */
95 #define OPTION_THINGY 0x00000010 /* Space Thingy can shoot back */
96 #define OPTION_PROBE 0x00000020 /* deep-space probes */
112 #define DDRAY 13 // Added deathray
113 #define DDSP 14 // Added deep space probe
114 #define NDEVICES (15) // Number of devices
116 // Scalar variables that are needed for freezing the game
117 // are placed in a structure. #defines are used to access by their
118 // original names. Gee, I could have done this with the d structure,
119 // but I just didn't think of it back when I started.
121 #define SSTMAGIC "SST2.0\n"
123 EXTERN WINDOW *curwnd;
126 char magic[sizeof(SSTMAGIC)];
127 unsigned long options;
130 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
131 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
132 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
133 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
134 double damage[NDEVICES]; // damage encountered
135 double future[NEVENTS+1]; // future events
136 char passwd[10]; // Self Destruct password
137 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
138 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
139 /* members with macro definitions start here */
228 #define inkling game.inkling // Initial number of klingons
229 #define inbase game.inbase // Initial number of bases
230 #define incom game.incom // Initian number of commanders
231 #define instar game.instar // Initial stars
232 #define intorps game.intorps // Initial/Max torpedoes
233 #define condit game.condit // Condition (red, yellow, green docked)
234 #define torps game.torps // number of torpedoes
235 #define ship game.ship // Ship type -- 'E' is Enterprise
236 #define quadx game.quadx // where we are
237 #define quady game.quady //
238 #define sectx game.sectx // where we are
239 #define secty game.secty //
240 #define length game.length // length of game
241 #define skill game.skill // skill level
242 #define basex game.basex // position of base in current quad
243 #define basey game.basey //
244 #define klhere game.klhere // klingons here
245 #define comhere game.comhere // commanders here
246 #define casual game.casual // causalties
247 #define nhelp game.nhelp // calls for help
248 #define nkinks game.nkinks //
249 #define ididit game.ididit // Action taken -- allows enemy to attack
250 #define gamewon game.gamewon // Finished!
251 #define alive game.alive // We are alive (not killed)
252 #define justin game.justin // just entered quadrant
253 #define alldone game.alldone // game is now finished
254 #define shldchg game.shldchg // shield is changing (affects efficiency)
255 #define plnetx game.plnetx // location of planet in quadrant
256 #define plnety game.plnety //
257 #define inorbit game.inorbit // orbiting
258 #define landed game.landed // party on planet (1), on ship (-1)
259 #define iplnet game.iplnet // planet # in quadrant
260 #define imine game.imine // mining
261 #define inplan game.inplan // initial planets
262 #define nenhere game.nenhere // Number of enemies in quadrant
263 #define ishere game.ishere // Super-commander in quandrant
264 #define neutz game.neutz // Romulan Neutral Zone
265 #define irhere game.irhere // Romulans in quadrant
266 #define icraft game.icraft // Kirk in Galileo
267 #define ientesc game.ientesc // Attempted escape from supercommander
268 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
269 #define isatb game.isatb // =1 if SuperCommander is attacking base
270 #define iscate game.iscate // Super Commander is here
272 #define idebug game.idebug // Debug mode
274 #define iattak game.iattak // attack recursion elimination (was cracks[4])
275 #define icrystl game.icrystl // dilithium crystals aboard
276 #define tourn game.tourn // Tournament number
277 #define thawed game.thawed // Thawed game
278 #define batx game.batx // Base coordinates being attacked
279 #define baty game.baty //
280 #define ithere game.ithere // Tholean is here
281 #define ithx game.ithx // coordinates of tholean
282 #define ithy game.ithy
283 #define iseenit game.iseenit // Seen base attack report
284 #define inresor game.inresor // initial resources
285 #define intime game.intime // initial time
286 #define inenrg game.inenrg // Initial/Max Energy
287 #define inshld game.inshld // Initial/Max Shield
288 #define inlsr game.inlsr // initial life support resources
289 #define indate game.indate // Initial date
290 #define energy game.energy // Energy level
291 #define shield game.shield // Shield level
292 #define shldup game.shldup // Shields are up
293 #define warpfac game.warpfac // Warp speed
294 #define wfacsq game.wfacsq // squared warp factor
295 #define lsupres game.lsupres // life support reserves
296 #define dist game.dist // movement distance
297 #define direc game.direc // movement direction
298 #define Time game.Time // time taken by current operation
299 #define docfac game.docfac // repair factor when docking (constant?)
300 #define resting game.resting // rest time
301 #define damfac game.damfac // damage factor
302 #define stdamtim game.stdamtim // time that star chart was damaged
303 #define cryprob game.cryprob // probability that crystal will work
304 #define probex game.probex // location of probe
305 #define probey game.probey
306 #define probecx game.probecx // current probe quadrant
307 #define probecy game.probecy
308 #define probeinx game.probeinx // Probe x,y increment
309 #define probeiny game.probeiny
310 #define proben game.proben // number of moves for probe
311 #define isarmed game.isarmed // Probe is armed
312 #define nprobes game.nprobes // number of probes available
314 /* the following global state doesn't need to be saved */
315 EXTERN char *device[NDEVICES];
316 EXTERN int iscore, iskill; // Common PLAQ
317 EXTERN double perdate;
318 EXTERN double aaitem;
319 EXTERN char citem[10];
321 /* the Space Thingy's global state should *not* be saved! */
322 EXTERN int thingx, thingy, iqhere, iqengry;
324 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
325 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
326 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
327 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
329 enum loctype {neither, quadrant, sector};
331 /* Define future events */
332 #define FSPY 0 // Spy event happens always (no future[] entry)
333 // can cause SC to tractor beam Enterprise
334 #define FSNOVA 1 // Supernova
335 #define FTBEAM 2 // Commander tractor beams Enterprise
336 #define FSNAP 3 // Snapshot for time warp
337 #define FBATTAK 4 // Commander attacks base
338 #define FCDBAS 5 // Commander destroys base
339 #define FSCMOVE 6 // Supercommander moves (might attack base)
340 #define FSCDBAS 7 // Supercommander destroys base
341 #define FDSPROB 8 // Move deep space probe
344 char *device[NDEVICES] = {
391 /* Function prototypes */
416 void finish(FINTYPE);
429 void prout(char *, ...);
430 void proutn(char *, ...);
436 char *cramlc(enum loctype, int, int);
437 double expran(double);
439 void iran(int, int *, int *);
440 #define square(i) ((i)*(i))
441 void dropin(int, int*, int*);
445 void ram(int, int, int, int);
446 void crmena(int, int, int, int, int);
447 void deadkl(int, int, int, int, int);
450 void torpedo(double, double, int, int, double *, int, int, int);
452 void pause_game(int);
454 void snova(int, int);
456 void hittem(double *);
457 void prouts(char *, ...);
462 void drawmaps(short);
465 void usecrystals(void);
469 void attakreport(int);
473 void setwnd(WINDOW *);
475 void boom(int ii, int jj);
476 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
477 void cgetline(char *, int);
479 void setpassword(void);
480 void commandhook(char *, int);
481 void makechart(void);
482 void enqueue(char *);
484 /* mode arguments for srscan() */
486 #define SCAN_REQUEST 2
487 #define SCAN_STATUS 3
488 #define SCAN_NO_LEFTSIDE 4
490 WINDOW *fullscreen_window;
491 WINDOW *srscan_window;
492 WINDOW *report_window;
493 WINDOW *lrscan_window;
494 WINDOW *message_window;
495 WINDOW *prompt_window;
497 extern void clreol(void);
498 extern void clrscr(void);
499 extern void textcolor(int color);
500 extern void highvideo(void);
504 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
505 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
508 #define DAMAGED 128 /* marker for damaged ship in starmap */