X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.c;h=5fc099739e6b9aaaba8fa67de1ce427f04d0606c;hp=b3a0202663bd5d6760366c82f8a1bf73d4f24545;hb=03ea69145938e4b01e7efc6be80a543bad1739c7;hpb=dd95aad0a184fc4f2ab4cd13323a70c9833acc2b diff --git a/sst.c b/sst.c index b3a0202..5fc0997 100644 --- a/sst.c +++ b/sst.c @@ -6,9 +6,11 @@ #include #endif #include - -int getch(void); +#ifndef SSTDOC +#define SSTDOC "sst.doc" +#endif + static char line[128], *linep = line; static int linecount; /* for paging */ static int screenheight = 24; @@ -40,7 +42,7 @@ static void clearscreen(void); 2. deathray improvement (but keeping original failure alternatives) 3. Tholian Web - +s 4. Enemies can ram the Enterprise. Regular Klingons and Romulans can move in Expert and Emeritus games. This code could use improvement. @@ -135,7 +137,7 @@ static void helpme(void) { cmdbuf[j] = toupper(commands[i][j]); cmdbuf[j] = '\0'; } - fp = fopen("sst.doc", "r"); + fp = fopen(SSTDOC, "r"); if (fp == NULL) { prout("Spock- \"Captain, that information is missing from the"); prout(" computer. You need to find SST.DOC and put it in the"); @@ -164,8 +166,7 @@ static void helpme(void) { while (fgets(linebuf, sizeof(linebuf),fp)) { if (strstr(linebuf, "******")) break; - /* use fputs here to avoid % expansion */ - fputs(linebuf, stdout); + proutc(linebuf); } fclose(fp); } @@ -361,19 +362,16 @@ int main(int argc, char **argv) { if (LINES) screenheight = atoi(LINES); + line[0] = '\0'; if (argc > 1) { - fromcommandline = 1; - line[0] = '\0'; while (--argc > 0) { strcat(line, *(++argv)); strcat(line, " "); } } - else fromcommandline = 0; - while (TRUE) { /* Play a game */ - setup(); + setup(line[0] == '\0'); if (alldone) { score(); alldone = 0; @@ -549,29 +547,33 @@ static void clearscreen(void) { extern void clrscr(void); clrscr(); #else - proutn("\033[2J"); /* Hope for an ANSI display */ + // proutn("\033[2J"); /* Hope for an ANSI display */ + /* much more in that old-time TTY spirit to just throw linefeeds */ + int i; + for (i = 0; i < screenheight; i++) + putchar('\n'); #endif } /* We will pull these out in case we want to do something special later */ void pause(int i) { + char buf[BUFSIZ]; putchar('\n'); if (i==1) { if (skill > 2) prout("[ANOUNCEMENT ARRIVING...]"); else - prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- HIT SPACE BAR TO CONTINUE]"); - getch(); + prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]"); } else { - if (skill > 2) - proutn("[CONTINUE?]"); - else - proutn("[HIT SPACE BAR TO CONTINUE]"); - getch(); - proutn("\r \r"); + if (skill > 2) + proutn("[CONTINUE?]"); + else + proutn("[PRESS ENTER TO CONTINUE]"); + } + fgets(buf, sizeof(buf), stdin); if (i != 0) { clearscreen(); } @@ -605,6 +607,12 @@ void prout(char *fmt, ...) { skip(1); } +void proutc(char *line) { + line[strlen(line)-1] = '\0'; + fputs(line, stdout); + skip(1); +} + void prouts(char *fmt, ...) { clock_t endTime; char *s, buf[BUFSIZ];