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