+/* $NetBSD: pl_7.c,v 1.12 1999/09/08 21:45:30 jsm Exp $ */
+
/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1983, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-/*static char sccsid[] = "from: @(#)pl_7.c 5.7 (Berkeley) 2/28/91";*/
-static char rcsid[] = "$Id: pl_7.c,v 1.2 1993/08/01 18:51:35 mycroft Exp $";
+#if 0
+static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93";
+#else
+__RCSID("$NetBSD: pl_7.c,v 1.12 1999/09/08 21:45:30 jsm Exp $");
+#endif
#endif /* not lint */
+#include <sys/ttydefaults.h>
#include "player.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <unistd.h>
+
/*
* Display interface
*/
static char sc_hasprompt;
-static char *sc_prompt;
-static char *sc_buf;
+static const char *sc_prompt;
+static const char *sc_buf;
static int sc_line;
+void
initscreen()
{
/* initscr() already done in SCREENTEST() */
(void) leaveok(slot_w, 1);
(void) leaveok(stat_w, 1);
(void) leaveok(turn_w, 1);
-#ifdef SIGTSTP
- {
- void susp();
- (void) signal(SIGTSTP, susp);
- }
-#endif
noecho();
crmode();
}
+void
cleanupscreen()
{
/* alarm already turned off */
}
}
+/*ARGSUSED*/
void
-newturn()
+newturn(n)
+ int n __attribute__((__unused__));
{
repaired = loaded = fired = changed = 0;
movebuf[0] = '\0';
(void) alarm(0);
- if (mf->readyL & R_LOADING)
+ 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_LOADING) {
if (mf->readyR & R_DOUBLE)
mf->readyR = R_LOADING;
else
mf->readyR = R_LOADED;
+ }
if (!hasdriver)
- Write(W_DDEAD, SHIP(0), 0, 0, 0, 0, 0);
+ Write(W_DDEAD, SHIP(0), 0, 0, 0, 0);
if (sc_hasprompt) {
(void) wmove(scroll_w, sc_line, 0);
(void) wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
if (turn % 50 == 0)
- Write(W_ALIVE, SHIP(0), 0, 0, 0, 0, 0);
+ Write(W_ALIVE, SHIP(0), 0, 0, 0, 0);
if (mf->FS && (!mc->rig1 || windspeed == 6))
- Write(W_FS, ms, 0, 0, 0, 0, 0);
+ Write(W_FS, ms, 0, 0, 0, 0);
if (mf->FS == 1)
- Write(W_FS, ms, 0, 2, 0, 0, 0);
+ Write(W_FS, ms, 2, 0, 0, 0);
if (mf->struck)
leave(LEAVE_QUIT);
}
/*VARARGS2*/
-Signal(fmt, ship, a, b, c, d)
-char *fmt;
-register struct ship *ship;
-int a, b, c, d;
+void
+#ifdef __STDC__
+Signal(const char *fmt, struct ship *ship, ...)
+#else
+Signal(va_alist)
+ va_dcl
+#endif
{
+ va_list ap;
+ char format[BUFSIZ];
+#ifndef __STDC__
+ const char *fmt;
+ struct ship *ship;
+
+ va_start(ap);
+ fmt = va_arg(ap, const char *);
+ ship = va_arg(ap, struct ship *);
+#else
+ va_start(ap, ship);
+#endif
if (!done_curses)
return;
if (*fmt == '\7')
putchar(*fmt++);
- if (ship == 0)
- (void) wprintw(scroll_w, fmt, a, b, c, d);
- else
- (void) wprintw(scroll_w, fmt, ship->shipname,
- colours(ship), sterncolour(ship), a, b, c, d);
+ fmtship(format, sizeof(format), fmt, ship);
+ (void) vwprintw(scroll_w, format, ap);
+ va_end(ap);
+ Scroll();
+}
+
+/*VARARGS2*/
+void
+#ifdef __STDC__
+Msg(const char *fmt, ...)
+#else
+Msg(va_alist)
+ va_dcl
+#endif
+{
+ va_list ap;
+#ifndef __STDC__
+ const char *fmt;
+
+ va_start(ap);
+ fmt = va_arg(ap, const char *);
+#else
+ va_start(ap, fmt);
+#endif
+
+ if (!done_curses)
+ return;
+ if (*fmt == '\7')
+ putchar(*fmt++);
+ (void) vwprintw(scroll_w, fmt, ap);
+ va_end(ap);
Scroll();
}
+void
Scroll()
{
if (++sc_line >= SCROLL_Y)
(void) wclrtoeol(scroll_w);
}
+void
prompt(p, ship)
-register char *p;
-struct ship *ship;
+ const char *p;
+ struct ship *ship;
{
- static char buf[60];
+ static char buf[BUFSIZ];
- if (ship != 0) {
- (void)sprintf(buf, p, ship->shipname, colours(ship),
- sterncolour(ship));
- p = buf;
- }
- sc_prompt = p;
+ fmtship(buf, sizeof(buf), p, ship);
+ sc_prompt = buf;
sc_buf = "";
sc_hasprompt = 1;
- (void) waddstr(scroll_w, p);
+ (void) waddstr(scroll_w, buf);
}
+void
endprompt(flag)
char flag;
{
Scroll();
}
+int
sgetch(p, ship, flag)
-char *p;
-struct ship *ship;
-char flag;
+ const char *p;
+ struct ship *ship;
+ char flag;
{
- register c;
-
+ int c;
prompt(p, ship);
blockalarm();
(void) wrefresh(scroll_w);
return c;
}
+void
sgetstr(pr, buf, n)
-char *pr;
-register char *buf;
-register n;
+ const char *pr;
+ char *buf;
+ int n;
{
- register c;
- register char *p = buf;
+ int c;
+ char *p = buf;
prompt(pr, (struct ship *)0);
sc_buf = buf;
*p++ = c;
(void) waddch(scroll_w, c);
} else
- (void) putchar(CTRL('g'));
+ (void) putchar('\a');
}
}
}
+void
draw_screen()
{
draw_view();
(void) wrefresh(scroll_w); /* move the cursor */
}
+void
draw_view()
{
- register struct ship *sp;
+ struct ship *sp;
(void) werase(view_w);
foreachship(sp) {
(void) wrefresh(view_w);
}
+void
draw_turn()
{
(void) wmove(turn_w, 0, 0);
(void) wrefresh(turn_w);
}
+void
draw_stat()
{
(void) wmove(stat_w, STAT_1, 0);
(void) wrefresh(stat_w);
}
+void
draw_slot()
{
if (!boarding(ms, 0)) {
(void) wrefresh(slot_w);
}
+void
draw_board()
{
- register int n;
+ int n;
(void) clear();
(void) werase(view_w);
(void) refresh();
}
+void
centerview()
{
viewrow = mf->row - VIEW_Y / 2;
viewcol = mf->col - VIEW_X / 2;
}
+void
upview()
{
viewrow -= VIEW_Y / 3;
}
+void
downview()
{
viewrow += VIEW_Y / 3;
}
+void
leftview()
{
viewcol -= VIEW_X / 5;
}
+void
rightview()
{
viewcol += VIEW_X / 5;
}
+void
adjustview()
{
if (dont_adjust)
else if (mf->col > viewcol + (VIEW_X - VIEW_X/8))
viewcol = mf->col - VIEW_X/8;
}
-
-#ifdef SIGTSTP
-void
-susp()
-{
- blockalarm();
- tstp();
- (void) signal(SIGTSTP, susp);
- unblockalarm();
-}
-#endif