Get rid of linux.c and os2.c, code is pure ANSI now.
[super-star-trek.git] / sst.c
diff --git a/sst.c b/sst.c
index ae209e2cb373ed7cf7ad8a156e1fbf01b55bc092..ee5bd3eeb3c64ca443c67fc1696a015ec752df79 100644 (file)
--- a/sst.c
+++ b/sst.c
@@ -11,8 +11,6 @@
 #define SSTDOC "sst.doc"\r
 #endif\r
        \r
 #define SSTDOC "sst.doc"\r
 #endif\r
        \r
-int getch(void);\r
-\r
 static char line[128], *linep = line;\r
 static int linecount;  /* for paging */\r
 static int screenheight = 24;\r
 static char line[128], *linep = line;\r
 static int linecount;  /* for paging */\r
 static int screenheight = 24;\r
@@ -44,7 +42,7 @@ static void clearscreen(void);
    2. deathray improvement (but keeping original failure alternatives)\r
 \r
    3. Tholian Web\r
    2. deathray improvement (but keeping original failure alternatives)\r
 \r
    3. Tholian Web\r
-\r
+s\r
    4. Enemies can ram the Enterprise. Regular Klingons and Romulans can\r
       move in Expert and Emeritus games. This code could use improvement.\r
 \r
    4. Enemies can ram the Enterprise. Regular Klingons and Romulans can\r
       move in Expert and Emeritus games. This code could use improvement.\r
 \r
@@ -168,8 +166,7 @@ static void helpme(void) {
        while (fgets(linebuf, sizeof(linebuf),fp)) {\r
                if (strstr(linebuf, "******"))\r
                        break;\r
        while (fgets(linebuf, sizeof(linebuf),fp)) {\r
                if (strstr(linebuf, "******"))\r
                        break;\r
-               /* use fputs here to avoid % expansion */\r
-               fputs(linebuf, stdout);\r
+               proutc(linebuf);\r
        }\r
        fclose(fp);\r
 }\r
        }\r
        fclose(fp);\r
 }\r
@@ -365,19 +362,16 @@ int main(int argc, char **argv) {
        if (LINES)\r
            screenheight = atoi(LINES);\r
 \r
        if (LINES)\r
            screenheight = atoi(LINES);\r
 \r
+       line[0] = '\0';\r
        if (argc > 1) {\r
        if (argc > 1) {\r
-               fromcommandline = 1;\r
-               line[0] = '\0';\r
                while (--argc > 0) {\r
                        strcat(line, *(++argv));\r
                        strcat(line, " ");\r
                }\r
        }\r
                while (--argc > 0) {\r
                        strcat(line, *(++argv));\r
                        strcat(line, " ");\r
                }\r
        }\r
-       else fromcommandline = 0;\r
-\r
 \r
        while (TRUE) { /* Play a game */\r
 \r
        while (TRUE) { /* Play a game */\r
-               setup();\r
+               setup(line[0] == '\0');\r
                if (alldone) {\r
                        score();\r
                        alldone = 0;\r
                if (alldone) {\r
                        score();\r
                        alldone = 0;\r
@@ -434,7 +428,7 @@ char *cramlc(enum loctype key, int x, int y) {
 void crmena(int i, int enemy, int key, int x, int y) {\r
        if (i == 1) proutn("***");\r
        cramen(enemy);\r
 void crmena(int i, int enemy, int key, int x, int y) {\r
        if (i == 1) proutn("***");\r
        cramen(enemy);\r
-       proutn(" at");\r
+       proutn(" at ");\r
        proutn(cramlc(key, x, y));\r
 }\r
 \r
        proutn(cramlc(key, x, y));\r
 }\r
 \r
@@ -553,29 +547,33 @@ static void clearscreen(void) {
        extern void clrscr(void);\r
        clrscr();\r
 #else\r
        extern void clrscr(void);\r
        clrscr();\r
 #else\r
-       proutn("\033[2J");      /* Hope for an ANSI display */\r
+       // proutn("\033[2J");   /* Hope for an ANSI display */\r
+       /* much more in that old-time TTY spirit to just throw linefeeds */\r
+       int i;\r
+       for (i = 0; i < screenheight; i++)\r
+           putchar('\n');\r
 #endif\r
 }\r
 \r
 /* We will pull these out in case we want to do something special later */\r
 \r
 void pause(int i) {\r
 #endif\r
 }\r
 \r
 /* We will pull these out in case we want to do something special later */\r
 \r
 void pause(int i) {\r
+       char buf[BUFSIZ];\r
        putchar('\n');\r
        if (i==1) {\r
                if (skill > 2)\r
                        prout("[ANOUNCEMENT ARRIVING...]");\r
                else\r
        putchar('\n');\r
        if (i==1) {\r
                if (skill > 2)\r
                        prout("[ANOUNCEMENT ARRIVING...]");\r
                else\r
-                       prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- HIT SPACE BAR TO CONTINUE]");\r
-               getch();\r
+                       prout("[IMPORTANT ANNOUNCEMENT ARRIVING -- PRESS ENTER TO CONTINUE]");\r
        }\r
        else {\r
        }\r
        else {\r
-               if (skill > 2)\r
-                       proutn("[CONTINUE?]");\r
-               else\r
-                       proutn("[HIT SPACE BAR TO CONTINUE]");\r
-               getch();\r
-               proutn("\r                           \r");\r
+               if (skill > 2)\r
+                       proutn("[CONTINUE?]");\r
+               else\r
+                       proutn("[PRESS ENTER TO CONTINUE]");\r
+\r
        }\r
        }\r
+       fgets(buf, sizeof(buf), stdin);\r
        if (i != 0) {\r
                clearscreen();\r
        }\r
        if (i != 0) {\r
                clearscreen();\r
        }\r
@@ -609,6 +607,12 @@ void prout(char *fmt, ...) {
     skip(1);\r
 }\r
 \r
     skip(1);\r
 }\r
 \r
+void proutc(char *line) {\r
+    line[strlen(line)-1] = '\0';\r
+    fputs(line, stdout);\r
+    skip(1);\r
+}\r
+\r
 void prouts(char *fmt, ...) {\r
        clock_t endTime;\r
        char *s, buf[BUFSIZ];\r
 void prouts(char *fmt, ...) {\r
        clock_t endTime;\r
        char *s, buf[BUFSIZ];\r