Guard against nasty surprises when building with -DESERGEEV off.
[super-star-trek.git] / conio.c
diff --git a/conio.c b/conio.c
index 92598140141e2e12633872e123c3c08ab8fa2965..8c33917e897521dac3b0e18abc619be5e9f2d410 100644 (file)
--- a/conio.c
+++ b/conio.c
@@ -59,9 +59,8 @@ static void docolor (int color) /* Set DOS-like text mode colors */
    wattron(conio_scr,COLOR_PAIR(1+(color&7)+((color&112)>>1))); 
 }
 
-#ifdef SERGEEV
 /* 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 */
+void initconio (void)
 {
    int x,y;
    short pair;
@@ -91,7 +90,6 @@ void __attribute__((constructor)) initconio (void) /* This is needed, because nc
    textcolor(7);
    textbackground(0);
 }
-#endif /* SERGEEV */
 
 /* Call this on exiting your program */
 void doneconio (void)
@@ -122,16 +120,22 @@ char *cgets (char *str) /* ugly function :-( */
 }
 
 void clreol (void)
+/* clear to end of line -- can be a no-op in tty mode */
 {
+#ifdef SERGEEV
    wclrtoeol(conio_scr);
    wrefresh(conio_scr);
+#endif /* SERGEEV */
 }
 
 void clrscr (void)
+/* clear screen -- can be a no-op in tty mode */
 {
+#ifdef SERGEEV
    wclear(conio_scr);
    wmove(conio_scr,0,0);
    wrefresh(conio_scr);
+#endif /* SERGEEV */
 }
 
 int cprintf (char *format, ... )
@@ -142,8 +146,13 @@ int cprintf (char *format, ... )
    va_start(argp,format);
    vsprintf(buffer,format,argp);
    va_end(argp);
+
+#ifdef SERGEEV
    i=waddstr(conio_scr,buffer);
    wrefresh(conio_scr);
+#else
+   i=printf(buffer);
+#endif /* SERGEEV */
    return(i);
 }
 
@@ -213,17 +222,22 @@ void gettextinfo(struct text_info *inforec)
 } 
 
 void gotoxy (int x, int y)
+/* address cursor -- OK for this to be a no-op in TTY mode */
 {
+#ifdef SERGEEV
    y--;
    x--;
    wmove(conio_scr,y,x);
    wrefresh(conio_scr);
+#endif /* SERGEEV */
 }
 
 void highvideo (void)
 {
+#ifdef SERGEEV
    textcolor(15); /* White */
    textbackground(0); /* Black */
+#endif /* SERGEEV */
 }
 
 void insline (void)
@@ -274,11 +288,14 @@ void textbackground (int color)
    docolor(color);
 }
 
+
 void textcolor (int color)
 {
+#ifdef SERGEEV
    fgc=color;
    color=(bgc*16)+fgc;
    docolor(color);
+#endif /* SERGEEV */
 }
  
 void textmode (int mode)
@@ -288,20 +305,24 @@ void textmode (int mode)
 
 int wherex (void)
 {
+#ifdef SERGEEV
    int y;
    int x;
    getyx(conio_scr,y,x);
    x++;
    return(x);
+#endif /* SERGEEV */
 }
 
 int wherey (void)
 {
+#ifdef SERGEEV
    int y;
    int x;
    getyx(conio_scr,y,x);
    y++;
    return(y);
+#endif /* SERGEEV */
 }
 
 void window (int left,int top,int right,int bottom)