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 the galaxy array are encoded.
63 * Someday these should turn into structure fields.
65 #define SUPERNOVA_PLACE 1000
66 #define KLINGON_PLACE 100
69 #define KLINGONS(n) ((n)/KLINGON_PLACE)
70 #define BASES(n) (((n)%KLINGON_PLACE)/BASE_PLACE)
71 #define STARS(n) ((n)%BASE_PLACE)
72 #define NOEXIT(s) ((s) > 899) /* supernova or >8 Klingons */
75 #define ROMULAN_PLACE 10
76 #define ROMULANS(n) ((n)/ROMULAN_PLACE)
79 #define CHART_UNKNOWN -1
82 #define SKILL_NOVICE 1
85 #define SKILL_EXPERT 4
86 #define SKILL_EMERITUS 5
88 // Scalar variables that are needed for freezing the game
89 // are placed in a structure. #defines are used to access by their
90 // original names. Gee, I could have done this with the d structure,
91 // but I just didn't think of it back when I started.
93 #define SSTMAGIC "SST2.0\n"
95 EXTERN WINDOW *curwnd;
98 char magic[sizeof(SSTMAGIC)];
101 char quad[QUADSIZE+1][QUADSIZE+1]; // contents of our quadrant
102 double kpower[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy energy levels
103 double kdist[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy distances
104 double kavgd[(QUADSIZE+1)*(QUADSIZE+1)]; // average distances
105 double damage[NDEVICES+1]; // damage encountered
106 double future[NEVENTS+1]; // future events
107 char passwd[10]; // Self Destruct password
108 int kx[(QUADSIZE+1)*(QUADSIZE+1)]; // enemy sector locations
109 int ky[(QUADSIZE+1)*(QUADSIZE+1)];
110 int starch[GALSIZE+1][GALSIZE+1]; // star chart
111 /* members with macro definitions start here */
203 #define inkling game.inkling // Initial number of klingons
204 #define inbase game.inbase // Initial number of bases
205 #define incom game.incom // Initian number of commanders
206 #define instar game.instar // Initial stars
207 #define intorps game.intorps // Initial/Max torpedoes
208 #define condit game.condit // Condition (red, yellow, green docked)
209 #define torps game.torps // number of torpedoes
210 #define ship game.ship // Ship type -- 'E' is Enterprise
211 #define quadx game.quadx // where we are
212 #define quady game.quady //
213 #define sectx game.sectx // where we are
214 #define secty game.secty //
215 #define length game.length // length of game
216 #define skill game.skill // skill level
217 #define basex game.basex // position of base in current quad
218 #define basey game.basey //
219 #define klhere game.klhere // klingons here
220 #define comhere game.comhere // commanders here
221 #define casual game.casual // causalties
222 #define nhelp game.nhelp // calls for help
223 #define nkinks game.nkinks //
224 #define ididit game.ididit // Action taken -- allows enemy to attack
225 #define gamewon game.gamewon // Finished!
226 #define alive game.alive // We are alive (not killed)
227 #define justin game.justin // just entered quadrant
228 #define alldone game.alldone // game is now finished
229 #define shldchg game.shldchg // shield is changing (affects efficiency)
230 #define thingx game.thingx // location of strange object in galaxy
231 #define thingy game.thingy //
232 #define plnetx game.plnetx // location of planet in quadrant
233 #define plnety game.plnety //
234 #define inorbit game.inorbit // orbiting
235 #define landed game.landed // party on planet (1), on ship (-1)
236 #define iplnet game.iplnet // planet # in quadrant
237 #define imine game.imine // mining
238 #define inplan game.inplan // initial planets
239 #define nenhere game.nenhere // Number of enemies in quadrant
240 #define ishere game.ishere // Super-commander in quandrant
241 #define neutz game.neutz // Romulan Neutral Zone
242 #define irhere game.irhere // Romulans in quadrant
243 #define iqhere game.iqhere // Thing in quadrant
244 #define iqengry game.iqengry // Thing attacking
245 #define icraft game.icraft // Kirk in Galileo
246 #define ientesc game.ientesc // Attempted escape from supercommander
247 #define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game
248 #define isatb game.isatb // =1 if SuperCommander is attacking base
249 #define iscate game.iscate // Super Commander is here
251 #define idebug game.idebug // Debug mode
253 #define iattak game.iattak // attack recursion elimination (was cracks[4])
254 #define icrystl game.icrystl // dilithium crystals aboard
255 #define tourn game.tourn // Tournament number
256 #define thawed game.thawed // Thawed game
257 #define batx game.batx // Base coordinates being attacked
258 #define baty game.baty //
259 #define ithere game.ithere // Tholean is here
260 #define ithx game.ithx // coordinates of tholean
261 #define ithy game.ithy
262 #define iseenit game.iseenit // Seen base attack report
263 #define inresor game.inresor // initial resources
264 #define intime game.intime // initial time
265 #define inenrg game.inenrg // Initial/Max Energy
266 #define inshld game.inshld // Initial/Max Shield
267 #define inlsr game.inlsr // initial life support resources
268 #define indate game.indate // Initial date
269 #define energy game.energy // Energy level
270 #define shield game.shield // Shield level
271 #define shldup game.shldup // Shields are up
272 #define warpfac game.warpfac // Warp speed
273 #define wfacsq game.wfacsq // squared warp factor
274 #define lsupres game.lsupres // life support reserves
275 #define dist game.dist // movement distance
276 #define direc game.direc // movement direction
277 #define Time game.Time // time taken by current operation
278 #define docfac game.docfac // repair factor when docking (constant?)
279 #define resting game.resting // rest time
280 #define damfac game.damfac // damage factor
281 #define stdamtim game.stdamtim // time that star chart was damaged
282 #define cryprob game.cryprob // probability that crystal will work
283 #define probex game.probex // location of probe
284 #define probey game.probey
285 #define probecx game.probecx // current probe quadrant
286 #define probecy game.probecy
287 #define probeinx game.probeinx // Probe x,y increment
288 #define probeiny game.probeiny
289 #define proben game.proben // number of moves for probe
290 #define isarmed game.isarmed // Probe is armed
291 #define nprobes game.nprobes // number of probes available
293 /* the following global state doesn't need to be saved */
294 EXTERN char *device[NDEVICES+1];
295 EXTERN int iscore, iskill; // Common PLAQ
296 EXTERN double perdate;
297 EXTERN double aaitem;
298 EXTERN char citem[10];
300 typedef enum {FWON, FDEPLETE, FLIFESUP, FNRG, FBATTLE,
301 FNEG3, FNOVA, FSNOVAED, FABANDN, FDILITHIUM,
302 FMATERIALIZE, FPHASER, FLOST, FMINING, FDPLANET,
303 FPNOVA, FSSC, FSTRACTOR, FDRAY, FTRIBBLE,
305 enum loctype {neither, quadrant, sector};
321 #define DDRAY 14 // Added deathray
322 #define DDSP 15 // Added deep space probe
324 /* Define future events */
325 #define FSPY 0 // Spy event happens always (no future[] entry)
326 // can cause SC to tractor beam Enterprise
327 #define FSNOVA 1 // Supernova
328 #define FTBEAM 2 // Commander tractor beams Enterprise
329 #define FSNAP 3 // Snapshot for time warp
330 #define FBATTAK 4 // Commander attacks base
331 #define FCDBAS 5 // Commander destroys base
332 #define FSCMOVE 6 // Supercommander moves (might attack base)
333 #define FSCDBAS 7 // Supercommander destroys base
334 #define FDSPROB 8 // Move deep space probe
337 char *device[NDEVICES+1] = {
385 /* Function prototypes */
409 void finish(FINTYPE);
422 void prout(char *, ...);
423 void proutn(char *, ...);
429 char *cramlc(enum loctype, int, int);
430 double expran(double);
432 void iran(int, int *, int *);
433 #define square(i) ((i)*(i))
434 void dropin(int, int*, int*);
438 void ram(int, int, int, int);
439 void crmena(int, int, int, int, int);
440 void deadkl(int, int, int, int, int);
443 void torpedo(double, double, int, int, double *, int, int, int);
445 void pause_game(int);
447 void snova(int, int);
449 void hittem(double *);
450 void prouts(char *, ...);
455 void drawmaps(short);
458 void usecrystals(void);
462 void attakreport(int);
466 void setwnd(WINDOW *);
468 void boom(int ii, int jj);
469 void tracktorpedo(int x, int y, int ix, int iy, int wait, int l, int i, int n, int iquad);
470 void cgetline(char *, int);
472 void setpassword(void);
473 void commandhook(char *, int);
474 void makechart(void);
475 void enqueue(char *);
477 /* mode arguments for srscan() */
479 #define SCAN_REQUEST 2
480 #define SCAN_STATUS 3
481 #define SCAN_NO_LEFTSIDE 4
483 WINDOW *fullscreen_window;
484 WINDOW *srscan_window;
485 WINDOW *report_window;
486 WINDOW *lrscan_window;
487 WINDOW *message_window;
488 WINDOW *prompt_window;
490 extern void clreol(void);
491 extern void clrscr(void);
492 extern void textcolor(int color);
493 extern void highvideo(void);
497 BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
498 DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
501 #define DAMAGED 128 /* marker for damaged ship in starmap */