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