]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
Move newturn() from pl_7 to pl_2.
authordholland <dholland@NetBSD.org>
Sun, 15 Mar 2009 00:50:47 +0000 (00:50 +0000)
committerdholland <dholland@NetBSD.org>
Sun, 15 Mar 2009 00:50:47 +0000 (00:50 +0000)
pl_7 was mostly curses/display stuff, is going to be all display stuff.
pl_2 is where the main loop lives.

sail/display.h
sail/pl_2.c
sail/pl_7.c

index 989956097be8a1871dd98e318c51fa8a5485954c..bcd58b9599b55e1d1089b397fa7adb51d7a660c4 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: display.h,v 1.5 2009/03/15 00:35:42 dholland Exp $     */
+/*     $NetBSD: display.h,v 1.6 2009/03/15 00:50:47 dholland Exp $     */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdbool.h>
+
 void display_show_obp(int which, bool show);
 void display_show_dbp(int which, bool show);
 void display_refresh_slot_w(void);
+
+void display_hide_prompt(void);
+void display_reshow_prompt(void);
+void display_adjust_view(void);
index 75be55fb9dc6afd15ccc7a7ceb227a9050653749..c66ddae8502f4574684a492bb4567866ef4fd641 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc Exp $    */
+/*     $NetBSD: pl_2.c,v 1.12 2009/03/15 00:50:47 dholland Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
 #if 0
 static char sccsid[] = "@(#)pl_2.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: pl_2.c,v 1.11 2003/08/07 09:37:43 agc Exp $");
+__RCSID("$NetBSD: pl_2.c,v 1.12 2009/03/15 00:50:47 dholland Exp $");
 #endif
 #endif /* not lint */
 
 #include <signal.h>
+#include <unistd.h>
+#include "display.h"
 #include "extern.h"
 #include "player.h"
 
+/*ARGSUSED*/
+void
+newturn(int n __unused)
+{
+       repaired = loaded = fired = changed = 0;
+       movebuf[0] = '\0';
+
+       alarm(0);
+       if (mf->readyL & R_LOADING) {
+               if (mf->readyL & R_DOUBLE)
+                       mf->readyL = R_LOADING;
+               else
+                       mf->readyL = R_LOADED;
+       }
+       if (mf->readyR & R_LOADING) {
+               if (mf->readyR & R_DOUBLE)
+                       mf->readyR = R_LOADING;
+               else
+                       mf->readyR = R_LOADED;
+       }
+       if (!hasdriver)
+               send_ddead();
+
+       display_hide_prompt();
+       if (Sync() < 0)
+               leave(LEAVE_SYNC);
+       if (!hasdriver)
+               leave(LEAVE_DRIVER);
+       display_reshow_prompt();
+
+       if (turn % 50 == 0)
+               send_alive();
+       if (mf->FS && (!mc->rig1 || windspeed == 6))
+               send_fs(ms, 0);
+       if (mf->FS == 1)
+               send_fs(ms, 2);
+
+       if (mf->struck)
+               leave(LEAVE_QUIT);
+       if (mf->captured != 0)
+               leave(LEAVE_CAPTURED);
+       if (windspeed == 7)
+               leave(LEAVE_HURRICAN);
+
+       display_adjust_view();
+       draw_screen();
+
+       signal(SIGALRM, newturn);
+       alarm(7);
+}
+
 void
 play(void)
 {
index 4be1df7ca1a3b423e5f7d2228d19610f95d01270..23172567f3ca18f2de3f4be169ba3ea4d0ca2914 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $       */
+/*     $NetBSD: pl_7.c,v 1.34 2009/03/15 00:50:47 dholland Exp $       */
 
 /*
  * Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pl_7.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $");
+__RCSID("$NetBSD: pl_7.c,v 1.34 2009/03/15 00:50:47 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -44,7 +44,6 @@ __RCSID("$NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $");
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
 #include "extern.h"
 #include "player.h"
@@ -52,7 +51,6 @@ __RCSID("$NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $");
 
 static void Scroll(void);
 static void endprompt(int);
-static void adjustview(void);
 
 /*
  * Display interface
@@ -130,61 +128,6 @@ cleanupscreen(void)
        }
 }
 
-/*ARGSUSED*/
-void
-newturn(int n __unused)
-{
-       repaired = loaded = fired = changed = 0;
-       movebuf[0] = '\0';
-
-       alarm(0);
-       if (mf->readyL & R_LOADING) {
-               if (mf->readyL & R_DOUBLE)
-                       mf->readyL = R_LOADING;
-               else
-                       mf->readyL = R_LOADED;
-       }
-       if (mf->readyR & R_LOADING) {
-               if (mf->readyR & R_DOUBLE)
-                       mf->readyR = R_LOADING;
-               else
-                       mf->readyR = R_LOADED;
-       }
-       if (!hasdriver)
-               send_ddead();
-
-       if (sc_hasprompt) {
-               wmove(scroll_w, sc_line, 0);
-               wclrtoeol(scroll_w);
-       }
-       if (Sync() < 0)
-               leave(LEAVE_SYNC);
-       if (!hasdriver)
-               leave(LEAVE_DRIVER);
-       if (sc_hasprompt)
-               wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
-
-       if (turn % 50 == 0)
-               send_alive();
-       if (mf->FS && (!mc->rig1 || windspeed == 6))
-               send_fs(ms, 0);
-       if (mf->FS == 1)
-               send_fs(ms, 2);
-
-       if (mf->struck)
-               leave(LEAVE_QUIT);
-       if (mf->captured != 0)
-               leave(LEAVE_CAPTURED);
-       if (windspeed == 7)
-               leave(LEAVE_HURRICAN);
-
-       adjustview();
-       draw_screen();
-
-       signal(SIGALRM, newturn);
-       alarm(7);
-}
-
 /*VARARGS2*/
 void
 Signal(const char *fmt, struct ship *ship, ...)
@@ -248,6 +191,28 @@ endprompt(int flag)
                Scroll();
 }
 
+/*
+ * Next two functions called from newturn() to poke display. Shouldn't
+ * exist... XXX
+ */
+
+void
+display_hide_prompt(void)
+{
+       if (sc_hasprompt) {
+               wmove(scroll_w, sc_line, 0);
+               wclrtoeol(scroll_w);
+       }
+}
+
+void
+display_reshow_prompt(void)
+{
+       if (sc_hasprompt)
+               wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
+}
+
+
 int
 sgetch(const char *p, struct ship *ship, int flag)
 {
@@ -551,8 +516,9 @@ rightview(void)
        viewcol += VIEW_X / 5;
 }
 
-static void
-adjustview(void)
+/* Called from newturn()... rename? */
+void
+display_adjust_view(void)
 {
        if (dont_adjust)
                return;