1. The Space Thingy can now be shoved.
2. Black holes are not instant death any more, one has a chance of
getting timewarped.
Various small code cleanups are included.
We know this if either short or long range sensors are working */\r
if (game.damage[DSRSENS] == 0.0 || game.damage[DLRSENS] == 0.0 ||\r
condit == IHDOCKED) {\r
- proutn("***");\r
- cramen(ienm);\r
+ crmena(1, ienm, 2, game.kx[loccom], game.ky[loccom]);\r
proutn(" escapes to %s (and regains strength).",\r
cramlc(quadrant, iqx, iqy));\r
}\r
/* handle local matters related to escape */\r
+ game.quad[game.kx[loccom]][game.ky[loccom]] = IHDOT;\r
game.kx[loccom] = game.kx[nenhere];\r
game.ky[loccom] = game.ky[nenhere];\r
game.kavgd[loccom] = game.kavgd[nenhere];\r
if (my != 0) my = my*motion < 0 ? -1 : 1;\r
nextx = comx;\r
nexty = comy;\r
- game.quad[comx][comy] = IHDOT;\r
/* main move loop */\r
for (ll = 1; ll <= nsteps; ll++) {\r
#ifdef DEBUG\r
else break; /* done early */\r
}\r
/* Put commander in place within same quadrant */\r
+ game.quad[comx][comy] = IHDOT;\r
game.quad[nextx][nexty] = ienm;\r
if (nextx != comx || nexty != comy) {\r
/* it moved */\r
if (game.damage[DSRSENS] == 0 || condit == IHDOCKED) {\r
proutn("***");\r
cramen(ienm);\r
+ proutn(" from");\r
+ cramlc(2, comx, comy);\r
if (game.kdist[loccom] < dist1) proutn(" advances to");\r
else proutn(" retreats to ");\r
prout(cramlc(sector, nextx, nexty));\r
sortkl();\r
}\r
\r
-static int checkdest(int iqx, int iqy, int flag, int *ipage) {\r
- int i, j;\r
+static int movescom(int iqx, int iqy, int flag, int *ipage) {\r
+ int i;\r
\r
if ((iqx==quadx && iqy==quady) ||\r
iqx < 1 || iqx > 8 || iqy < 1 || iqy > 8 ||\r
for (i = 1; i <= game.state.rembase; i++)\r
if (game.state.baseqx[i]==iqx && game.state.baseqy[i]==iqy) return 1;\r
}\r
-\r
+ if (justin && !iscate) return 1;\r
/* do the move */\r
game.state.galaxy[game.state.isx][game.state.isy] -= 100;\r
game.state.isx = iqx;\r
game.state.isy = iqy;\r
game.state.galaxy[game.state.isx][game.state.isy] += 100;\r
- if (iscate) {\r
+ if (ishere) {\r
/* SC has scooted, Remove him from current quadrant */\r
iscate=0;\r
isatb=0;\r
DESTROY(&game.state.plnets[i]);\r
game.state.newstuf[game.state.isx][game.state.isy] -= 1;\r
if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED) {\r
- if (*ipage==0) pause(1);\r
+ if (*ipage==0) pause_game(1);\r
*ipage = 1;\r
prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");\r
proutn(" a planet in ");\r
/* try moving in both x and y directions */\r
iqx = game.state.isx + ideltax;\r
iqy = game.state.isy + ideltax;\r
- if (checkdest(iqx, iqy, flag, ipage)) {\r
+ if (movescom(iqx, iqy, flag, ipage)) {\r
/* failed -- try some other maneuvers */\r
if (ideltax==0 || ideltay==0) {\r
/* attempt angle move */\r
if (ideltax != 0) {\r
iqy = game.state.isy + 1;\r
- if (checkdest(iqx, iqy, flag, ipage)) {\r
+ if (movescom(iqx, iqy, flag, ipage)) {\r
iqy = game.state.isy - 1;\r
- checkdest(iqx, iqy, flag, ipage);\r
+ movescom(iqx, iqy, flag, ipage);\r
}\r
}\r
else {\r
iqx = game.state.isx + 1;\r
- if (checkdest(iqx, iqy, flag, ipage)) {\r
+ if (movescom(iqx, iqy, flag, ipage)) {\r
iqx = game.state.isx - 1;\r
- checkdest(iqx, iqy, flag, ipage);\r
+ movescom(iqx, iqy, flag, ipage);\r
}\r
}\r
}\r
else {\r
/* try moving just in x or y */\r
iqy = game.state.isy;\r
- if (checkdest(iqx, iqy, flag, ipage)) {\r
+ if (movescom(iqx, iqy, flag, ipage)) {\r
iqy = game.state.isy + ideltay;\r
iqx = game.state.isx;\r
- checkdest(iqx, iqy, flag, ipage);\r
+ movescom(iqx, iqy, flag, ipage);\r
}\r
}\r
}\r
iseenit = 0;\r
isatb=1;\r
game.future[FSCDBAS] = game.state.date + 1.0 +2.0*Rand();\r
- if (batx != 0) game.future[FSCDBAS] += game.future[FCDBAS]-game.state.date;\r
+ if (game.future[FCDBAS] < 1e30) game.future[FSCDBAS] +=\r
+ game.future[FCDBAS]-game.state.date;\r
if (game.damage[DRADIO] > 0 && condit != IHDOCKED)\r
return; /* no warning */\r
iseenit = 1;\r
- if (*ipage == 0) pause(1);\r
+ if (*ipage == 0) pause_game(1);\r
*ipage=1;\r
proutn("Lt. Uhura- \"Captain, the starbase in ");\r
proutn(cramlc(quadrant, game.state.isx, game.state.isy));\r
(game.damage[DRADIO] > 0.0 && condit != IHDOCKED) ||\r
game.starch[game.state.isx][game.state.isy] > 0))\r
return;\r
- if (*ipage==0) pause(1);\r
+ if (*ipage==0) pause_game(1);\r
*ipage = 1;\r
prout("Lt. Uhura- \"Captain, Starfleet Intelligence reports");\r
proutn(" the Super-commander is in ");\r
}\r
}\r
game.quad[ithx][ithy] = IHT;\r
+ game.kx[nenhere]=ithx;\r
+ game.ky[nenhere]=ithy;\r
\r
/* check to see if all holes plugged */\r
for (i = 1; i < 11; i++) {\r
crmena(1,IHT, 2, ithx, ithy);\r
prout(" completes web.");\r
ithere = ithx = ithy = 0;\r
+ nenhere--;\r
return;\r
}\r
shield += aaitem;\r
energy -= aaitem;\r
return;\r
+ case NONE:; /* avoid gcc warning */\r
}\r
}\r
\r
case IHC: type = 2.0; break;\r
case IHS: type = 2.5; break;\r
case IHT: type = 0.5; break;\r
+ case IHQUEST: type = 4.0; break;\r
}\r
proutn(ibumpd ? " rammed by " : " rams ");\r
crmena(0, ienm, 2, ix, iy);\r
}\r
shldup = 0;\r
if (game.state.remkl) {\r
- pause(2);\r
+ pause_game(2);\r
dreprt();\r
}\r
else finish(FWON);\r
*hit = fabs(*hit);\r
newcnd(); /* undock */\r
/* We may be displaced. */\r
- if (landed==1) return; /* Cheat if on a planet */\r
+ if (landed==1 || condit==IHDOCKED) return; /* Cheat if on a planet */\r
ang = angle + 2.5*(Rand()-0.5);\r
temp = fabs(sin(ang));\r
if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));\r
prout(" damaged but not destroyed.");\r
return;\r
}\r
- prout(" damaged--");\r
+ proutn(" damaged--");\r
game.kx[ll] = jx;\r
game.ky[ll] = jy;\r
shoved = 1;\r
break;\r
case IHB: /* Hit a base */\r
+ skip(1);\r
prout("***STARBASE DESTROYED..");\r
if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0;\r
for (ll=1; ll<=game.state.rembase; ll++) {\r
prout(" unaffected by photon blast.");\r
return;\r
case IHQUEST: /* Hit a thingy */\r
+ if (Rand()>0.7) { // Used to be certain death \r
skip(1);\r
prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");\r
skip(1);\r
prouts(" HACK! HACK! HACK! *CHOKE!* ");\r
skip(1);\r
proutn("Mr. Spock-");\r
- prouts(" \"Facinating!\"");\r
+ prouts(" \"Fascinating!\"");\r
skip(1);\r
- game.quad[ix][iy] = IHDOT;\r
- return;\r
+ deadkl(ix, iy, iquad, ix, iy);\r
+ } else {\r
+ /*\r
+ * Stas Sergeev added the possibility that\r
+ * you can shove the Thingy.\r
+ */\r
+ iqengry=1;\r
+ shoved=1;\r
+ }\r
+ return;\r
case IHBLANK: /* Black hole */\r
skip(1);\r
crmena(1, IHBLANK, 2, ix, iy);\r
prout("***Torpedo absorbed by Tholian web.");\r
return;\r
case IHT: /* Hit a Tholian */\r
- skip(1);\r
- crmena(1, IHT, 2, ix, iy);\r
h1 = 700.0 + 100.0*Rand() -\r
1000.0*sqrt(square(ix-inx)+square(iy-iny))*\r
fabs(sin(bullseye-angle));\r
ithx = ithy = 0;\r
return;\r
}\r
+ skip(1);\r
+ crmena(1, IHT, 2, ix, iy);\r
if (Rand() > 0.05) {\r
prout(" survives photon blast.");\r
return;\r
prout(" disappears.");\r
game.quad[ix][iy] = IHWEB;\r
ithere = ithx = ithy = 0;\r
+ nenhere--;\r
{\r
int dum, my;\r
dropin(IHBLANK, &dum, &my);\r
\r
static void fry(double hit) {\r
double ncrit, extradm;\r
- int ktr=1, l, ll, j, cdam[6], crptr;\r
+ int ktr=1, l, ll, j, cdam[NDEVICES+1], crptr;\r
\r
/* a critical hit occured */\r
if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return;\r
ncrit = 1.0 + hit/(500.0+100.0*Rand());\r
proutn("***CRITICAL HIT--");\r
/* Select devices and cause damage */\r
- for (l = 1; l <= ncrit; l++) {\r
+ for (l = 1; l <= ncrit && l <= NDEVICES; l++) {\r
do {\r
j = NDEVICES*Rand()+1.0;\r
/* Cheat to prevent shuttle damage unless on ship */\r
neutz = 0;\r
return;\r
}\r
- if (((comhere || ishere) && (justin == 0)) || skill == 5) movcom();\r
- if (nenhere==0) return;\r
+ if ((((comhere || ishere) && (justin == 0)) || skill == 5)&&(k!=0)) movcom();\r
+ if (nenhere==0 || (nenhere==1 && iqhere && iqengry==0)) return;\r
pfac = 1.0/inshld;\r
if (shldchg == 1) chgfac = 0.25+0.5*Rand();\r
skip(1);\r
jx = game.kx[l];\r
jy = game.ky[l];\r
iquad = game.quad[jx][jy];\r
+ if (iquad==IHT || (iquad==IHQUEST && !iqengry)) continue;\r
itflag = (iquad == IHK && r > 0.0005) || k == 0 ||\r
(iquad==IHC && r > 0.015) ||\r
(iquad==IHR && r > 0.3) ||\r
- (iquad==IHS && r > 0.07);\r
+ (iquad==IHS && r > 0.07) ||\r
+ (iquad==IHQUEST && r > 0.05);\r
if (itflag) {\r
/* Enemy uses phasers */\r
if (condit == IHDOCKED) continue; /* Don't waste the effort! */\r
crmena(0, iquad, i, jx, jy);\r
}\r
attempt = 1;\r
- prout("--");\r
+ prout(" ");\r
r = (Rand()+Rand())*0.5 -0.5;\r
r += 0.002*game.kpower[l]*r;\r
torpedo(course, r, jx, jy, &hit);\r
alldone) return; /* Supernova or finished */\r
if (hit == 0) continue;\r
}\r
- if (shldup != 0 || shldchg != 0) {\r
+ if (shldup != 0 || shldchg != 0 || condit==IHDOCKED) {\r
/* shields will take hits */\r
- double absorb, hitsh, propor = pfac*shield;\r
+ double absorb, hitsh, propor = pfac*shield*(condit==IHDOCKED ? 2.1 : 1.0);\r
if(propor < 0.1) propor = 0.1;\r
hitsh = propor*chgfac*hit+1.0;\r
atackd=1;\r
/* Killed a Tholian */\r
ithere = 0;\r
}\r
+ else if (type == IHQUEST) {\r
+ /* Killed a Thingy */\r
+ iqhere=iqengry=thingx=thingy=0;\r
+ }\r
else {\r
/* Some type of a Klingon */\r
game.state.galaxy[quadx][quady] -= 100;\r
\r
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);\r
\r
- if (type == IHT) return;\r
-\r
/* Remove enemy ship from arrays describing local conditions */\r
-\r
+ if (game.future[FCDBAS] < 1e30 && batx==quadx && baty==quady && type==IHC)\r
+ game.future[FCDBAS] = 1e30;\r
for (i=1; i<=nenhere; i++)\r
if (game.kx[i]==ix && game.ky[i]==iy) break;\r
nenhere--;\r
skip(1);\r
prout("Spock- \"Bridge to sickbay. Dr. McCoy,");\r
prout(" I recommend an immediate review of");\r
- prout(" the Captain's psychological profile.");\r
+ prout(" the Captain's psychological profile.\"");\r
chew();\r
return 1;\r
}\r
chew();\r
prout("Maximum of 3 torpedoes per burst.");\r
key = IHEOL;\r
+ return;\r
}\r
if (n <= torps) break;\r
chew();\r
int kz = 0, k=1, i; /* Cheating inhibitor */\r
int ifast=0, no=0, ipoop=1, msgflag = 1;\r
enum {NOTSET, MANUAL, FORCEMAN, AUTOMATIC} automode = NOTSET;\r
- int key;\r
+ int key=0;\r
\r
skip(1);\r
/* SR sensors and Computer */\r
key = scan();\r
}\r
if (key != IHREAL && nenhere != 0) {\r
- prout("Phasers locked on target. Energy available = %.2f", ifast?energy-200.0:energy);\r
+ prout("Phasers locked on target. Energy available: %.2f", ifast?energy-200.0:energy);\r
}\r
do {\r
while (key != IHREAL) {\r
}\r
if (aaitem < 0) {\r
/* abort out */\r
- ididit = 0;\r
chew();\r
return;\r
}\r
chew();\r
return;\r
}\r
- if (key == IHALPHA & isit("no")) {\r
+ if (key == IHALPHA && isit("no")) {\r
no = 1;\r
}\r
energy -= rpow;\r
else\r
proutn("Very small hit on ");\r
ienm = game.quad[ii][jj];\r
+ if (ienm==IHQUEST) iqengry=1;\r
crmena(0,ienm,2,ii,jj);\r
skip(1);\r
if (kpow == 0) {\r
--- /dev/null
+/****************************************************************************
+ * This is the implementation file for conio.h - a conio.h for Linux. *
+ * It uses ncurses and some internal functions of Linux to simulate the *
+ * I/O-functions. *
+ * This is copyright (c) 1996,97 by Fractor / Mental eXPlosion (MXP) *
+ * Use and distribution is only allowed if you follow the terms of the *
+ * GNU Library Public License Version 2. *
+ * Since this work is based on ncurses please read its copyright notices as *
+ * well ! *
+ * Look into the readme to this file for further information. *
+ * Thanx to SubZero / MXP for his little tutorial on the curses library ! *
+ * Many thanks to Mark Hahn and Rich Cochran for solving the inpw and inpd *
+ * mega-bug !!! *
+ * Watch out for other MXP releases, too ! *
+ * Send bugreports to: fractor@germanymail.com *
+ ****************************************************************************/
+
+#define _ISOC99_SOURCE
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/io.h>
+#include <ncurses.h>
+#include "conio.h"
+
+static attr_t txtattr,oldattr;
+static int fgc,bgc;
+char color_warning=1;
+int directvideo;
+WINDOW *conio_scr;
+
+/* Some internals... */
+static int colortab(int a) /* convert LINUX Color code to DOS-standard */
+{
+ switch(a) {
+ case 0 : return COLOR_BLACK;
+ case 1 : return COLOR_BLUE;
+ case 2 : return COLOR_GREEN;
+ case 3 : return COLOR_CYAN;
+ case 4 : return COLOR_RED;
+ case 5 : return COLOR_MAGENTA;
+ case 6 : return COLOR_YELLOW;
+ case 7 : return COLOR_WHITE;
+ }
+ return COLOR_BLACK;
+}
+
+static void docolor (int color) /* Set DOS-like text mode colors */
+{
+ wattrset(conio_scr,0); /* My curses-version needs this ... */
+ if ((color&128)==128) txtattr=A_BLINK; else txtattr=A_NORMAL;
+ if ((color&15)>7) txtattr|=A_STANDOUT; else txtattr|=A_NORMAL;
+ txtattr|=COLOR_PAIR((1+(color&7)+(color&112)) >> 1);
+ if (((color&127)==15) | ((color&127)==7)) txtattr=COLOR_PAIR(0);
+ if (((color&127)==127) | ((color&127)==119)) txtattr=COLOR_PAIR(8);
+ wattron(conio_scr,txtattr);
+ wattron(conio_scr,COLOR_PAIR(1+(color&7)+((color&112)>>1)));
+}
+
+/* Call this before any call to linux conio - except the port functions ! */
+void __attribute__((constructor)) initconio (void) /* This is needed, because ncurses needs to be initialized */
+{
+ int x,y;
+ short pair;
+ if (atexit(doneconio)){
+ fprintf(stderr,"Unable to register doneconio(), exiting...\n");
+ exit(1);
+ }
+ initscr();
+ start_color();
+// attr_get(&oldattr,&pair,NULL);
+ nonl();
+ raw();
+ if (!has_colors() & (color_warning>-1))
+ fprintf(stderr,"Attention: A color terminal may be required to run this application !\n");
+ noecho();
+ conio_scr=newwin(0,0,0,0);
+ keypad(conio_scr,TRUE);
+ meta(conio_scr,TRUE);
+ idlok(conio_scr,TRUE);
+ scrollok(conio_scr,TRUE);
+ /* Color initialization */
+ for (y=0;y<=7;y++)
+ for (x=0;x<=7;x++)
+ init_pair((8*y)+x+1, colortab(x), colortab(y));
+ wattr_get(conio_scr,&txtattr,&pair,NULL);
+ bgc=0;
+ textcolor(7);
+ textbackground(0);
+}
+
+/* Call this on exiting your program */
+void doneconio (void)
+{
+ endwin();
+}
+
+/* Here it starts... */
+void _setcursortype (int cur_t)
+{
+ curs_set(cur_t);
+ wrefresh(conio_scr);
+}
+
+char *cgets (char *str) /* ugly function :-( */
+{
+ char strng[257];
+ unsigned char i=2;
+ echo();
+ strncpy(strng,str,1);
+ wgetnstr(conio_scr,&strng[2],(int) strng[0]);
+ while (strng[i]!=0) i++;
+ i=i-2;
+ strng[1]=i;
+ memcpy(str,strng,i+3);
+ noecho();
+ return(&str[2]);
+}
+
+void clreol (void)
+{
+ wclrtoeol(conio_scr);
+ wrefresh(conio_scr);
+}
+
+void clrscr (void)
+{
+ wclear(conio_scr);
+ wmove(conio_scr,0,0);
+ wrefresh(conio_scr);
+}
+
+int cprintf (char *format, ... )
+{
+ int i;
+ char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
+ va_list argp;
+ va_start(argp,format);
+ vsprintf(buffer,format,argp);
+ va_end(argp);
+ i=waddstr(conio_scr,buffer);
+ wrefresh(conio_scr);
+ return(i);
+}
+
+void cputs (char *str)
+{
+ waddstr(conio_scr,str);
+ wrefresh(conio_scr);
+}
+
+int cscanf (const char *format, ...)
+{
+ int i;
+ char buffer[BUFSIZ]; /* See cprintf */
+ va_list argp;
+ echo();
+ if (wgetstr(conio_scr,buffer)==ERR) return(-1);
+ va_start(argp,format);
+ i=vsscanf(buffer,format,argp);
+ va_end(argp);
+ noecho();
+ return(i);
+}
+
+void delline (void)
+{
+ wdeleteln(conio_scr);
+ wrefresh(conio_scr);
+}
+
+int getche (void)
+{
+ int i;
+ echo();
+ i=wgetch(conio_scr);
+ if (i==-1) i=0;
+ noecho();
+ return(i);
+}
+
+void gettextinfo(struct text_info *inforec)
+{
+ short pair;
+ unsigned char xp,yp;
+ unsigned char x1,x2,y1,y2;
+ attr_t dattr,dnattr,a; /* The "d" stands for DOS */
+ getyx(conio_scr,yp,xp);
+ getbegyx(conio_scr,y1,x1);
+ getmaxyx(conio_scr,y2,x2);
+ dattr=(bgc*16)+fgc;
+ wattr_get(conio_scr,&a,&pair,NULL);
+ if (a==(a & A_BLINK)) dattr=dattr+128;
+ dnattr=oldattr; /* Well, this cannot be right,
+ because we don't know the COLORPAIR values from before initconio() !*/
+ inforec->winleft=x1+1;
+ inforec->wintop=y1+1;
+ if (x1==0) x2--;
+ if (y1==0) y2--;
+ inforec->winright=x1+x2+1;
+ inforec->winbottom=y1+y2+1;
+ inforec->curx=xp+1;
+ inforec->cury=yp+1;
+ inforec->screenheight=y2+1;
+ inforec->screenwidth=x2+1;
+ inforec->currmode=3; /* This is C80 */
+ inforec->normattr=dnattr; /* Don't use this ! */
+ inforec->attribute=dattr;
+}
+
+void gotoxy (int x, int y)
+{
+ y--;
+ x--;
+ wmove(conio_scr,y,x);
+ wrefresh(conio_scr);
+}
+
+void highvideo (void)
+{
+ textcolor(15); /* White */
+ textbackground(0); /* Black */
+}
+
+void insline (void)
+{
+ winsertln(conio_scr);
+ wrefresh(conio_scr);
+}
+
+int kbhit (void)
+{
+ int i;
+ nodelay(conio_scr,TRUE);
+ i=wgetch(conio_scr);
+ nodelay(conio_scr,FALSE);
+ if (i==-1) i=0;
+ return(i);
+}
+
+void lowvideo (void)
+{
+ textbackground(0); /* Black */
+ textcolor(8); /* Should be darkgray */
+}
+
+void normvideo (void)
+{
+ wattrset(conio_scr,oldattr);
+}
+
+int putch (int c)
+{
+ if (waddch(conio_scr,c)!=ERR) {
+ wrefresh(conio_scr);
+ return(c);
+ }
+ return(0);
+}
+
+void textattr (int attr)
+{
+ docolor(attr);
+}
+
+void textbackground (int color)
+{
+ bgc=color;
+ color=(bgc*16)+fgc;
+ docolor(color);
+}
+
+void textcolor (int color)
+{
+ fgc=color;
+ color=(bgc*16)+fgc;
+ docolor(color);
+}
+
+void textmode (int mode)
+{
+ /* Ignored */
+}
+
+int wherex (void)
+{
+ int y;
+ int x;
+ getyx(conio_scr,y,x);
+ x++;
+ return(x);
+}
+
+int wherey (void)
+{
+ int y;
+ int x;
+ getyx(conio_scr,y,x);
+ y++;
+ return(y);
+}
+
+void window (int left,int top,int right,int bottom)
+{
+ int nlines,ncols;
+ delwin(conio_scr);
+ top--;
+ left--;
+ right--;
+ bottom--;
+ nlines=bottom-top;
+ ncols=right-left;
+ if (top==0) nlines++;
+ if (left==0) ncols++;
+ if ((nlines<1) | (ncols<1)) return;
+ conio_scr=newwin(nlines,ncols,top,left);
+ keypad(conio_scr,TRUE);
+ meta(conio_scr,TRUE);
+ idlok(conio_scr,TRUE);
+ scrollok(conio_scr,TRUE);
+ wrefresh(conio_scr);
+}
+
+/* Linux is cool */
--- /dev/null
+/***************************************************************************/
+/** File: conio.h Date: 03/09/1997 Version: 1.02 **/
+/** --------------------------------------------------------------------- **/
+/** CONIO.H an implementation of the conio.h for Linux based on ncurses. **/
+/** This is copyright (c) 1996,97 by Fractor / Mental EXPlosion. **/
+/** If you want to copy it you must do this following the terms of the **/
+/** GNU Library Public License **/
+/** Please read the file "README" before using this library. **/
+/** --------------------------------------------------------------------- **/
+/** To use this thing you must have got the curses library. **/
+/** This thing was tested on Linux Kernel 2.0.29, GCC 2.7.2 and **/
+/** ncurses 1.9.9e which is (c) 1992-1995 by Zeyd M. Ben-Halim and Eric S.**/
+/** Raymond. **/
+/** Please also read the copyright notices for ncurses before using this !**/
+/***************************************************************************/
+
+#ifndef __linux__
+#error This conio.h was only tested to work under LINUX !
+#endif
+
+#ifndef __LINUXCONIO_H
+#define __LINUXCONIO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses.h>
+
+#define linux_conio_version 1.04
+
+extern int directvideo; /* ignored by linux conio.h */
+extern char color_warning; /* Tell the users when terminal can't display colors ? */
+extern WINDOW *conio_scr;
+
+#define _NOCURSOR 0
+#define _NORMALCURSOR 1
+
+struct text_info {
+ unsigned char winleft;
+ unsigned char wintop;
+ unsigned char winright;
+ unsigned char winbottom;
+ unsigned char attribute;
+ unsigned char normattr;
+ unsigned char currmode;
+ unsigned char screenheight;
+ unsigned char screenwidth;
+ unsigned char curx;
+ unsigned char cury;
+};
+
+enum text_modes { LASTMODE=-1, BW40=0, C40, BW80, C80, MONO=7, C4350=64 };
+
+enum COLORS {
+ BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
+ DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
+};
+
+#define BLINK 128
+
+extern void initconio(void); /* Please run this function before any other */
+extern void doneconio(void); /* Please run this function before exiting your program */
+
+extern int wherex(void);
+extern int wherey(void);
+extern int putch(int c);
+extern int getche(void);
+extern int kbhit(void);
+extern void _setcursortype(int);
+extern int cprintf(char *format, ...);
+extern int cscanf(const char *format, ...);
+
+extern unsigned inp(unsigned port);
+extern unsigned inpw(unsigned port);
+extern unsigned outp(unsigned port, unsigned value);
+extern unsigned outpw(unsigned port,unsigned value);
+extern unsigned inpd(unsigned port);
+extern unsigned outpd(unsigned port, unsigned value);
+
+extern void clreol(void);
+extern void clrscr(void);
+extern void gotoxy(int x, int y);
+extern void delline(void);
+extern void gettextinfo(struct text_info *r);
+extern void highvideo(void);
+extern void insline(void);
+extern void lowvideo(void);
+extern void normvideo(void);
+extern void textattr(int attribute);
+extern void textbackground(int color);
+extern void textcolor(int color);
+extern void textmode(int unused_mode);
+extern void window(int left, int top, int right, int bottom);
+extern void cputs(char *str);
+
+extern char *cgets(char *str);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
#include <math.h>\r
\r
void events(void) {\r
-\r
- int ictbeam=0, ipage=0, istract=0, line, i, j, k, l, ixhold, iyhold;\r
- double fintim = game.state.date + Time, datemin, xtime, repair, yank;\r
- \r
+ int ictbeam=0, ipage=0, istract=0, line, i=0, j, k, l, ixhold=0, iyhold=0;\r
+ double fintim = game.state.date + Time, datemin, xtime, repair, yank=0;\r
\r
#ifdef DEBUG\r
if (idebug) prout("EVENTS");\r
if (alldone) return;\r
datemin = fintim;\r
for (l=1; l<=NEVENTS; l++)\r
- if (game.future[l] <= datemin) {\r
+ if (game.future[l] < datemin) {\r
line = l;\r
datemin = game.future[l];\r
}\r
for (j=1; j <= 8; j++)\r
if (game.starch[i][j] > 999) game.starch[i][j] = 1;\r
if (iseenit==0) {\r
- attakreport();\r
+ attakreport(0);\r
iseenit = 1;\r
}\r
skip(1);\r
Time -= xtime;\r
switch (line) {\r
case FSNOVA: /* Supernova */\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage=1;\r
snova(0,0);\r
game.future[FSNOVA] = game.state.date + expran(0.5*intime);\r
}\r
/* tractor beaming cases merge here */\r
yank = sqrt(yank);\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage=1;\r
Time = (10.0/(7.5*7.5))*yank; /* 7.5 is yank rate (warp 7.5) */\r
ictbeam = 1;\r
newqad(0);\r
/* Adjust finish time to time of tractor beaming */\r
fintim = game.state.date+Time;\r
+ attack(0);\r
if (game.state.remcom <= 0) game.future[FTBEAM] = 1e30;\r
else game.future[FTBEAM] = game.state.date+Time+expran(1.5*intime/game.state.remcom);\r
break;\r
if (game.damage[DRADIO] != 0.0 &&\r
condit != IHDOCKED) break; /* No warning :-( */\r
iseenit = 1;\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
proutn("Lt. Uhura- \"Captain, the starbase in ");\r
prout(cramlc(quadrant, batx, baty));\r
- prout(" reports that it is under atttack and that it can");\r
+ prout(" reports that it is under attack and that it can");\r
proutn(" hold out only until stardate %d",\r
(int)game.future[FCDBAS]);\r
prout(".\"");\r
else if (game.state.rembase != 1 &&\r
(game.damage[DRADIO] <= 0.0 || condit == IHDOCKED)) {\r
/* Get word via subspace radio */\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
prout("Lt. Uhura- \"Captain, Starfleet Command reports that");\r
game.state.galaxy[probecx][probecy] == 1000) {\r
// Left galaxy or ran into supernova\r
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
proutn("Lt. Uhura- \"The deep space probe ");\r
break;\r
}\r
if (game.damage[DRADIO]==0.0 || condit == IHDOCKED) {\r
- if (ipage==0) pause(1);\r
+ if (ipage==0) pause_game(1);\r
ipage = 1;\r
skip(1);\r
proutn("Lt. Uhura- \"The deep space probe is now in ");\r
origTime = delay = aaitem;\r
if (delay <= 0.0) return;\r
if (delay >= game.state.remtime || nenhere != 0) {\r
- prout("Are you sure? ");\r
+ proutn("Are you sure? ");\r
if (ja() == 0) return;\r
}\r
\r
Time = temp;\r
}\r
if (Time < delay) attack(0);\r
- if (nenhere==0) movetho();\r
if (alldone) return;\r
events();\r
ididit = 1;\r
void nova(int ix, int iy) {\r
static double course[] =\r
{0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5};\r
- int bot, top, top2, burst, hits[11][3], kount, icx, icy, mm, nn, j;\r
+ int bot, top, top2, hits[11][3], kount, icx, icy, mm, nn, j;\r
int iquad, iquad1, i, ll, newcx, newcy, ii, jj;\r
if (Rand() < 0.05) {\r
/* Wow! We've supernova'ed */\r
double timused = game.state.date - indate;\r
int ithperd, iwon, klship;\r
\r
- pause(0);\r
+ pause_game(0);\r
\r
iskill = skill;\r
if ((timused == 0 || game.state.remkl != 0) && timused < 5.0) timused = 5.0;\r
#endif
}
-void pause(int i) {
+void pause_game(int i) {
char buf[BUFSIZ], *prompt;
if (i==1) {
if (skill > 2)
int y, x;
getyx(stdscr, y, x);
if (y == screenheight-1)
- pause(0);
+ pause_game(0);
else
waddch(stdscr, '\n');
} else {
linecount++;
if (linecount >= screenheight)
- pause(0);
+ pause_game(0);
else
putchar('\n');
}
+#include <unistd.h>\r
#include "sst.h"\r
\r
static void getcd(int, int);\r
\r
void imove(void) {\r
double angle, deltax, deltay, bigger, x, y,\r
- finald, finalx, finaly, stopegy;\r
- int trbeam = 0, n, l, ix, iy, kink, kinks, iquad;\r
+ finald, finalx, finaly, stopegy, probf;\r
+ int trbeam = 0, n, l, ix=0, iy=0, kink, kinks, iquad;\r
\r
if (inorbit) {\r
prout("Helmsman Sulu- \"Leaving standard orbit.\"");\r
quady = (iy+9)/10;\r
sectx = ix - 10*(quadx-1);\r
secty = iy - 10*(quady-1);\r
- prout("");\r
- prout("Entering %s.",\r
+ proutn("\n\rEntering %s.",\r
cramlc(quadrant, quadx, quady));\r
game.quad[sectx][secty] = ship;\r
newqad(0);\r
+ if (skill>1) attack(0);\r
return;\r
}\r
iquad = game.quad[ix][iy];\r
case IHC:\r
case IHS:\r
case IHR:\r
+ case IHQUEST:\r
sectx = ix;\r
secty = iy;\r
ram(0, iquad, sectx, secty);\r
crmshp();\r
proutn(" pulled into black hole at ");\r
prout(cramlc(sector, ix, iy));\r
- finish(FHOLE);\r
+ /*\r
+ * Getting pulled into a black \r
+ * hole was certain death in\r
+ * Almy's original. Stas \r
+ * Sergeev added a possibility\r
+ * that you'll get timewarped\r
+ * instead.\r
+ */\r
+ n=0;\r
+ for (l=1;l<=NDEVICES+1;l++)\r
+ if (game.damage[l]>0) n++;\r
+ probf=pow(1.4,(energy+shield)/5000.0-1.0)*\r
+ pow(1.3,1.0/(n+1)-1.0);\r
+ if (Rand()>probf) \r
+ timwrp();\r
+ else \r
+ finish(FHOLE);\r
return;\r
default:\r
/* something else */\r
return;\r
}\r
\r
-void dock(void) {\r
+void dock(int l) {\r
chew();\r
- if (condit == IHDOCKED) {\r
+ if (condit == IHDOCKED && l) {\r
prout("Already docked.");\r
return;\r
}\r
(game.future[FCDBAS] < 1e30 || isatb == 1) && iseenit == 0) {\r
/* get attack report from base */\r
prout("Lt. Uhura- \"Captain, an important message from the starbase:\"");\r
- attakreport();\r
+ attakreport(0);\r
iseenit = 1;\r
}\r
}\r
are always displayed y - x, where +y is downward! */\r
\r
\r
- int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key;\r
+ int irowq=quadx, icolq=quady, irows, icols, itemp=0, iprompt=0, key=0;\r
double xi, xj, xk, xl;\r
double deltax, deltay;\r
int automatic = -1;\r
if (Time >= game.state.remtime) {\r
prout("First Officer Spock- \"Captain, our speed under impulse");\r
prout("power is only 0.95 sectors per stardate. Are you sure");\r
- prout("we dare spend the time?\"");\r
+ proutn("we dare spend the time?\" ");\r
if (ja() == 0) return;\r
}\r
/* Activate impulse engines and pay the cost */\r
proutn(" a trip would require approximately %2.0f",\r
100.0*Time/game.state.remtime);\r
prout(" percent of our");\r
- prout(" remaining time. Are you sure this is wise?\"");\r
- if (ja() == 0) { ididit = 0; return;}\r
+ proutn(" remaining time. Are you sure this is wise?\" ");\r
+ if (ja() == 0) { ididit = 0; Time=0; return;}\r
}\r
}\r
/* Entry WARPX */\r
\r
while ((key=scan()) == IHEOL) {\r
chew();\r
- proutn("Warp factor-");\r
+ proutn("Warp factor- ");\r
}\r
chew();\r
if (key != IHREAL) {\r
warpfac = aaitem;\r
wfacsq=warpfac*warpfac;\r
if (warpfac <= oldfac || warpfac <= 6.0) {\r
- proutn("Helmsman Sulu- \"Warp factor %do, Captain.\"", \r
+ proutn("Helmsman Sulu- \"Warp factor %d, Captain.\"", \r
(int)warpfac);\r
return;\r
}\r
key = scan();\r
}\r
else if (key == IHEOL) {\r
- proutn("Arm NOVAMAX warhead?");\r
+ proutn("Arm NOVAMAX warhead? ");\r
isarmed = ja();\r
}\r
getcd(TRUE, key);\r
sectx=ix;\r
secty=iy;\r
game.quad[ix][iy]=ship;\r
- dock();\r
+ dock(0);\r
skip(1);\r
prout("Lt. Uhura- \"Captain, we made it!\"");\r
return;\r
}\r
prout("Spock- \"Captain, the 'Experimental Death Ray'");\r
prout(" is highly unpredictible. Considering the alternatives,");\r
- prout(" are you sure this is wise?\" ");\r
+ proutn(" are you sure this is wise?\" ");\r
if (ja()==0) return;\r
prout("Spock- \"Acknowledged.\"");\r
skip(1);\r
#include <stdlib.h>\r
#include <string.h>\r
\r
-void attakreport(void) {\r
+void attakreport(int l) {\r
+ if (!l) {\r
if (game.future[FCDBAS] < 1e30) {\r
- prout("Starbase in %s is currently under attack.",\r
+ prout("Starbase in %s is currently under Commander attack.",\r
cramlc(quadrant, batx, baty));\r
prout("It can hold out until Stardate %d.", \r
(int)game.future[FCDBAS]);\r
prout("It can hold out until Stardate %d.", \r
(int)game.future[FSCDBAS]);\r
}\r
+ } else {\r
+ if (game.future[FCDBAS] < 1e30)\r
+ proutn("Base in %i - %i attacked by C. Alive until %.1f", batx, baty, game.future[FCDBAS]);\r
+ if (isatb == 1)\r
+ proutn("Base in %i - %i attacked by S. Alive until %.1f", game.state.isx, game.state.isy, game.future[FSCDBAS]);\r
+ }\r
}\r
\r
\r
if (game.damage[DRADIO] == 0.0 || condit == IHDOCKED || iseenit) {\r
/* Don't report this if not seen and\r
either the radio is dead or not at base! */\r
- attakreport();\r
+ attakreport(0);\r
iseenit = 1;\r
}\r
if (casual) prout("%d casualt%s suffered so far.",\r
}\r
if (icrystl) {\r
if (cryprob <= .05)\r
- prout("Dilithium crystals aboard ship...not yet used.");\r
+ prout("Dilithium crystals aboard ship... not yet used.");\r
else {\r
int i=0;\r
double ai = 0.05;\r
proutn(" Klingons Left %d", game.state.remkl);\r
break;\r
case 10:\r
- proutn(" Time Left %.2f", game.state.remtime);\r
+ attakreport(1);\r
break;\r
}\r
\r
}\r
ix2 = aaitem + 0.5;\r
}\r
- else { // same quadrant\r
- ix2 = ix1;\r
- iy2 = iy1;\r
- ix1 = quady; // ya got me why x and y are reversed!\r
- iy1 = quadx;\r
+ else {\r
+ if (quady>ix1) ix2 = 1;\r
+ else ix2=10;\r
+ if (quadx>iy1) iy2 = 1;\r
+ else iy2=10;\r
}\r
\r
if (ix1 > 8 || ix1 < 1 || iy1 > 8 || iy1 < 1 ||\r
}\r
\r
\r
-void thaw(void) {\r
- char *x, *y;\r
+int thaw(void) {\r
FILE *fp;\r
- int key;\r
+ int key;\r
\r
game.passwd[0] = '\0';\r
if ((key = scan()) == IHEOL) {\r
}\r
if (key != IHALPHA) {\r
huh();\r
- return;\r
+ return 1;\r
}\r
chew();\r
if (strchr(citem, '.') == NULL) {\r
proutn("Can't find game file ");\r
proutn(citem);\r
skip(1);\r
- return;\r
+ return 1;\r
}\r
fread(&game, sizeof(game), 1, fp);\r
if (strcmp(game.magic, SSTMAGIC)) {\r
prout("Game file format is bad, should begin with " SSTMAGIC);\r
skip(1);\r
- return;\r
+ fclose(fp);\r
+ return 1;\r
}\r
\r
fclose(fp);\r
\r
- /* I hope that's enough! */\r
+ return 0;\r
}\r
\r
void abandn(void) {\r
void setup(int needprompt) {\r
int i,j, krem, klumper;\r
int ix, iy;\r
- alldone = gamewon = 0;\r
#ifdef DEBUG\r
idebug = 0;\r
#endif\r
// Decide how many of everything\r
if (choose(needprompt)) return; // frozen game\r
// Prepare the Enterprise\r
+ alldone = gamewon = 0;\r
ship = IHE;\r
energy = inenrg = 5000.0;\r
shield = inshld = 2500.0;\r
game.state.date = indate = 100.0*(int)(31.0*Rand()+20.0);\r
game.state.killk = game.state.killc = nkinks = nhelp = resting = casual = game.state.nromkl = 0;\r
isatb = iscate = imine = icrystl = icraft = game.state.nsckill = game.state.nplankl = 0;\r
+ game.state.starkl = game.state.basekl = 0;\r
iscraft = 1;\r
landed = -1;\r
alive = 1;\r
game.state.galaxy[ix][iy] += 100;\r
}\r
// Place thing (in tournament game, thingx == -1, don't want one!)\r
- if (Rand() < 0.1 && thingx != -1) {\r
+ if (thingx != -1) {\r
iran8(&thingx, &thingy);\r
}\r
else {\r
}\r
\r
// idate = date;\r
- skip(3);\r
+ skip(2);\r
game.state.snap = 0;\r
\r
if (skill == 1) {\r
prout("Good Luck!");\r
if (game.state.nscrem) prout(" YOU'LL NEED IT.");\r
newqad(0);\r
- if (nenhere) shldup=1.0;\r
+ if (nenhere-iqhere-ithere) shldup=1.0;\r
if (neutz) attack(0); // bad luck to start in a Romulan Neutral Zone\r
}\r
\r
landed = -1;\r
ientesc = 0;\r
ithere = 0;\r
+ iqhere=0;\r
+ iqengry=0;\r
iseenit = 0;\r
if (iscate) {\r
// Attempt to escape Super-commander, so tbeam back!\r
// Position Starship\r
game.quad[sectx][secty] = ship;\r
\r
- // Decide if quadrant needs a Tholian\r
- if ((skill < 3 && Rand() <= 0.02) || /* Lighten up if skill is low */\r
- (skill == 3 && Rand() <= 0.05) ||\r
- (skill > 3 && Rand() <= 0.08)\r
-#ifdef DEBUG\r
- || strcmp(game.passwd, "tholianx")==0\r
-#endif\r
- ) {\r
- do {\r
- ithx = Rand() > 0.5 ? 10 : 1;\r
- ithy = Rand() > 0.5 ? 10 : 1;\r
- } while (game.quad[ithx][ithy] != IHDOT);\r
- game.quad[ithx][ithy] = IHT;\r
- ithere = 1;\r
- /* Reserve unocupied corners */\r
- if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';\r
- if (game.quad[1][10]==IHDOT) game.quad[1][10] = 'X';\r
- if (game.quad[10][1]==IHDOT) game.quad[10][1] = 'X';\r
- if (game.quad[10][10]==IHDOT) game.quad[10][10] = 'X';\r
- }\r
-\r
if (quadnum >= 100) {\r
// Position ordinary Klingons\r
quadnum -= 100*klhere;\r
if (quadx == game.state.isx && quady == game.state.isy) {\r
game.quad[game.kx[1]][game.ky[1]] = IHS;\r
game.kpower[1] = 1175.0 + 400.0*Rand() + 125.0*skill;\r
- iscate = 1;\r
+ iscate = game.state.remkl>1;\r
ishere = 1;\r
}\r
}\r
for (i = 1; i <= quadnum; i++) dropin(IHSTAR, &ix, &iy);\r
\r
// Check for RNZ\r
- if (irhere > 0 && klhere == 0 && basex == 0) {\r
+ if (irhere > 0 && klhere == 0) {\r
neutz = 1;\r
if (game.damage[DRADIO] <= 0.0) {\r
skip(1);\r
// Put in THING if needed\r
if (thingx == quadx && thingy == quady) {\r
dropin(IHQUEST, &ix, &iy);\r
- thingx = thingy = 0; // Transient\r
+ iran8(&thingx, &thingy);\r
+ nenhere++;\r
+ iqhere=1;\r
+ game.kx[nenhere] = ix;\r
+ game.ky[nenhere] = iy;\r
+ game.kdist[nenhere] = game.kavgd[nenhere] =\r
+ sqrt(square(sectx-ix) + square(secty-iy));\r
+ game.kpower[nenhere] = Rand()*6000.0 +500.0 +250.0*skill;\r
if (game.damage[DSRSENS] == 0.0) {\r
skip(1);\r
prout("MR. SPOCK- \"Captain, this is most unusual.");\r
}\r
}\r
\r
+ // Decide if quadrant needs a Tholian\r
+ if ((skill < 3 && Rand() <= 0.02) || /* Lighten up if skill is low */\r
+ (skill == 3 && Rand() <= 0.05) ||\r
+ (skill > 3 && Rand() <= 0.08)\r
+#ifdef DEBUG\r
+ || strcmp(passwd, "tholianx")==0\r
+#endif\r
+ ) {\r
+ do {\r
+ ithx = Rand() > 0.5 ? 10 : 1;\r
+ ithy = Rand() > 0.5 ? 10 : 1;\r
+ } while (game.quad[ithx][ithy] != IHDOT);\r
+ game.quad[ithx][ithy] = IHT;\r
+ ithere = 1;\r
+ nenhere++;\r
+ game.kx[nenhere] = ithx;\r
+ game.ky[nenhere] = ithy;\r
+ game.kdist[nenhere] = game.kavgd[nenhere] =\r
+ sqrt(square(sectx-ithx) + square(secty-ithy));\r
+ game.kpower[nenhere] = Rand()*400.0 +100.0 +25.0*skill;\r
+ /* Reserve unocupied corners */\r
+ if (game.quad[1][1]==IHDOT) game.quad[1][1] = 'X';\r
+ if (game.quad[1][10]==IHDOT) game.quad[1][10] = 'X';\r
+ if (game.quad[10][1]==IHDOT) game.quad[10][1] = 'X';\r
+ if (game.quad[10][10]==IHDOT) game.quad[10][10] = 'X';\r
+ }\r
+ sortkl();\r
+\r
// Put in a few black holes\r
for (i = 1; i <= 3; i++)\r
if (Rand() > 0.5) dropin(IHBLANK, &ix, &iy);\r
\r
// The author liked bubble sort. So we will use it. :-(\r
\r
- if (nenhere < 2) return;\r
+ if (nenhere-iqhere-ithere < 2) return;\r
\r
do {\r
sw = FALSE;\r
}\r
break;\r
case 6: // dock\r
- dock();\r
+ dock(1);\r
+ if (ididit) attack(0);\r
break;\r
case 7: // damages\r
dreprt();\r
case IHBLANK: s = "Black hole"; break;\r
case IHT: s = "Tholian"; break;\r
case IHWEB: s = "Tholian web"; break;\r
+ case IHQUEST: s = "Stranger"; break;\r
default: s = "Unknown??"; break;\r
}\r
proutn(s);\r
}\r
if (isdigit(*linep) || *linep=='+' || *linep=='-' || *linep=='.') {\r
// treat as a number\r
+ i = 0;\r
if (sscanf(linep, "%lf%n", &aaitem, &i) < 1) {\r
linep = line; // Invalid numbers are ignored\r
*linep = 0;\r
}\r
}\r
\r
-double square(double i) { return i*i; }\r
- \r
void huh(void) {\r
chew();\r
skip(1);\r
batx,\r
baty,\r
ithere,\r
+ iqhere,\r
+ iqengry,\r
ithx,\r
ithy,\r
iseenit,\r
#define ishere game.ishere // Super-commander in quandrant\r
#define neutz game.neutz // Romulan Neutral Zone\r
#define irhere game.irhere // Romulans in quadrant\r
+#define iqhere game.iqhere // Thing in quadrant\r
+#define iqengry game.iqengry // Thing attacking\r
#define icraft game.icraft // Kirk in Galileo\r
#define ientesc game.ientesc // Attempted escape from supercommander\r
#define iscraft game.iscraft // =1 if craft on ship, -1 if removed from game\r
#define IHYELLOW 'Y'\r
#define IHRED 'R'\r
#define IHDOCKED 'D'\r
+#define IHDEAD 'Z'\r
+#define IHMATER0 '-'\r
+#define IHMATER1 'o'\r
+#define IHMATER2 '0'\r
\r
\r
/* Function prototypes */\r
void photon(void);\r
void warp(int);\r
void doshield(int);\r
-void dock(void);\r
+void dock(int);\r
void dreprt(void);\r
void chart(int);\r
void impuls(void);\r
void dstrct(void);\r
void kaboom(void);\r
void freeze(int);\r
-void thaw(void);\r
+int thaw(void);\r
void plaque(void);\r
int scan(void);\r
#define IHEOL (0)\r
double Rand(void);\r
void iran8(int *, int *);\r
void iran10(int *, int *);\r
-double square(double);\r
+#define square(i) ((i)*(i))\r
void dropin(int, int*, int*);\r
void newcnd(void);\r
void sortkl(void);\r
void movcom(void);\r
void torpedo(double, double, int, int, double *);\r
void huh(void);\r
-void pause(int);\r
+void pause_game(int);\r
void nova(int, int);\r
void snova(int, int);\r
void scom(int *);\r
void shuttle(void);\r
void deathray(void);\r
void debugme(void);\r
-void attakreport(void);\r
+void attakreport(int);\r
void movetho(void);\r
void probe(void);\r
void clearscreen(void);\r
--- /dev/null
+#include <stdarg.h>
+#include <ncurses/ncurses.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <linux/kd.h>
+
+#include "sstlinux.h"
+
+static int fd = 0;
+
+int c_printf (char *format, ... )
+{
+ char buffer[BUFSIZ]; /* Well, BUFSIZ is from ncurses... */
+ va_list argp;
+ va_start(argp,format);
+ vsprintf(buffer,format,argp);
+ va_end(argp);
+ return waddstr(conio_scr,buffer);
+}
+
+void sound(unsigned int freq)
+{
+ if(fd==0) fd=open("/dev/console", O_RDONLY);
+ if(fd>0) ioctl(fd, KDMKTONE, 1193180/freq + (0xFFFF<<16));
+}
+
+void nosound(void)
+{
+ if(fd>0) ioctl(fd, KDMKTONE, 0);
+}
--- /dev/null
+#ifndef __SSTLINUX_H
+#define __SSTLINUX_H
+
+int c_printf (char *format, ... );
+void sound(unsigned int);
+void nosound(void);
+
+extern WINDOW *conio_scr;
+
+#define delay(x) usleep(x*1000)
+#define randomize() srand((unsigned)time(NULL))
+
+#endif