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)
26 int x; /* Quadrant location of planet */
28 enum {M=0, N=1, O=2} pclass;
29 int crystals; /* has crystals */
30 enum {unknown, known, shuttle_down} known;
33 #define DESTROY(pl) memset(pl, '\0', sizeof(planet))
36 int snap, // snapshot taken
37 remkl, // remaining klingons
38 remcom, // remaining commanders
39 rembase, // remaining bases
40 starkl, // destroyed stars
41 basekl, // destroyed bases
42 killk, // Klingons killed
43 killc, // commanders killed
44 galaxy[GALSIZE+1][GALSIZE+1], // The Galaxy (subscript 0 not used)
45 cx[QUADSIZE+1],cy[QUADSIZE+1], // Commander quadrant coordinates
46 baseqx[BASEMAX], // Base quadrant X
47 baseqy[BASEMAX], // Base quadrant Y
48 newstuf[GALSIZE+1][GALSIZE+1], // Extended galaxy goodies
49 isx, isy, // Coordinate of Super Commander
50 nscrem, // remaining super commanders
51 nromkl, // Romulans killed
52 nromrem, // Romulans remaining
53 nsckill, // super commanders killed
54 nplankl; // destroyed planets
55 planet plnets[PLNETMAX]; // Planet information
56 double date, // stardate
57 remres, // remaining resources
58 remtime; // remaining time
59 } snapshot; // Data that is snapshot
62 * This is how the integers in galaxy are encoded.
63 * Someday these should turn into structure fields.
65 #define SUPERNOVA_PLACE 1000
66 #define ENEMY_PLACE 100
71 #define ROMULAN_PLACE 10
74 #define CHART_UNKNOWN -1
76 // Scalar variables that are needed for freezing the game
77 // are placed in a structure. #defines are used to access by their
78 // original names. Gee, I could have done this with the d structure,
79 // but I just didn't think of it back when I started.
81 #define SSTMAGIC "SST2.0\n"
83 EXTERN WINDOW *curwnd;
86 char magic[sizeof(SSTMAGIC)];
89 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
90 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
91 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
92 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
93 double damage[NDEVICES+1]; // damage encountered
94 double future[NEVENTS+1]; // future events
95 char passwd[10]; // Self Destruct password
96 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
97 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
98 int starch[GALSIZE+1][GALSIZE+1]; // star chart
99 /* members with macro definitions start here */
191 #define inkling game.inkling // Initial number of klingons
192 #define inbase game.inbase // Initial number of bases
193 #define incom game.incom // Initian number of commanders
194 #define instar game.instar // Initial stars
195 #define intorps game.intorps // Initial/Max torpedoes
196 #define condit game.condit // Condition (red, yellow, green docked)
197 #define torps game.torps // number of torpedoes
198 #define ship game.ship // Ship type -- 'E' is Enterprise
199 #define quadx game.quadx // where we are
200 #define quady game.quady //
201 #define sectx game.sectx // where we are
202 #define secty game.secty //
203 #define length game.length // length of game
204 #define skill game.skill // skill level
205 #define basex game.basex // position of base in current quad
206 #define basey game.basey //
207 #define klhere game.klhere // klingons here
208 #define comhere game.comhere // commanders here
209 #define casual game.casual // causalties
210 #define nhelp game.nhelp // calls for help
211 #define nkinks game.nkinks //
212 #define ididit game.ididit // Action taken -- allows enemy to attack
213 #define gamewon game.gamewon // Finished!
214 #define alive game.alive // We are alive (not killed)
215 #define justin game.justin // just entered quadrant
216 #define alldone game.alldone // game is now finished
217 #define shldchg game.shldchg // shield is changing (affects efficiency)
218 #define thingx game.thingx // location of strange object in galaxy
219 #define thingy game.thingy //
220 #define plnetx game.plnetx // location of planet in quadrant
221 #define plnety game.plnety //
222 #define inorbit game.inorbit // orbiting
223 #define landed game.landed // party on planet (1), on ship (-1)
224 #define iplnet game.iplnet // planet # in quadrant
225 #define imine game.imine // mining
226 #define inplan game.inplan // initial planets
227 #define nenhere game.nenhere // Number of enemies in quadrant
228 #define ishere game.ishere // Super-commander in quandrant
229 #define neutz game.neutz // Romulan Neutral Zone
230 #define irhere game.irhere // Romulans in quadrant
231 #define iqhere game.iqhere // Thing in quadrant
232 #define iqengry game.iqengry // Thing attacking
233 #define icraft game.icraft // Kirk in Galileo
234 #define ientesc game.ientesc // Attempted escape from supercommander
235 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
236 #define isatb game.isatb // =1 if SuperCommander is attacking base
237 #define iscate game.iscate // Super Commander is here
239 #define idebug game.idebug // Debug mode
241 #define iattak game.iattak // attack recursion elimination (was cracks[4])
242 #define icrystl game.icrystl // dilithium crystals aboard
243 #define tourn game.tourn // Tournament number
244 #define thawed game.thawed // Thawed game
245 #define batx game.batx // Base coordinates being attacked
246 #define baty game.baty //
247 #define ithere game.ithere // Tholean is here
248 #define ithx game.ithx // coordinates of tholean
249 #define ithy game.ithy
250 #define iseenit game.iseenit // Seen base attack report
251 #define inresor game.inresor // initial resources
252 #define intime game.intime // initial time
253 #define inenrg game.inenrg // Initial/Max Energy
254 #define inshld game.inshld // Initial/Max Shield
255 #define inlsr game.inlsr // initial life support resources
256 #define indate game.indate // Initial date
257 #define energy game.energy // Energy level
258 #define shield game.shield // Shield level
259 #define shldup game.shldup // Shields are up
260 #define warpfac game.warpfac // Warp speed
261 #define wfacsq game.wfacsq // squared warp factor
262 #define lsupres game.lsupres // life support reserves
263 #define dist game.dist // movement distance
264 #define direc game.direc // movement direction
265 #define Time game.Time // time taken by current operation
266 #define docfac game.docfac // repair factor when docking (constant?)
267 #define resting game.resting // rest time
268 #define damfac game.damfac // damage factor
269 #define stdamtim game.stdamtim // time that star chart was damaged
270 #define cryprob game.cryprob // probability that crystal will work
271 #define probex game.probex // location of probe
272 #define probey game.probey
273 #define probecx game.probecx // current probe quadrant
274 #define probecy game.probecy
275 #define probeinx game.probeinx // Probe x,y increment
276 #define probeiny game.probeiny
277 #define proben game.proben // number of moves for probe
278 #define isarmed game.isarmed // Probe is armed
279 #define nprobes game.nprobes // number of probes available
281 /* the following global state doesn't need to be saved */
282 EXTERN char *device[NDEVICES+1];
283 EXTERN int iscore, iskill; // Common PLAQ
284 EXTERN double perdate;
285 EXTERN double aaitem;
286 EXTERN char citem[10];
288 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
289 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
290 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
291 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
293 enum loctype {neither, quadrant, sector};
309 #define DDRAY 14 // Added deathray
310 #define DDSP 15 // Added deep space probe
312 /* Define future events */
313 #define FSPY 0 // Spy event happens always (no future[] entry)
314 // can cause SC to tractor beam Enterprise
315 #define FSNOVA 1 // Supernova
316 #define FTBEAM 2 // Commander tractor beams Enterprise
317 #define FSNAP 3 // Snapshot for time warp
318 #define FBATTAK 4 // Commander attacks base
319 #define FCDBAS 5 // Commander destroys base
320 #define FSCMOVE 6 // Supercommander moves (might attack base)
321 #define FSCDBAS 7 // Supercommander destroys base
322 #define FDSPROB 8 // Move deep space probe
325 char *device[NDEVICES+1] = {
373 /* Function prototypes */
397 void finish(FINTYPE);
410 void prout(char *, ...);
411 void proutn(char *, ...);
417 char *cramlc(enum loctype, int, int);
418 double expran(double);
420 void iran8(int *, int *);
421 void iran10(int *, int *);
422 #define square(i) ((i)*(i))
423 void dropin(int, int*, int*);
427 void ram(int, int, int, int);
428 void crmena(int, int, int, int, int);
429 void deadkl(int, int, int, int, int);
432 void torpedo(double, double, int, int, double *, int, int, int);
434 void pause_game(int);
436 void snova(int, int);
438 void hittem(double *);
439 void prouts(char *, ...);
444 void drawmaps(short);
447 void usecrystals(void);
451 void attakreport(int);
455 void setwnd(WINDOW *);
457 void boom(int ii, int jj);
458 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
459 void cgetline(char *, int);
461 void setpassword(void);
462 void commandhook(char *, int);
463 void makechart(void);
464 void enqueue(char *);
466 /* mode arguments for srscan() */
468 #define SCAN_REQUEST 2
469 #define SCAN_STATUS 3
470 #define SCAN_NO_LEFTSIDE 4
472 WINDOW *fullscreen_window;
473 WINDOW *srscan_window;
474 WINDOW *report_window;
475 WINDOW *lrscan_window;
476 WINDOW *message_window;
477 WINDOW *prompt_window;
479 extern void clreol(void);
480 extern void clrscr(void);
481 extern void textcolor(int color);
482 extern void highvideo(void);
486 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
487 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
490 #define DAMAGED 128 /* marker for damaged ship in starmap */