More factoring out.
[super-star-trek.git] / io.c
diff --git a/io.c b/io.c
index 12a1993e693272f9fd29ce546229e63d92ff7e88..444a5cb2c2923e509a3702b16756d729a5fc735b 100644 (file)
--- a/io.c
+++ b/io.c
@@ -1,26 +1,15 @@
-#ifdef SERGEEV
 #define _GNU_SOURCE
-#endif /* SERGEEV */
 #include <stdio.h>
-#ifdef SERGEEV
 #include <unistd.h>
-#endif /* SERGEEV */
 #include <termios.h>
 #include <curses.h>
 #include <signal.h>
 #include <ctype.h>
 #include <stdarg.h>
-#ifdef SERGEEV
-#include <conio.h>
-#endif /* SERGEEV */
-#ifdef MSDOS
-#include <dos.h>
-#endif
 #include <time.h>
 
-#ifdef SERGEEV
+#include "conio.h"
 #include "sstlinux.h"
-#endif /* SERGEEV */
 #include "sst.h"
 
 #ifndef SERGEEV
@@ -62,6 +51,11 @@ static void fastexit(int sig) {
 }
 
 void iostart(int usecurses) {
+#ifdef SERGEEV
+        textattr(7);
+        clrscr();
+        setwnd(FULLSCREEN_WINDOW);
+#else
        (void) signal(SIGINT, fastexit);
        (void) signal(SIGINT, fastexit);
 #ifdef SIGIOT
@@ -86,10 +80,13 @@ void iostart(int usecurses) {
                if (LINES)
                    screenheight = atoi(LINES);
        }
+#endif /* SERGEEV */
 }
 
 void ioend(void) {
+#ifndef SERGEEV
     outro(0);
+#endif /* SERGEEV */
 }
 
 void waitfor(void) {
@@ -302,6 +299,67 @@ void c_printf (char *format, ... )
 #endif /* SERGEEV */
 }
 
+void cgetline(char *line, int max) {
+    if (curses) {
+#ifndef SERGEEV
+       wgetnstr(stdscr, line, max);
+       wrefresh(stdscr);
+#else /* SERGEEV */
+       line[0]=max-1;
+       cgets(line);
+       memmove(line,&line[2],max-3);
+#endif /* SERGEEV */
+    } else {
+       fgets(line, max, stdin);
+        line[strlen(line)-1] = '\0';
+    }
+}
+
+void setwnd(short wndnum){
+/* change windows -- OK for this to be a no-op in tty mode */
+#ifdef SERGEEV
+     int cury;
+     cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
+     if ((curwnd==FULLSCREEN_WINDOW)&&(wndnum!=FULLSCREEN_WINDOW)) clrscr();
+     window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
+     if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
+        gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
+       skip(1);
+     }
+     curwnd=wndnum;
+     gotoxy(1,cury);
+#endif /* SERGEEV */
+}
+
+void commandhook(char *cmd, int before) {
+}
+
+/*
+ * Things past this point have policy implications.
+ */
+
+void drawmaps(short l) {
+/* hook to be called after moving to redraw maps */
+#ifdef SERGEEV
+     _setcursortype(_NOCURSOR);
+     if (l==1) sensor();
+     if (l!=2) setwnd(LEFTUPPER_WINDOW);
+     gotoxy(1,1);
+     strcpy(line,"s");
+     srscan(1);
+     if (l!=2){
+        setwnd(SRSCAN_WINDOW);
+        clrscr();
+        srscan(2);
+        setwnd(LRSCAN_WINDOW);
+        clrscr();
+        strcpy(line,"l");
+        lrscan();
+        _setcursortype(_NORMALCURSOR);
+     }
+#endif /* SERGEEV */
+}
+
 void warble(void)
 /* sound and visual effects for teleportation */
 {
@@ -336,37 +394,3 @@ void setpassword(void) {
 #endif /* SERGEEV */
 }
 
-void getline(char *line, int max) {
-    if (curses) {
-#ifndef SERGEEV
-       wgetnstr(stdscr, line, max);
-       wrefresh(stdscr);
-#else /* SERGEEV */
-       line[0]=max-1;
-       cgets(line);
-       memmove(line,&line[2],max-3);
-#endif /* SERGEEV */
-    } else {
-       fgets(line, max, stdin);
-        line[strlen(line)-1] = '\0';
-    }
-}
-
-void setwnd(short wndnum){
-/* change windows -- OK for this to be a no-op in tty mode */
-#ifdef SERGEEV
-     int cury;
-     cury=wherey()+wnds[curwnd].wndtop-wnds[wndnum].wndtop;
-     if ((curwnd==FULLSCREEN_WINDOW)&&(wndnum!=FULLSCREEN_WINDOW)) clrscr();
-     window(wnds[wndnum].wndleft, wnds[wndnum].wndtop, wnds[wndnum].wndright, wnds[wndnum].wndbottom);
-     if ((curwnd==wndnum)&&(cury>wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1)){
-        gotoxy(wnds[wndnum].wndright-wnds[wndnum].wndleft+1,wnds[wndnum].wndbottom-wnds[wndnum].wndtop+1);
-       skip(1);
-     }
-     curwnd=wndnum;
-     gotoxy(1,cury);
-#endif /* SERGEEV */
-}
-
-void commandhook(char *cmd, int before) {
-}