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 */
218 #define inkling game.inkling // Initial number of klingons
219 #define inbase game.inbase // Initial number of bases
220 #define incom game.incom // Initian number of commanders
221 #define instar game.instar // Initial stars
222 #define intorps game.intorps // Initial/Max torpedoes
223 #define condit game.condit // Condition (red, yellow, green docked)
224 #define torps game.torps // number of torpedoes
225 #define ship game.ship // Ship type -- 'E' is Enterprise
226 #define quadx game.quadx // where we are
227 #define quady game.quady //
228 #define sectx game.sectx // where we are
229 #define secty game.secty //
230 #define length game.length // length of game
231 #define skill game.skill // skill level
232 #define basex game.basex // position of base in current quad
233 #define basey game.basey //
234 #define klhere game.klhere // klingons here
235 #define comhere game.comhere // commanders here
236 #define casual game.casual // causalties
237 #define nhelp game.nhelp // calls for help
238 #define nkinks game.nkinks //
239 #define ididit game.ididit // Action taken -- allows enemy to attack
240 #define gamewon game.gamewon // Finished!
241 #define alive game.alive // We are alive (not killed)
242 #define justin game.justin // just entered quadrant
243 #define alldone game.alldone // game is now finished
244 #define shldchg game.shldchg // shield is changing (affects efficiency)
245 #define plnetx game.plnetx // location of planet in quadrant
246 #define plnety game.plnety //
247 #define inorbit game.inorbit // orbiting
248 #define landed game.landed // party on planet (1), on ship (-1)
249 #define iplnet game.iplnet // planet # in quadrant
250 #define imine game.imine // mining
251 #define inplan game.inplan // initial planets
252 #define nenhere game.nenhere // Number of enemies in quadrant
253 #define ishere game.ishere // Super-commander in quandrant
254 #define neutz game.neutz // Romulan Neutral Zone
255 #define irhere game.irhere // Romulans in quadrant
256 #define icraft game.icraft // Kirk in Galileo
257 #define ientesc game.ientesc // Attempted escape from supercommander
258 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
259 #define isatb game.isatb // =1 if SuperCommander is attacking base
260 #define iscate game.iscate // Super Commander is here
262 #define idebug game.idebug // Debug mode
264 #define iattak game.iattak // attack recursion elimination (was cracks[4])
265 #define icrystl game.icrystl // dilithium crystals aboard
266 #define tourn game.tourn // Tournament number
267 #define thawed game.thawed // Thawed game
268 #define batx game.batx // Base coordinates being attacked
269 #define baty game.baty //
270 #define ithere game.ithere // Tholean is here
271 #define ithx game.ithx // coordinates of tholean
272 #define ithy game.ithy
273 #define iseenit game.iseenit // Seen base attack report
274 #define inresor game.inresor // initial resources
275 #define intime game.intime // initial time
276 #define inenrg game.inenrg // Initial/Max Energy
277 #define inshld game.inshld // Initial/Max Shield
278 #define inlsr game.inlsr // initial life support resources
279 #define indate game.indate // Initial date
280 #define energy game.energy // Energy level
281 #define shield game.shield // Shield level
282 #define shldup game.shldup // Shields are up
283 #define warpfac game.warpfac // Warp speed
284 #define wfacsq game.wfacsq // squared warp factor
285 #define lsupres game.lsupres // life support reserves
286 #define dist game.dist // movement distance
287 #define direc game.direc // movement direction
288 #define Time game.Time // time taken by current operation
289 #define docfac game.docfac // repair factor when docking (constant?)
290 #define resting game.resting // rest time
291 #define damfac game.damfac // damage factor
292 #define stdamtim game.stdamtim // time that star chart was damaged
293 #define cryprob game.cryprob // probability that crystal will work
294 #define probex game.probex // location of probe
295 #define probey game.probey
296 #define probecx game.probecx // current probe quadrant
297 #define probecy game.probecy
298 #define probeinx game.probeinx // Probe x,y increment
299 #define probeiny game.probeiny
300 #define proben game.proben // number of moves for probe
301 #define isarmed game.isarmed // Probe is armed
302 #define nprobes game.nprobes // number of probes available
304 /* the following global state doesn't need to be saved */
305 EXTERN char *device[NDEVICES];
306 EXTERN int iscore, iskill; // Common PLAQ
307 EXTERN double perdate;
308 EXTERN double aaitem;
309 EXTERN char citem[10];
311 /* the Space Thingy's global state should *not* be saved! */
312 EXTERN int thingx, thingy, iqhere, iqengry;
314 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
315 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
316 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
317 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
319 enum loctype {neither, quadrant, sector};
321 /* Define future events */
322 #define FSPY 0 // Spy event happens always (no future[] entry)
323 // can cause SC to tractor beam Enterprise
324 #define FSNOVA 1 // Supernova
325 #define FTBEAM 2 // Commander tractor beams Enterprise
326 #define FSNAP 3 // Snapshot for time warp
327 #define FBATTAK 4 // Commander attacks base
328 #define FCDBAS 5 // Commander destroys base
329 #define FSCMOVE 6 // Supercommander moves (might attack base)
330 #define FSCDBAS 7 // Supercommander destroys base
331 #define FDSPROB 8 // Move deep space probe
334 char *device[NDEVICES] = {
381 /* Function prototypes */
406 void finish(FINTYPE);
419 void prout(char *, ...);
420 void proutn(char *, ...);
426 char *cramlc(enum loctype, int, int);
427 double expran(double);
429 void iran(int, int *, int *);
430 #define square(i) ((i)*(i))
431 void dropin(int, int*, int*);
435 void ram(int, int, int, int);
436 void crmena(int, int, int, int, int);
437 void deadkl(int, int, int, int, int);
440 void torpedo(double, double, int, int, double *, int, int, int);
442 void pause_game(int);
444 void snova(int, int);
446 void hittem(double *);
447 void prouts(char *, ...);
452 void drawmaps(short);
455 void usecrystals(void);
459 void attakreport(int);
463 void setwnd(WINDOW *);
465 void boom(int ii, int jj);
466 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
467 void cgetline(char *, int);
469 void setpassword(void);
470 void commandhook(char *, int);
471 void makechart(void);
472 void enqueue(char *);
474 /* mode arguments for srscan() */
476 #define SCAN_REQUEST 2
477 #define SCAN_STATUS 3
478 #define SCAN_NO_LEFTSIDE 4
480 WINDOW *fullscreen_window;
481 WINDOW *srscan_window;
482 WINDOW *report_window;
483 WINDOW *lrscan_window;
484 WINDOW *message_window;
485 WINDOW *prompt_window;
487 extern void clreol(void);
488 extern void clrscr(void);
489 extern void textcolor(int color);
490 extern void highvideo(void);
494 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
495 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
498 #define DAMAGED 128 /* marker for damaged ship in starmap */