summaryrefslogtreecommitdiffstats
path: root/sail
diff options
context:
space:
mode:
authordholland <dholland@NetBSD.org>2009-03-15 00:50:47 +0000
committerdholland <dholland@NetBSD.org>2009-03-15 00:50:47 +0000
commit89a2669a8a8be664d488ac22db57f6c9f9f2b8ec (patch)
treeb9226c46f50e7ea70b0e2236746c3746690625e2 /sail
parent68d4fdd27d94764d7e4f1a1e40f9ada5f69d0fbd (diff)
downloadbsdgames-darwin-89a2669a8a8be664d488ac22db57f6c9f9f2b8ec.tar.gz
bsdgames-darwin-89a2669a8a8be664d488ac22db57f6c9f9f2b8ec.tar.zst
bsdgames-darwin-89a2669a8a8be664d488ac22db57f6c9f9f2b8ec.zip
Move newturn() from pl_7 to pl_2.
pl_7 was mostly curses/display stuff, is going to be all display stuff. pl_2 is where the main loop lives.
Diffstat (limited to 'sail')
-rw-r--r--sail/display.h8
-rw-r--r--sail/pl_2.c57
-rw-r--r--sail/pl_7.c88
3 files changed, 89 insertions, 64 deletions
diff --git a/sail/display.h b/sail/display.h
index 98995609..bcd58b95 100644
--- a/sail/display.h
+++ b/sail/display.h
@@ -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.
@@ -29,6 +29,12 @@
* 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);
diff --git a/sail/pl_2.c b/sail/pl_2.c
index 75be55fb..c66ddae8 100644
--- a/sail/pl_2.c
+++ b/sail/pl_2.c
@@ -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
@@ -34,14 +34,67 @@
#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)
{
diff --git a/sail/pl_7.c b/sail/pl_7.c
index 4be1df7c..23172567 100644
--- a/sail/pl_7.c
+++ b/sail/pl_7.c
@@ -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;