X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.c;h=653e06be826b8a71d4950682fa2ad04fb78f1267;hp=f6db8870c9ae1856cf8eb55d345ac0981475a7c6;hb=7d27c8befdb5de9a50ff4af88e764c8336bc1797;hpb=77e371705e1e059173ec9c88f63be7a460e44e50 diff --git a/sst.c b/sst.c index f6db887..653e06b 100644 --- a/sst.c +++ b/sst.c @@ -1,6 +1,7 @@ #define INCLUDED // Define externs here #include "sst.h" #include +#include #ifdef MSDOS #include #endif @@ -373,13 +374,13 @@ int main(int argc, char **argv) { skip(1); if (tourn && alldone) { - printf("Do you want your score recorded?"); + proutn("Do you want your score recorded?"); if (ja()) { chew2(); freeze(FALSE); } } - printf("Do you want to play again?"); + proutn("Do you want to play again?"); if (!ja()) break; } skip(1); @@ -407,20 +408,20 @@ void cramen(int i) { proutn(s); } -void cramlc(int key, int x, int y) { - if (key == 1) proutn(" Quadrant"); - else if (key == 2) proutn(" Sector"); - proutn(" "); - crami(x, 1); - proutn(" - "); - crami(y, 1); +char *cramlc(enum loctype key, int x, int y) { + static char buf[32]; + buf[0] = '\0'; + if (key == quadrant) strcpy(buf, "Quadrant "); + else if (key == sector) strcpy(buf, "Sector "); + sprintf(buf+strlen(buf), "%d-%d", x, y); + return buf; } void crmena(int i, int enemy, int key, int x, int y) { if (i == 1) proutn("***"); cramen(enemy); proutn(" at"); - cramlc(key, x, y); + proutn(cramlc(key, x, y)); } void crmshp(void) { @@ -530,18 +531,6 @@ int ja(void) { } } -void cramf(double x, int w, int d) { - char buf[64]; - sprintf(buf, "%*.*f", w, d, x); - proutn(buf); -} - -void crami(int i, int w) { - char buf[16]; - sprintf(buf, "%*d", w, i); - proutn(buf); -} - double square(double i) { return i*i; } static void clearscreen(void) { @@ -591,22 +580,34 @@ void skip(int i) { } -void proutn(char *s) { - fputs(s, stdout); +void proutn(char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); } -void prout(char *s) { - proutn(s); - skip(1); +void prout(char *fmt, ...) { + va_list ap; + va_start(ap, fmt); + vprintf(fmt, ap); + va_end(ap); + skip(1); } -void prouts(char *s) { +void prouts(char *fmt, ...) { clock_t endTime; + char *s, buf[BUFSIZ]; /* print slowly! */ - while (*s) { + va_list ap; + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + skip(1); + for (s = buf; *s; s++) { endTime = clock() + CLOCKS_PER_SEC*0.05; while (clock() < endTime) ; - putchar(*s++); + putchar(*s); fflush(stdout); } } @@ -676,7 +677,7 @@ void debugme(void) { case FSCMOVE: proutn("SC Move "); break; case FSCDBAS: proutn("SC Base Destroy "); break; } - cramf(future[i]-game.state.date, 8, 2); + proutn("%82.2f", future[i]-game.state.date); chew(); proutn(" ?"); key = scan();