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