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