]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - sail/pl_7.c
2 * Copyright (c) 1983 Regents of the University of California.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 /*static char sccsid[] = "from: @(#)pl_7.c 5.7 (Berkeley) 2/28/91";*/
36 static char rcsid
[] = "$Id: pl_7.c,v 1.2 1993/08/01 18:51:35 mycroft Exp $";
45 static char sc_hasprompt
;
46 static char *sc_prompt
;
52 /* initscr() already done in SCREENTEST() */
53 view_w
= newwin(VIEW_Y
, VIEW_X
, VIEW_T
, VIEW_L
);
54 slot_w
= newwin(SLOT_Y
, SLOT_X
, SLOT_T
, SLOT_L
);
55 scroll_w
= newwin(SCROLL_Y
, SCROLL_X
, SCROLL_T
, SCROLL_L
);
56 stat_w
= newwin(STAT_Y
, STAT_X
, STAT_T
, STAT_L
);
57 turn_w
= newwin(TURN_Y
, TURN_X
, TURN_T
, TURN_L
);
59 (void) leaveok(view_w
, 1);
60 (void) leaveok(slot_w
, 1);
61 (void) leaveok(stat_w
, 1);
62 (void) leaveok(turn_w
, 1);
66 (void) signal(SIGTSTP
, susp
);
75 /* alarm already turned off */
77 (void) wmove(scroll_w
, SCROLL_Y
- 1, 0);
78 (void) wclrtoeol(scroll_w
);
87 repaired
= loaded
= fired
= changed
= 0;
91 if (mf
->readyL
& R_LOADING
)
92 if (mf
->readyL
& R_DOUBLE
)
93 mf
->readyL
= R_LOADING
;
95 mf
->readyL
= R_LOADED
;
96 if (mf
->readyR
& R_LOADING
)
97 if (mf
->readyR
& R_DOUBLE
)
98 mf
->readyR
= R_LOADING
;
100 mf
->readyR
= R_LOADED
;
102 Write(W_DDEAD
, SHIP(0), 0, 0, 0, 0, 0);
105 (void) wmove(scroll_w
, sc_line
, 0);
106 (void) wclrtoeol(scroll_w
);
113 (void) wprintw(scroll_w
, "%s%s", sc_prompt
, sc_buf
);
116 Write(W_ALIVE
, SHIP(0), 0, 0, 0, 0, 0);
117 if (mf
->FS
&& (!mc
->rig1
|| windspeed
== 6))
118 Write(W_FS
, ms
, 0, 0, 0, 0, 0);
120 Write(W_FS
, ms
, 0, 2, 0, 0, 0);
124 if (mf
->captured
!= 0)
125 leave(LEAVE_CAPTURED
);
127 leave(LEAVE_HURRICAN
);
132 (void) signal(SIGALRM
, newturn
);
137 Signal(fmt
, ship
, a
, b
, c
, d
)
139 register struct ship
*ship
;
147 (void) wprintw(scroll_w
, fmt
, a
, b
, c
, d
);
149 (void) wprintw(scroll_w
, fmt
, ship
->shipname
,
150 colours(ship
), sterncolour(ship
), a
, b
, c
, d
);
156 if (++sc_line
>= SCROLL_Y
)
158 (void) wmove(scroll_w
, sc_line
, 0);
159 (void) wclrtoeol(scroll_w
);
169 (void)sprintf(buf
, p
, ship
->shipname
, colours(ship
),
176 (void) waddstr(scroll_w
, p
);
187 sgetch(p
, ship
, flag
)
196 (void) wrefresh(scroll_w
);
198 while ((c
= wgetch(scroll_w
)) == EOF
)
200 if (flag
&& c
>= ' ' && c
< 0x7f)
201 (void) waddch(scroll_w
, c
);
212 register char *p
= buf
;
214 prompt(pr
, (struct ship
*)0);
219 (void) wrefresh(scroll_w
);
221 while ((c
= wgetch(scroll_w
)) == EOF
)
230 (void) waddstr(scroll_w
, "\b \b");
235 if (c
>= ' ' && c
< 0x7f && p
< buf
+ n
- 1) {
237 (void) waddch(scroll_w
, c
);
239 (void) putchar(CTRL('g'));
250 (void) wrefresh(scroll_w
); /* move the cursor */
255 register struct ship
*sp
;
257 (void) werase(view_w
);
260 && sp
->file
->row
> viewrow
261 && sp
->file
->row
< viewrow
+ VIEW_Y
262 && sp
->file
->col
> viewcol
263 && sp
->file
->col
< viewcol
+ VIEW_X
) {
264 (void) wmove(view_w
, sp
->file
->row
- viewrow
,
265 sp
->file
->col
- viewcol
);
266 (void) waddch(view_w
, colours(sp
));
268 sternrow(sp
) - viewrow
,
269 sterncol(sp
) - viewcol
);
270 (void) waddch(view_w
, sterncolour(sp
));
273 (void) wrefresh(view_w
);
278 (void) wmove(turn_w
, 0, 0);
279 (void) wprintw(turn_w
, "%cTurn %d", dont_adjust
?'*':'-', turn
);
280 (void) wrefresh(turn_w
);
285 (void) wmove(stat_w
, STAT_1
, 0);
286 (void) wprintw(stat_w
, "Points %3d\n", mf
->points
);
287 (void) wprintw(stat_w
, "Fouls %2d\n", fouled(ms
));
288 (void) wprintw(stat_w
, "Grapples %2d\n", grappled(ms
));
290 (void) wmove(stat_w
, STAT_2
, 0);
291 (void) wprintw(stat_w
, " 0 %c(%c)\n",
292 maxmove(ms
, winddir
+ 3, -1) + '0',
293 maxmove(ms
, winddir
+ 3, 1) + '0');
294 (void) waddstr(stat_w
, " \\|/\n");
295 (void) wprintw(stat_w
, " -^-%c(%c)\n",
296 maxmove(ms
, winddir
+ 2, -1) + '0',
297 maxmove(ms
, winddir
+ 2, 1) + '0');
298 (void) waddstr(stat_w
, " /|\\\n");
299 (void) wprintw(stat_w
, " | %c(%c)\n",
300 maxmove(ms
, winddir
+ 1, -1) + '0',
301 maxmove(ms
, winddir
+ 1, 1) + '0');
302 (void) wprintw(stat_w
, " %c(%c)\n",
303 maxmove(ms
, winddir
, -1) + '0',
304 maxmove(ms
, winddir
, 1) + '0');
306 (void) wmove(stat_w
, STAT_3
, 0);
307 (void) wprintw(stat_w
, "Load %c%c %c%c\n",
308 loadname
[mf
->loadL
], readyname(mf
->readyL
),
309 loadname
[mf
->loadR
], readyname(mf
->readyR
));
310 (void) wprintw(stat_w
, "Hull %2d\n", mc
->hull
);
311 (void) wprintw(stat_w
, "Crew %2d %2d %2d\n",
312 mc
->crew1
, mc
->crew2
, mc
->crew3
);
313 (void) wprintw(stat_w
, "Guns %2d %2d\n", mc
->gunL
, mc
->gunR
);
314 (void) wprintw(stat_w
, "Carr %2d %2d\n", mc
->carL
, mc
->carR
);
315 (void) wprintw(stat_w
, "Rigg %d %d %d ", mc
->rig1
, mc
->rig2
, mc
->rig3
);
317 (void) waddch(stat_w
, '-');
319 (void) wprintw(stat_w
, "%d", mc
->rig4
);
320 (void) wrefresh(stat_w
);
325 if (!boarding(ms
, 0)) {
326 (void) mvwaddstr(slot_w
, 0, 0, " ");
327 (void) mvwaddstr(slot_w
, 1, 0, " ");
329 (void) mvwaddstr(slot_w
, 1, 0, "OBP");
330 if (!boarding(ms
, 1)) {
331 (void) mvwaddstr(slot_w
, 2, 0, " ");
332 (void) mvwaddstr(slot_w
, 3, 0, " ");
334 (void) mvwaddstr(slot_w
, 3, 0, "DBP");
336 (void) wmove(slot_w
, SLOT_Y
-4, 0);
338 (void) wprintw(slot_w
, "%dRH", mf
->RH
);
340 (void) waddstr(slot_w
, " ");
341 (void) wmove(slot_w
, SLOT_Y
-3, 0);
343 (void) wprintw(slot_w
, "%dRG", mf
->RG
);
345 (void) waddstr(slot_w
, " ");
346 (void) wmove(slot_w
, SLOT_Y
-2, 0);
348 (void) wprintw(slot_w
, "%dRR", mf
->RR
);
350 (void) waddstr(slot_w
, " ");
353 (void) wmove(slot_w
, 7, 1);
354 (void) wprintw(slot_w
,"%d", windspeed
);
355 (void) mvwaddch(slot_w
, Y
, 0, ' ');
356 (void) mvwaddch(slot_w
, Y
, 2, ' ');
357 (void) mvwaddch(slot_w
, Y
-1, 0, ' ');
358 (void) mvwaddch(slot_w
, Y
-1, 1, ' ');
359 (void) mvwaddch(slot_w
, Y
-1, 2, ' ');
360 (void) mvwaddch(slot_w
, Y
+1, 0, ' ');
361 (void) mvwaddch(slot_w
, Y
+1, 1, ' ');
362 (void) mvwaddch(slot_w
, Y
+1, 2, ' ');
363 (void) wmove(slot_w
, Y
- dr
[winddir
], 1 - dc
[winddir
]);
367 (void) waddch(slot_w
, '|');
371 (void) waddch(slot_w
, '/');
375 (void) waddch(slot_w
, '-');
379 (void) waddch(slot_w
, '\\');
382 (void) mvwaddch(slot_w
, Y
+ dr
[winddir
], 1 + dc
[winddir
], '+');
383 (void) wrefresh(slot_w
);
391 (void) werase(view_w
);
392 (void) werase(slot_w
);
393 (void) werase(scroll_w
);
394 (void) werase(stat_w
);
395 (void) werase(turn_w
);
399 (void) move(BOX_T
, BOX_L
);
400 for (n
= 0; n
< BOX_X
; n
++)
402 (void) move(BOX_B
, BOX_L
);
403 for (n
= 0; n
< BOX_X
; n
++)
405 for (n
= BOX_T
+1; n
< BOX_B
; n
++) {
406 (void) mvaddch(n
, BOX_L
, '|');
407 (void) mvaddch(n
, BOX_R
, '|');
409 (void) mvaddch(BOX_T
, BOX_L
, '+');
410 (void) mvaddch(BOX_T
, BOX_R
, '+');
411 (void) mvaddch(BOX_B
, BOX_L
, '+');
412 (void) mvaddch(BOX_B
, BOX_R
, '+');
415 #define WSaIM "Wooden Ships & Iron Men"
416 (void) wmove(view_w
, 2, (VIEW_X
- sizeof WSaIM
- 1) / 2);
417 (void) waddstr(view_w
, WSaIM
);
418 (void) wmove(view_w
, 4, (VIEW_X
- strlen(cc
->name
)) / 2);
419 (void) waddstr(view_w
, cc
->name
);
420 (void) wrefresh(view_w
);
422 (void) move(LINE_T
, LINE_L
);
423 (void) printw("Class %d %s (%d guns) '%s' (%c%c)",
425 classname
[mc
->class],
435 viewrow
= mf
->row
- VIEW_Y
/ 2;
436 viewcol
= mf
->col
- VIEW_X
/ 2;
441 viewrow
-= VIEW_Y
/ 3;
446 viewrow
+= VIEW_Y
/ 3;
451 viewcol
-= VIEW_X
/ 5;
456 viewcol
+= VIEW_X
/ 5;
463 if (mf
->row
< viewrow
+ VIEW_Y
/4)
464 viewrow
= mf
->row
- (VIEW_Y
- VIEW_Y
/4);
465 else if (mf
->row
> viewrow
+ (VIEW_Y
- VIEW_Y
/4))
466 viewrow
= mf
->row
- VIEW_Y
/4;
467 if (mf
->col
< viewcol
+ VIEW_X
/8)
468 viewcol
= mf
->col
- (VIEW_X
- VIEW_X
/8);
469 else if (mf
->col
> viewcol
+ (VIEW_X
- VIEW_X
/8))
470 viewcol
= mf
->col
- VIEW_X
/8;
479 (void) signal(SIGTSTP
, susp
);