Home | History | Annotate | Line # | Download | only in sail
pl_7.c revision 1.33
      1  1.33  dholland /*	$NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $	*/
      2   1.6       cgd 
      3   1.1       cgd /*
      4   1.6       cgd  * Copyright (c) 1983, 1993
      5   1.6       cgd  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15  1.27       agc  * 3. Neither the name of the University nor the names of its contributors
     16   1.1       cgd  *    may be used to endorse or promote products derived from this software
     17   1.1       cgd  *    without specific prior written permission.
     18   1.1       cgd  *
     19   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29   1.1       cgd  * SUCH DAMAGE.
     30   1.1       cgd  */
     31   1.1       cgd 
     32   1.7  christos #include <sys/cdefs.h>
     33   1.1       cgd #ifndef lint
     34   1.6       cgd #if 0
     35   1.6       cgd static char sccsid[] = "@(#)pl_7.c	8.1 (Berkeley) 5/31/93";
     36   1.6       cgd #else
     37  1.33  dholland __RCSID("$NetBSD: pl_7.c,v 1.33 2009/03/15 00:35:42 dholland Exp $");
     38   1.6       cgd #endif
     39   1.1       cgd #endif /* not lint */
     40   1.1       cgd 
     41  1.20     jwise #include <curses.h>
     42  1.29  dholland #include <err.h>
     43  1.19     jwise #include <signal.h>
     44   1.7  christos #include <stdarg.h>
     45  1.18     jwise #include <stdio.h>
     46  1.23       cgd #include <stdlib.h>
     47   1.7  christos #include <unistd.h>
     48  1.22    itojun #include <string.h>
     49  1.20     jwise #include "extern.h"
     50  1.18     jwise #include "player.h"
     51  1.20     jwise #include "display.h"
     52   1.6       cgd 
     53  1.30  dholland static void Scroll(void);
     54  1.30  dholland static void endprompt(int);
     55  1.30  dholland static void adjustview(void);
     56   1.1       cgd 
     57   1.1       cgd /*
     58   1.1       cgd  * Display interface
     59   1.1       cgd  */
     60   1.1       cgd 
     61   1.1       cgd static char sc_hasprompt;
     62  1.11       jsm static const char *sc_prompt;
     63  1.11       jsm static const char *sc_buf;
     64   1.1       cgd static int sc_line;
     65  1.13       jsm 
     66  1.33  dholland static WINDOW *view_w;
     67  1.33  dholland static WINDOW *slot_w;
     68  1.33  dholland static WINDOW *scroll_w;
     69  1.33  dholland static WINDOW *stat_w;
     70  1.33  dholland static WINDOW *turn_w;
     71  1.13       jsm 
     72  1.21     jwise int done_curses;
     73  1.21     jwise int loaded, fired, changed, repaired;
     74  1.21     jwise int dont_adjust;
     75  1.13       jsm int viewrow, viewcol;
     76  1.13       jsm char movebuf[sizeof SHIP(0)->file->movebuf];
     77  1.13       jsm int player;
     78  1.13       jsm struct ship *ms;		/* memorial structure, &cc->ship[player] */
     79  1.13       jsm struct File *mf;		/* ms->file */
     80  1.13       jsm struct shipspecs *mc;		/* ms->specs */
     81   1.1       cgd 
     82   1.7  christos void
     83  1.16     jwise initscreen(void)
     84   1.1       cgd {
     85  1.33  dholland 	if (signal(SIGTSTP, SIG_DFL) == SIG_ERR) {
     86  1.33  dholland 		err(1, "signal(SIGTSTP)");
     87  1.33  dholland 	}
     88  1.33  dholland 
     89  1.33  dholland 	if (initscr() == NULL) {
     90  1.29  dholland 		errx(1, "Can't sail on this terminal.");
     91  1.14       jsm 	}
     92  1.33  dholland 	if (STAT_R >= COLS || SCROLL_Y <= 0) {
     93  1.33  dholland 		errx(1, "Window/terminal not large enough.");
     94  1.33  dholland 	}
     95  1.33  dholland 
     96   1.1       cgd 	view_w = newwin(VIEW_Y, VIEW_X, VIEW_T, VIEW_L);
     97   1.1       cgd 	slot_w = newwin(SLOT_Y, SLOT_X, SLOT_T, SLOT_L);
     98   1.1       cgd 	scroll_w = newwin(SCROLL_Y, SCROLL_X, SCROLL_T, SCROLL_L);
     99   1.1       cgd 	stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L);
    100   1.1       cgd 	turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L);
    101  1.33  dholland 
    102  1.33  dholland 	if (view_w == NULL ||
    103  1.33  dholland 	    slot_w == NULL ||
    104  1.33  dholland 	    scroll_w == NULL ||
    105  1.33  dholland 	    stat_w == NULL ||
    106  1.33  dholland 	    turn_w == NULL) {
    107  1.33  dholland 		endwin();
    108  1.33  dholland 		errx(1, "Curses initialization failed.");
    109  1.33  dholland 	}
    110  1.33  dholland 
    111  1.16     jwise 	leaveok(view_w, 1);
    112  1.16     jwise 	leaveok(slot_w, 1);
    113  1.16     jwise 	leaveok(stat_w, 1);
    114  1.16     jwise 	leaveok(turn_w, 1);
    115   1.1       cgd 	noecho();
    116  1.26     blymn 	cbreak();
    117  1.33  dholland 
    118  1.33  dholland 	done_curses++;
    119   1.1       cgd }
    120   1.1       cgd 
    121   1.7  christos void
    122  1.16     jwise cleanupscreen(void)
    123   1.1       cgd {
    124   1.1       cgd 	/* alarm already turned off */
    125   1.1       cgd 	if (done_curses) {
    126  1.16     jwise 		wmove(scroll_w, SCROLL_Y - 1, 0);
    127  1.16     jwise 		wclrtoeol(scroll_w);
    128   1.1       cgd 		draw_screen();
    129   1.1       cgd 		endwin();
    130   1.1       cgd 	}
    131   1.1       cgd }
    132   1.1       cgd 
    133   1.7  christos /*ARGSUSED*/
    134   1.1       cgd void
    135  1.28     perry newturn(int n __unused)
    136   1.1       cgd {
    137   1.1       cgd 	repaired = loaded = fired = changed = 0;
    138   1.1       cgd 	movebuf[0] = '\0';
    139   1.1       cgd 
    140  1.16     jwise 	alarm(0);
    141   1.9     veego 	if (mf->readyL & R_LOADING) {
    142   1.1       cgd 		if (mf->readyL & R_DOUBLE)
    143   1.1       cgd 			mf->readyL = R_LOADING;
    144   1.1       cgd 		else
    145   1.1       cgd 			mf->readyL = R_LOADED;
    146   1.9     veego 	}
    147   1.9     veego 	if (mf->readyR & R_LOADING) {
    148   1.1       cgd 		if (mf->readyR & R_DOUBLE)
    149   1.1       cgd 			mf->readyR = R_LOADING;
    150   1.1       cgd 		else
    151   1.1       cgd 			mf->readyR = R_LOADED;
    152   1.9     veego 	}
    153   1.1       cgd 	if (!hasdriver)
    154  1.32  dholland 		send_ddead();
    155   1.1       cgd 
    156   1.1       cgd 	if (sc_hasprompt) {
    157  1.16     jwise 		wmove(scroll_w, sc_line, 0);
    158  1.16     jwise 		wclrtoeol(scroll_w);
    159   1.1       cgd 	}
    160   1.1       cgd 	if (Sync() < 0)
    161   1.1       cgd 		leave(LEAVE_SYNC);
    162   1.1       cgd 	if (!hasdriver)
    163   1.1       cgd 		leave(LEAVE_DRIVER);
    164   1.1       cgd 	if (sc_hasprompt)
    165  1.16     jwise 		wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
    166   1.1       cgd 
    167   1.1       cgd 	if (turn % 50 == 0)
    168  1.32  dholland 		send_alive();
    169   1.1       cgd 	if (mf->FS && (!mc->rig1 || windspeed == 6))
    170  1.32  dholland 		send_fs(ms, 0);
    171   1.1       cgd 	if (mf->FS == 1)
    172  1.32  dholland 		send_fs(ms, 2);
    173   1.1       cgd 
    174   1.1       cgd 	if (mf->struck)
    175   1.1       cgd 		leave(LEAVE_QUIT);
    176   1.1       cgd 	if (mf->captured != 0)
    177   1.1       cgd 		leave(LEAVE_CAPTURED);
    178   1.1       cgd 	if (windspeed == 7)
    179   1.1       cgd 		leave(LEAVE_HURRICAN);
    180   1.1       cgd 
    181   1.1       cgd 	adjustview();
    182   1.1       cgd 	draw_screen();
    183   1.1       cgd 
    184  1.16     jwise 	signal(SIGALRM, newturn);
    185  1.16     jwise 	alarm(7);
    186   1.1       cgd }
    187   1.1       cgd 
    188   1.1       cgd /*VARARGS2*/
    189   1.7  christos void
    190   1.7  christos Signal(const char *fmt, struct ship *ship, ...)
    191   1.1       cgd {
    192   1.7  christos 	va_list ap;
    193   1.7  christos 	char format[BUFSIZ];
    194   1.7  christos 
    195   1.1       cgd 	if (!done_curses)
    196   1.1       cgd 		return;
    197  1.25       wiz 	va_start(ap, ship);
    198  1.31  dholland 	if (*fmt == '\a')
    199   1.1       cgd 		putchar(*fmt++);
    200   1.7  christos 	fmtship(format, sizeof(format), fmt, ship);
    201  1.16     jwise 	vwprintw(scroll_w, format, ap);
    202   1.7  christos 	va_end(ap);
    203   1.7  christos 	Scroll();
    204   1.7  christos }
    205   1.7  christos 
    206   1.7  christos /*VARARGS2*/
    207   1.7  christos void
    208   1.7  christos Msg(const char *fmt, ...)
    209   1.7  christos {
    210   1.7  christos 	va_list ap;
    211   1.7  christos 
    212   1.7  christos 	if (!done_curses)
    213   1.7  christos 		return;
    214  1.25       wiz 	va_start(ap, fmt);
    215  1.31  dholland 	if (*fmt == '\a')
    216   1.7  christos 		putchar(*fmt++);
    217  1.16     jwise 	vwprintw(scroll_w, fmt, ap);
    218   1.7  christos 	va_end(ap);
    219   1.1       cgd 	Scroll();
    220   1.1       cgd }
    221   1.1       cgd 
    222  1.17     jwise static void
    223  1.16     jwise Scroll(void)
    224   1.1       cgd {
    225   1.1       cgd 	if (++sc_line >= SCROLL_Y)
    226   1.1       cgd 		sc_line = 0;
    227  1.16     jwise 	wmove(scroll_w, sc_line, 0);
    228  1.16     jwise 	wclrtoeol(scroll_w);
    229   1.1       cgd }
    230   1.1       cgd 
    231   1.7  christos void
    232  1.17     jwise prompt(const char *p, struct ship *ship)
    233   1.1       cgd {
    234   1.8  christos 	static char buf[BUFSIZ];
    235   1.1       cgd 
    236   1.8  christos 	fmtship(buf, sizeof(buf), p, ship);
    237   1.8  christos 	sc_prompt = buf;
    238   1.1       cgd 	sc_buf = "";
    239   1.1       cgd 	sc_hasprompt = 1;
    240  1.16     jwise 	waddstr(scroll_w, buf);
    241   1.1       cgd }
    242   1.1       cgd 
    243  1.17     jwise static void
    244  1.16     jwise endprompt(int flag)
    245   1.1       cgd {
    246   1.1       cgd 	sc_hasprompt = 0;
    247   1.1       cgd 	if (flag)
    248   1.1       cgd 		Scroll();
    249   1.1       cgd }
    250   1.1       cgd 
    251   1.7  christos int
    252  1.16     jwise sgetch(const char *p, struct ship *ship, int flag)
    253   1.1       cgd {
    254   1.7  christos 	int c;
    255   1.1       cgd 	prompt(p, ship);
    256   1.1       cgd 	blockalarm();
    257  1.16     jwise 	wrefresh(scroll_w);
    258   1.1       cgd 	unblockalarm();
    259   1.1       cgd 	while ((c = wgetch(scroll_w)) == EOF)
    260   1.1       cgd 		;
    261   1.1       cgd 	if (flag && c >= ' ' && c < 0x7f)
    262  1.16     jwise 		waddch(scroll_w, c);
    263   1.1       cgd 	endprompt(flag);
    264   1.1       cgd 	return c;
    265   1.1       cgd }
    266   1.1       cgd 
    267   1.7  christos void
    268  1.16     jwise sgetstr(const char *pr, char *buf, int n)
    269   1.1       cgd {
    270   1.7  christos 	int c;
    271   1.7  christos 	char *p = buf;
    272   1.1       cgd 
    273   1.1       cgd 	prompt(pr, (struct ship *)0);
    274   1.1       cgd 	sc_buf = buf;
    275   1.1       cgd 	for (;;) {
    276   1.1       cgd 		*p = 0;
    277   1.1       cgd 		blockalarm();
    278  1.16     jwise 		wrefresh(scroll_w);
    279   1.1       cgd 		unblockalarm();
    280   1.1       cgd 		while ((c = wgetch(scroll_w)) == EOF)
    281   1.1       cgd 			;
    282   1.1       cgd 		switch (c) {
    283   1.1       cgd 		case '\n':
    284   1.1       cgd 		case '\r':
    285   1.1       cgd 			endprompt(1);
    286   1.1       cgd 			return;
    287   1.1       cgd 		case '\b':
    288   1.1       cgd 			if (p > buf) {
    289  1.16     jwise 				waddstr(scroll_w, "\b \b");
    290   1.1       cgd 				p--;
    291   1.1       cgd 			}
    292   1.1       cgd 			break;
    293   1.1       cgd 		default:
    294   1.1       cgd 			if (c >= ' ' && c < 0x7f && p < buf + n - 1) {
    295   1.1       cgd 				*p++ = c;
    296  1.16     jwise 				waddch(scroll_w, c);
    297   1.1       cgd 			} else
    298  1.16     jwise 				putchar('\a');
    299   1.1       cgd 		}
    300   1.1       cgd 	}
    301   1.1       cgd }
    302   1.1       cgd 
    303   1.7  christos void
    304  1.16     jwise draw_screen(void)
    305   1.1       cgd {
    306   1.1       cgd 	draw_view();
    307   1.1       cgd 	draw_turn();
    308   1.1       cgd 	draw_stat();
    309   1.1       cgd 	draw_slot();
    310  1.16     jwise 	wrefresh(scroll_w);		/* move the cursor */
    311   1.1       cgd }
    312   1.1       cgd 
    313   1.7  christos void
    314  1.16     jwise draw_view(void)
    315   1.1       cgd {
    316   1.7  christos 	struct ship *sp;
    317   1.1       cgd 
    318  1.16     jwise 	werase(view_w);
    319   1.1       cgd 	foreachship(sp) {
    320   1.1       cgd 		if (sp->file->dir
    321   1.1       cgd 		    && sp->file->row > viewrow
    322   1.1       cgd 		    && sp->file->row < viewrow + VIEW_Y
    323   1.1       cgd 		    && sp->file->col > viewcol
    324   1.1       cgd 		    && sp->file->col < viewcol + VIEW_X) {
    325  1.16     jwise 			wmove(view_w, sp->file->row - viewrow,
    326   1.1       cgd 				sp->file->col - viewcol);
    327  1.16     jwise 			waddch(view_w, colours(sp));
    328  1.16     jwise 			wmove(view_w,
    329   1.1       cgd 				sternrow(sp) - viewrow,
    330   1.1       cgd 				sterncol(sp) - viewcol);
    331  1.16     jwise 			waddch(view_w, sterncolour(sp));
    332   1.1       cgd 		}
    333   1.1       cgd 	}
    334  1.16     jwise 	wrefresh(view_w);
    335   1.1       cgd }
    336   1.1       cgd 
    337   1.7  christos void
    338  1.16     jwise draw_turn(void)
    339   1.1       cgd {
    340  1.16     jwise 	wmove(turn_w, 0, 0);
    341  1.16     jwise 	wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn);
    342  1.16     jwise 	wrefresh(turn_w);
    343   1.1       cgd }
    344   1.1       cgd 
    345   1.7  christos void
    346  1.16     jwise draw_stat(void)
    347   1.1       cgd {
    348  1.16     jwise 	wmove(stat_w, STAT_1, 0);
    349  1.16     jwise 	wprintw(stat_w, "Points  %3d\n", mf->points);
    350  1.16     jwise 	wprintw(stat_w, "Fouls    %2d\n", fouled(ms));
    351  1.16     jwise 	wprintw(stat_w, "Grapples %2d\n", grappled(ms));
    352   1.1       cgd 
    353  1.16     jwise 	wmove(stat_w, STAT_2, 0);
    354  1.16     jwise 	wprintw(stat_w, "    0 %c(%c)\n",
    355   1.1       cgd 		maxmove(ms, winddir + 3, -1) + '0',
    356   1.1       cgd 		maxmove(ms, winddir + 3, 1) + '0');
    357  1.16     jwise 	waddstr(stat_w, "   \\|/\n");
    358  1.16     jwise 	wprintw(stat_w, "   -^-%c(%c)\n",
    359   1.1       cgd 		maxmove(ms, winddir + 2, -1) + '0',
    360   1.1       cgd 		maxmove(ms, winddir + 2, 1) + '0');
    361  1.16     jwise 	waddstr(stat_w, "   /|\\\n");
    362  1.16     jwise 	wprintw(stat_w, "    | %c(%c)\n",
    363   1.1       cgd 		maxmove(ms, winddir + 1, -1) + '0',
    364   1.1       cgd 		maxmove(ms, winddir + 1, 1) + '0');
    365  1.16     jwise 	wprintw(stat_w, "   %c(%c)\n",
    366   1.1       cgd 		maxmove(ms, winddir, -1) + '0',
    367   1.1       cgd 		maxmove(ms, winddir, 1) + '0');
    368   1.1       cgd 
    369  1.16     jwise 	wmove(stat_w, STAT_3, 0);
    370  1.16     jwise 	wprintw(stat_w, "Load  %c%c %c%c\n",
    371   1.1       cgd 		loadname[mf->loadL], readyname(mf->readyL),
    372   1.1       cgd 		loadname[mf->loadR], readyname(mf->readyR));
    373  1.16     jwise 	wprintw(stat_w, "Hull %2d\n", mc->hull);
    374  1.16     jwise 	wprintw(stat_w, "Crew %2d %2d %2d\n",
    375   1.1       cgd 		mc->crew1, mc->crew2, mc->crew3);
    376  1.16     jwise 	wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR);
    377  1.16     jwise 	wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR);
    378  1.16     jwise 	wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3);
    379   1.1       cgd 	if (mc->rig4 < 0)
    380  1.16     jwise 		waddch(stat_w, '-');
    381   1.1       cgd 	else
    382  1.16     jwise 		wprintw(stat_w, "%d", mc->rig4);
    383  1.16     jwise 	wrefresh(stat_w);
    384   1.1       cgd }
    385   1.1       cgd 
    386   1.7  christos void
    387  1.16     jwise draw_slot(void)
    388   1.1       cgd {
    389   1.1       cgd 	if (!boarding(ms, 0)) {
    390  1.16     jwise 		mvwaddstr(slot_w, 0, 0, "   ");
    391  1.16     jwise 		mvwaddstr(slot_w, 1, 0, "   ");
    392   1.1       cgd 	} else
    393  1.16     jwise 		mvwaddstr(slot_w, 1, 0, "OBP");
    394   1.1       cgd 	if (!boarding(ms, 1)) {
    395  1.16     jwise 		mvwaddstr(slot_w, 2, 0, "   ");
    396  1.16     jwise 		mvwaddstr(slot_w, 3, 0, "   ");
    397   1.1       cgd 	} else
    398  1.16     jwise 		mvwaddstr(slot_w, 3, 0, "DBP");
    399   1.1       cgd 
    400  1.16     jwise 	wmove(slot_w, SLOT_Y-4, 0);
    401   1.1       cgd 	if (mf->RH)
    402  1.16     jwise 		wprintw(slot_w, "%dRH", mf->RH);
    403   1.1       cgd 	else
    404  1.16     jwise 		waddstr(slot_w, "   ");
    405  1.16     jwise 	wmove(slot_w, SLOT_Y-3, 0);
    406   1.1       cgd 	if (mf->RG)
    407  1.16     jwise 		wprintw(slot_w, "%dRG", mf->RG);
    408   1.1       cgd 	else
    409  1.16     jwise 		waddstr(slot_w, "   ");
    410  1.16     jwise 	wmove(slot_w, SLOT_Y-2, 0);
    411   1.1       cgd 	if (mf->RR)
    412  1.16     jwise 		wprintw(slot_w, "%dRR", mf->RR);
    413   1.1       cgd 	else
    414  1.16     jwise 		waddstr(slot_w, "   ");
    415   1.1       cgd 
    416   1.1       cgd #define Y	(SLOT_Y/2)
    417  1.16     jwise 	wmove(slot_w, 7, 1);
    418  1.16     jwise 	wprintw(slot_w,"%d", windspeed);
    419  1.16     jwise 	mvwaddch(slot_w, Y, 0, ' ');
    420  1.16     jwise 	mvwaddch(slot_w, Y, 2, ' ');
    421  1.16     jwise 	mvwaddch(slot_w, Y-1, 0, ' ');
    422  1.16     jwise 	mvwaddch(slot_w, Y-1, 1, ' ');
    423  1.16     jwise 	mvwaddch(slot_w, Y-1, 2, ' ');
    424  1.16     jwise 	mvwaddch(slot_w, Y+1, 0, ' ');
    425  1.16     jwise 	mvwaddch(slot_w, Y+1, 1, ' ');
    426  1.16     jwise 	mvwaddch(slot_w, Y+1, 2, ' ');
    427  1.16     jwise 	wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]);
    428   1.1       cgd 	switch (winddir) {
    429   1.1       cgd 	case 1:
    430   1.1       cgd 	case 5:
    431  1.16     jwise 		waddch(slot_w, '|');
    432   1.1       cgd 		break;
    433   1.1       cgd 	case 2:
    434   1.1       cgd 	case 6:
    435  1.16     jwise 		waddch(slot_w, '/');
    436   1.1       cgd 		break;
    437   1.1       cgd 	case 3:
    438   1.1       cgd 	case 7:
    439  1.16     jwise 		waddch(slot_w, '-');
    440   1.1       cgd 		break;
    441   1.1       cgd 	case 4:
    442   1.1       cgd 	case 8:
    443  1.16     jwise 		waddch(slot_w, '\\');
    444   1.1       cgd 		break;
    445   1.1       cgd 	}
    446  1.16     jwise 	mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+');
    447  1.16     jwise 	wrefresh(slot_w);
    448   1.1       cgd }
    449   1.1       cgd 
    450   1.7  christos void
    451  1.16     jwise draw_board(void)
    452   1.1       cgd {
    453   1.7  christos 	int n;
    454   1.1       cgd 
    455  1.16     jwise 	clear();
    456  1.16     jwise 	werase(view_w);
    457  1.16     jwise 	werase(slot_w);
    458  1.16     jwise 	werase(scroll_w);
    459  1.16     jwise 	werase(stat_w);
    460  1.16     jwise 	werase(turn_w);
    461   1.1       cgd 
    462   1.1       cgd 	sc_line = 0;
    463   1.1       cgd 
    464  1.16     jwise 	move(BOX_T, BOX_L);
    465   1.1       cgd 	for (n = 0; n < BOX_X; n++)
    466  1.16     jwise 		addch('-');
    467  1.16     jwise 	move(BOX_B, BOX_L);
    468   1.1       cgd 	for (n = 0; n < BOX_X; n++)
    469  1.16     jwise 		addch('-');
    470   1.1       cgd 	for (n = BOX_T+1; n < BOX_B; n++) {
    471  1.16     jwise 		mvaddch(n, BOX_L, '|');
    472  1.16     jwise 		mvaddch(n, BOX_R, '|');
    473   1.1       cgd 	}
    474  1.16     jwise 	mvaddch(BOX_T, BOX_L, '+');
    475  1.16     jwise 	mvaddch(BOX_T, BOX_R, '+');
    476  1.16     jwise 	mvaddch(BOX_B, BOX_L, '+');
    477  1.16     jwise 	mvaddch(BOX_B, BOX_R, '+');
    478  1.16     jwise 	refresh();
    479   1.1       cgd 
    480   1.1       cgd #define WSaIM "Wooden Ships & Iron Men"
    481  1.16     jwise 	wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2);
    482  1.16     jwise 	waddstr(view_w, WSaIM);
    483  1.16     jwise 	wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2);
    484  1.16     jwise 	waddstr(view_w, cc->name);
    485  1.16     jwise 	wrefresh(view_w);
    486   1.1       cgd 
    487  1.16     jwise 	move(LINE_T, LINE_L);
    488  1.16     jwise 	printw("Class %d %s (%d guns) '%s' (%c%c)",
    489   1.1       cgd 		mc->class,
    490   1.1       cgd 		classname[mc->class],
    491   1.1       cgd 		mc->guns,
    492   1.1       cgd 		ms->shipname,
    493   1.1       cgd 		colours(ms),
    494   1.1       cgd 		sterncolour(ms));
    495  1.16     jwise 	refresh();
    496   1.1       cgd }
    497   1.1       cgd 
    498  1.33  dholland /* Called after show_[od]bp. Shouldn't really exist... XXX */
    499  1.33  dholland void
    500  1.33  dholland display_refresh_slot_w(void)
    501  1.33  dholland {
    502  1.33  dholland 	blockalarm();
    503  1.33  dholland 	wrefresh(slot_w);
    504  1.33  dholland 	unblockalarm();
    505  1.33  dholland }
    506  1.33  dholland 
    507  1.33  dholland void
    508  1.33  dholland display_show_obp(int which, bool show)
    509  1.33  dholland {
    510  1.33  dholland 	wmove(slot_w, 0, which);
    511  1.33  dholland 	waddch(slot_w, show ? '1' + which : ' ');
    512  1.33  dholland 	mvwaddstr(slot_w, 1, 0, "OBP");
    513  1.33  dholland }
    514  1.33  dholland 
    515  1.33  dholland void
    516  1.33  dholland display_show_dbp(int which, bool show)
    517  1.33  dholland {
    518  1.33  dholland 	wmove(slot_w, 2, which);
    519  1.33  dholland 	waddch(slot_w, show ? '1' + which : ' ');
    520  1.33  dholland 	mvwaddstr(slot_w, 3, 0, "DBP");
    521  1.33  dholland }
    522  1.33  dholland 
    523   1.7  christos void
    524  1.16     jwise centerview(void)
    525   1.1       cgd {
    526   1.1       cgd 	viewrow = mf->row - VIEW_Y / 2;
    527   1.1       cgd 	viewcol = mf->col - VIEW_X / 2;
    528   1.1       cgd }
    529   1.1       cgd 
    530   1.7  christos void
    531  1.16     jwise upview(void)
    532   1.1       cgd {
    533   1.1       cgd 	viewrow -= VIEW_Y / 3;
    534   1.1       cgd }
    535   1.1       cgd 
    536   1.7  christos void
    537  1.16     jwise downview(void)
    538   1.1       cgd {
    539   1.1       cgd 	viewrow += VIEW_Y / 3;
    540   1.1       cgd }
    541   1.1       cgd 
    542   1.7  christos void
    543  1.16     jwise leftview(void)
    544   1.1       cgd {
    545   1.1       cgd 	viewcol -= VIEW_X / 5;
    546   1.1       cgd }
    547   1.1       cgd 
    548   1.7  christos void
    549  1.16     jwise rightview(void)
    550   1.1       cgd {
    551   1.1       cgd 	viewcol += VIEW_X / 5;
    552   1.1       cgd }
    553   1.1       cgd 
    554  1.17     jwise static void
    555  1.16     jwise adjustview(void)
    556   1.1       cgd {
    557   1.1       cgd 	if (dont_adjust)
    558   1.1       cgd 		return;
    559   1.1       cgd 	if (mf->row < viewrow + VIEW_Y/4)
    560   1.1       cgd 		viewrow = mf->row - (VIEW_Y - VIEW_Y/4);
    561   1.1       cgd 	else if (mf->row > viewrow + (VIEW_Y - VIEW_Y/4))
    562   1.1       cgd 		viewrow = mf->row - VIEW_Y/4;
    563   1.1       cgd 	if (mf->col < viewcol + VIEW_X/8)
    564   1.1       cgd 		viewcol = mf->col - (VIEW_X - VIEW_X/8);
    565   1.1       cgd 	else if (mf->col > viewcol + (VIEW_X - VIEW_X/8))
    566   1.1       cgd 		viewcol = mf->col - VIEW_X/8;
    567   1.1       cgd }
    568