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