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.
This commit is contained in:
dholland 2009-03-15 00:50:47 +00:00
parent 842019525c
commit 5368eaecca
3 changed files with 89 additions and 64 deletions

View 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.
@ -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);

View 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
@ -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)
{

View 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;