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