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