12 #define min(x, y) ((x)<(y)?(x):(y))
13 #define max(x, y) ((x)>(y)?(x):(y))
17 #define NDEVICES (15) // Number of devices
18 #define PHASEFAC (2.0)
23 int x; /* Quadrant location of planet */
25 enum {M=0, N=1, O=2} pclass;
26 int crystals; /* has crystals */
27 enum {unknown, known, shuttle_down} known;
30 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
33 int snap, // snapshot taken
34 remkl, // remaining klingons
35 remcom, // remaining commanders
36 rembase, // remaining bases
37 starkl, // destroyed stars
38 basekl, // destroyed bases
39 killk, // Klingons killed
40 killc, // commanders killed
41 galaxy[9][9], // The Galaxy (subscript 0 not used)
42 cx[11],cy[11], // Commander quadrant coordinates
43 baseqx[6], // Base quadrant X
44 baseqy[6], // Base quadrant Y
45 newstuf[9][9], // Extended galaxy goodies
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
56 } snapshot; // Data that is snapshot
58 // Scalar variables that are needed for freezing the game
59 // are placed in a structure. #defines are used to access by their
60 // original names. Gee, I could have done this with the d structure,
61 // but I just didn't think of it back when I started.
63 #define SSTMAGIC "SST2.0\n"
65 EXTERN WINDOW *curwnd;
68 char magic[sizeof(SSTMAGIC)];
71 char quad[11][11]; // contents of our quadrant
72 double kpower[21]; // enemy energy levels
73 double kdist[21]; // enemy distances
74 double kavgd[21]; // average distances
75 double damage[NDEVICES+1]; // damage encountered
76 double future[NEVENTS+1]; // future events
77 char passwd[10]; // Self Destruct password
78 int kx[21]; // enemy sector locations
80 int starch[9][9]; // star chart
81 /* members with macro definitions start here */
173 #define inkling game.inkling // Initial number of klingons
174 #define inbase game.inbase // Initial number of bases
175 #define incom game.incom // Initian number of commanders
176 #define instar game.instar // Initial stars
177 #define intorps game.intorps // Initial/Max torpedoes
178 #define condit game.condit // Condition (red, yellow, green docked)
179 #define torps game.torps // number of torpedoes
180 #define ship game.ship // Ship type -- 'E' is Enterprise
181 #define quadx game.quadx // where we are
182 #define quady game.quady //
183 #define sectx game.sectx // where we are
184 #define secty game.secty //
185 #define length game.length // length of game
186 #define skill game.skill // skill level
187 #define basex game.basex // position of base in current quad
188 #define basey game.basey //
189 #define klhere game.klhere // klingons here
190 #define comhere game.comhere // commanders here
191 #define casual game.casual // causalties
192 #define nhelp game.nhelp // calls for help
193 #define nkinks game.nkinks //
194 #define ididit game.ididit // Action taken -- allows enemy to attack
195 #define gamewon game.gamewon // Finished!
196 #define alive game.alive // We are alive (not killed)
197 #define justin game.justin // just entered quadrant
198 #define alldone game.alldone // game is now finished
199 #define shldchg game.shldchg // shield is changing (affects efficiency)
200 #define thingx game.thingx // location of strange object in galaxy
201 #define thingy game.thingy //
202 #define plnetx game.plnetx // location of planet in quadrant
203 #define plnety game.plnety //
204 #define inorbit game.inorbit // orbiting
205 #define landed game.landed // party on planet (1), on ship (-1)
206 #define iplnet game.iplnet // planet # in quadrant
207 #define imine game.imine // mining
208 #define inplan game.inplan // initial planets
209 #define nenhere game.nenhere // Number of enemies in quadrant
210 #define ishere game.ishere // Super-commander in quandrant
211 #define neutz game.neutz // Romulan Neutral Zone
212 #define irhere game.irhere // Romulans in quadrant
213 #define iqhere game.iqhere // Thing in quadrant
214 #define iqengry game.iqengry // Thing attacking
215 #define icraft game.icraft // Kirk in Galileo
216 #define ientesc game.ientesc // Attempted escape from supercommander
217 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
218 #define isatb game.isatb // =1 if SuperCommander is attacking base
219 #define iscate game.iscate // Super Commander is here
221 #define idebug game.idebug // Debug mode
223 #define iattak game.iattak // attack recursion elimination (was cracks[4])
224 #define icrystl game.icrystl // dilithium crystals aboard
225 #define tourn game.tourn // Tournament number
226 #define thawed game.thawed // Thawed game
227 #define batx game.batx // Base coordinates being attacked
228 #define baty game.baty //
229 #define ithere game.ithere // Tholean is here
230 #define ithx game.ithx // coordinates of tholean
231 #define ithy game.ithy
232 #define iseenit game.iseenit // Seen base attack report
233 #define inresor game.inresor // initial resources
234 #define intime game.intime // initial time
235 #define inenrg game.inenrg // Initial/Max Energy
236 #define inshld game.inshld // Initial/Max Shield
237 #define inlsr game.inlsr // initial life support resources
238 #define indate game.indate // Initial date
239 #define energy game.energy // Energy level
240 #define shield game.shield // Shield level
241 #define shldup game.shldup // Shields are up
242 #define warpfac game.warpfac // Warp speed
243 #define wfacsq game.wfacsq // squared warp factor
244 #define lsupres game.lsupres // life support reserves
245 #define dist game.dist // movement distance
246 #define direc game.direc // movement direction
247 #define Time game.Time // time taken by current operation
248 #define docfac game.docfac // repair factor when docking (constant?)
249 #define resting game.resting // rest time
250 #define damfac game.damfac // damage factor
251 #define stdamtim game.stdamtim // time that star chart was damaged
252 #define cryprob game.cryprob // probability that crystal will work
253 #define probex game.probex // location of probe
254 #define probey game.probey
255 #define probecx game.probecx // current probe quadrant
256 #define probecy game.probecy
257 #define probeinx game.probeinx // Probe x,y increment
258 #define probeiny game.probeiny
259 #define proben game.proben // number of moves for probe
260 #define isarmed game.isarmed // Probe is armed
261 #define nprobes game.nprobes // number of probes available
263 /* the following global state doesn't need to be saved */
264 EXTERN char *device[NDEVICES+1];
265 EXTERN int iscore, iskill; // Common PLAQ
266 EXTERN double perdate;
267 EXTERN double aaitem;
268 EXTERN char citem[10];
270 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
271 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
272 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
273 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
275 enum loctype {neither, quadrant, sector};
291 #define DDRAY 14 // Added deathray
292 #define DDSP 15 // Added deep space probe
294 /* Define future events */
295 #define FSPY 0 // Spy event happens always (no future[] entry)
296 // can cause SC to tractor beam Enterprise
297 #define FSNOVA 1 // Supernova
298 #define FTBEAM 2 // Commander tractor beams Enterprise
299 #define FSNAP 3 // Snapshot for time warp
300 #define FBATTAK 4 // Commander attacks base
301 #define FCDBAS 5 // Commander destroys base
302 #define FSCMOVE 6 // Supercommander moves (might attack base)
303 #define FSCDBAS 7 // Supercommander destroys base
304 #define FDSPROB 8 // Move deep space probe
307 char *device[NDEVICES+1] = {
355 /* Function prototypes */
379 void finish(FINTYPE);
392 void prout(char *, ...);
393 void proutn(char *, ...);
399 char *cramlc(enum loctype, int, int);
400 double expran(double);
402 void iran8(int *, int *);
403 void iran10(int *, int *);
404 #define square(i) ((i)*(i))
405 void dropin(int, int*, int*);
409 void ram(int, int, int, int);
410 void crmena(int, int, int, int, int);
411 void deadkl(int, int, int, int, int);
414 void torpedo(double, double, int, int, double *, int, int, int);
416 void pause_game(int);
418 void snova(int, int);
420 void hittem(double *);
421 void prouts(char *, ...);
426 void drawmaps(short);
429 void usecrystals(void);
433 void attakreport(int);
437 void setwnd(WINDOW *);
439 void boom(int ii, int jj);
440 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
441 void cgetline(char *, int);
443 void setpassword(void);
444 void commandhook(char *, int);
445 void makechart(void);
446 void enqueue(char *s);
448 /* mode arguments for srscan() */
450 #define SCAN_REQUEST 2
451 #define SCAN_STATUS 3
452 #define SCAN_NO_LEFTSIDE 4
454 WINDOW *fullscreen_window;
455 WINDOW *srscan_window;
456 WINDOW *REPORT_WINDOW;
457 WINDOW *lrscan_window;
458 WINDOW *message_window;
459 WINDOW *prompt_window;
461 extern void clreol(void);
462 extern void clrscr(void);
463 extern void textcolor(int color);
464 extern void highvideo(void);
468 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
469 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
472 #define DAMAGED 128 /* marker for damaged ship in starmap */