]>
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
[] = "@(#)pl_7.c 5.7 (Berkeley) 2/28/91";
44 static char sc_hasprompt
;
45 static char *sc_prompt
;
51 /* initscr() already done in SCREENTEST() */
52 view_w
= newwin(VIEW_Y
, VIEW_X
, VIEW_T
, VIEW_L
);
53 slot_w
= newwin(SLOT_Y
, SLOT_X
, SLOT_T
, SLOT_L
);
54 scroll_w
= newwin(SCROLL_Y
, SCROLL_X
, SCROLL_T
, SCROLL_L
);
55 stat_w
= newwin(STAT_Y
, STAT_X
, STAT_T
, STAT_L
);
56 turn_w
= newwin(TURN_Y
, TURN_X
, TURN_T
, TURN_L
);
58 (void) leaveok(view_w
, 1);
59 (void) leaveok(slot_w
, 1);
60 (void) leaveok(stat_w
, 1);
61 (void) leaveok(turn_w
, 1);
65 (void) signal(SIGTSTP
, susp
);
74 /* alarm already turned off */
76 (void) wmove(scroll_w
, SCROLL_Y
- 1, 0);
77 (void) wclrtoeol(scroll_w
);
86 repaired
= loaded
= fired
= changed
= 0;
90 if (mf
->readyL
& R_LOADING
)
91 if (mf
->readyL
& R_DOUBLE
)
92 mf
->readyL
= R_LOADING
;
94 mf
->readyL
= R_LOADED
;
95 if (mf
->readyR
& R_LOADING
)
96 if (mf
->readyR
& R_DOUBLE
)
97 mf
->readyR
= R_LOADING
;
99 mf
->readyR
= R_LOADED
;
101 Write(W_DDEAD
, SHIP(0), 0, 0, 0, 0, 0);
104 (void) wmove(scroll_w
, sc_line
, 0);
105 (void) wclrtoeol(scroll_w
);
112 (void) wprintw(scroll_w
, "%s%s", sc_prompt
, sc_buf
);
115 Write(W_ALIVE
, SHIP(0), 0, 0, 0, 0, 0);
116 if (mf
->FS
&& (!mc
->rig1
|| windspeed
== 6))
117 Write(W_FS
, ms
, 0, 0, 0, 0, 0);
119 Write(W_FS
, ms
, 0, 2, 0, 0, 0);
123 if (mf
->captured
!= 0)
124 leave(LEAVE_CAPTURED
);
126 leave(LEAVE_HURRICAN
);
131 (void) signal(SIGALRM
, newturn
);
136 Signal(fmt
, ship
, a
, b
, c
, d
)
138 register struct ship
*ship
;
146 (void) wprintw(scroll_w
, fmt
, a
, b
, c
, d
);
148 (void) wprintw(scroll_w
, fmt
, ship
->shipname
,
149 colours(ship
), sterncolour(ship
), a
, b
, c
, d
);
155 if (++sc_line
>= SCROLL_Y
)
157 (void) wmove(scroll_w
, sc_line
, 0);
158 (void) wclrtoeol(scroll_w
);
168 (void)sprintf(buf
, p
, ship
->shipname
, colours(ship
),
175 (void) waddstr(scroll_w
, p
);
186 sgetch(p
, ship
, flag
)
195 (void) wrefresh(scroll_w
);
197 while ((c
= wgetch(scroll_w
)) == EOF
)
199 if (flag
&& c
>= ' ' && c
< 0x7f)
200 (void) waddch(scroll_w
, c
);
211 register char *p
= buf
;
213 prompt(pr
, (struct ship
*)0);
218 (void) wrefresh(scroll_w
);
220 while ((c
= wgetch(scroll_w
)) == EOF
)
229 (void) waddstr(scroll_w
, "\b \b");
234 if (c
>= ' ' && c
< 0x7f && p
< buf
+ n
- 1) {
236 (void) waddch(scroll_w
, c
);
238 (void) putchar(CTRL('g'));
249 (void) wrefresh(scroll_w
); /* move the cursor */
254 register struct ship
*sp
;
256 (void) werase(view_w
);
259 && sp
->file
->row
> viewrow
260 && sp
->file
->row
< viewrow
+ VIEW_Y
261 && sp
->file
->col
> viewcol
262 && sp
->file
->col
< viewcol
+ VIEW_X
) {
263 (void) wmove(view_w
, sp
->file
->row
- viewrow
,
264 sp
->file
->col
- viewcol
);
265 (void) waddch(view_w
, colours(sp
));
267 sternrow(sp
) - viewrow
,
268 sterncol(sp
) - viewcol
);
269 (void) waddch(view_w
, sterncolour(sp
));
272 (void) wrefresh(view_w
);
277 (void) wmove(turn_w
, 0, 0);
278 (void) wprintw(turn_w
, "%cTurn %d", dont_adjust
?'*':'-', turn
);
279 (void) wrefresh(turn_w
);
284 (void) wmove(stat_w
, STAT_1
, 0);
285 (void) wprintw(stat_w
, "Points %3d\n", mf
->points
);
286 (void) wprintw(stat_w
, "Fouls %2d\n", fouled(ms
));
287 (void) wprintw(stat_w
, "Grapples %2d\n", grappled(ms
));
289 (void) wmove(stat_w
, STAT_2
, 0);
290 (void) wprintw(stat_w
, " 0 %c(%c)\n",
291 maxmove(ms
, winddir
+ 3, -1) + '0',
292 maxmove(ms
, winddir
+ 3, 1) + '0');
293 (void) waddstr(stat_w
, " \\|/\n");
294 (void) wprintw(stat_w
, " -^-%c(%c)\n",
295 maxmove(ms
, winddir
+ 2, -1) + '0',
296 maxmove(ms
, winddir
+ 2, 1) + '0');
297 (void) waddstr(stat_w
, " /|\\\n");
298 (void) wprintw(stat_w
, " | %c(%c)\n",
299 maxmove(ms
, winddir
+ 1, -1) + '0',
300 maxmove(ms
, winddir
+ 1, 1) + '0');
301 (void) wprintw(stat_w
, " %c(%c)\n",
302 maxmove(ms
, winddir
, -1) + '0',
303 maxmove(ms
, winddir
, 1) + '0');
305 (void) wmove(stat_w
, STAT_3
, 0);
306 (void) wprintw(stat_w
, "Load %c%c %c%c\n",
307 loadname
[mf
->loadL
], readyname(mf
->readyL
),
308 loadname
[mf
->loadR
], readyname(mf
->readyR
));
309 (void) wprintw(stat_w
, "Hull %2d\n", mc
->hull
);
310 (void) wprintw(stat_w
, "Crew %2d %2d %2d\n",
311 mc
->crew1
, mc
->crew2
, mc
->crew3
);
312 (void) wprintw(stat_w
, "Guns %2d %2d\n", mc
->gunL
, mc
->gunR
);
313 (void) wprintw(stat_w
, "Carr %2d %2d\n", mc
->carL
, mc
->carR
);
314 (void) wprintw(stat_w
, "Rigg %d %d %d ", mc
->rig1
, mc
->rig2
, mc
->rig3
);
316 (void) waddch(stat_w
, '-');
318 (void) wprintw(stat_w
, "%d", mc
->rig4
);
319 (void) wrefresh(stat_w
);
324 if (!boarding(ms
, 0)) {
325 (void) mvwaddstr(slot_w
, 0, 0, " ");
326 (void) mvwaddstr(slot_w
, 1, 0, " ");
328 (void) mvwaddstr(slot_w
, 1, 0, "OBP");
329 if (!boarding(ms
, 1)) {
330 (void) mvwaddstr(slot_w
, 2, 0, " ");
331 (void) mvwaddstr(slot_w
, 3, 0, " ");
333 (void) mvwaddstr(slot_w
, 3, 0, "DBP");
335 (void) wmove(slot_w
, SLOT_Y
-4, 0);
337 (void) wprintw(slot_w
, "%dRH", mf
->RH
);
339 (void) waddstr(slot_w
, " ");
340 (void) wmove(slot_w
, SLOT_Y
-3, 0);
342 (void) wprintw(slot_w
, "%dRG", mf
->RG
);
344 (void) waddstr(slot_w
, " ");
345 (void) wmove(slot_w
, SLOT_Y
-2, 0);
347 (void) wprintw(slot_w
, "%dRR", mf
->RR
);
349 (void) waddstr(slot_w
, " ");
352 (void) wmove(slot_w
, 7, 1);
353 (void) wprintw(slot_w
,"%d", windspeed
);
354 (void) mvwaddch(slot_w
, Y
, 0, ' ');
355 (void) mvwaddch(slot_w
, Y
, 2, ' ');
356 (void) mvwaddch(slot_w
, Y
-1, 0, ' ');
357 (void) mvwaddch(slot_w
, Y
-1, 1, ' ');
358 (void) mvwaddch(slot_w
, Y
-1, 2, ' ');
359 (void) mvwaddch(slot_w
, Y
+1, 0, ' ');
360 (void) mvwaddch(slot_w
, Y
+1, 1, ' ');
361 (void) mvwaddch(slot_w
, Y
+1, 2, ' ');
362 (void) wmove(slot_w
, Y
- dr
[winddir
], 1 - dc
[winddir
]);
366 (void) waddch(slot_w
, '|');
370 (void) waddch(slot_w
, '/');
374 (void) waddch(slot_w
, '-');
378 (void) waddch(slot_w
, '\\');
381 (void) mvwaddch(slot_w
, Y
+ dr
[winddir
], 1 + dc
[winddir
], '+');
382 (void) wrefresh(slot_w
);
390 (void) werase(view_w
);
391 (void) werase(slot_w
);
392 (void) werase(scroll_w
);
393 (void) werase(stat_w
);
394 (void) werase(turn_w
);
398 (void) move(BOX_T
, BOX_L
);
399 for (n
= 0; n
< BOX_X
; n
++)
401 (void) move(BOX_B
, BOX_L
);
402 for (n
= 0; n
< BOX_X
; n
++)
404 for (n
= BOX_T
+1; n
< BOX_B
; n
++) {
405 (void) mvaddch(n
, BOX_L
, '|');
406 (void) mvaddch(n
, BOX_R
, '|');
408 (void) mvaddch(BOX_T
, BOX_L
, '+');
409 (void) mvaddch(BOX_T
, BOX_R
, '+');
410 (void) mvaddch(BOX_B
, BOX_L
, '+');
411 (void) mvaddch(BOX_B
, BOX_R
, '+');
414 #define WSaIM "Wooden Ships & Iron Men"
415 (void) wmove(view_w
, 2, (VIEW_X
- sizeof WSaIM
- 1) / 2);
416 (void) waddstr(view_w
, WSaIM
);
417 (void) wmove(view_w
, 4, (VIEW_X
- strlen(cc
->name
)) / 2);
418 (void) waddstr(view_w
, cc
->name
);
419 (void) wrefresh(view_w
);
421 (void) move(LINE_T
, LINE_L
);
422 (void) printw("Class %d %s (%d guns) '%s' (%c%c)",
424 classname
[mc
->class],
434 viewrow
= mf
->row
- VIEW_Y
/ 2;
435 viewcol
= mf
->col
- VIEW_X
/ 2;
440 viewrow
-= VIEW_Y
/ 3;
445 viewrow
+= VIEW_Y
/ 3;
450 viewcol
-= VIEW_X
/ 5;
455 viewcol
+= VIEW_X
/ 5;
462 if (mf
->row
< viewrow
+ VIEW_Y
/4)
463 viewrow
= mf
->row
- (VIEW_Y
- VIEW_Y
/4);
464 else if (mf
->row
> viewrow
+ (VIEW_Y
- VIEW_Y
/4))
465 viewrow
= mf
->row
- VIEW_Y
/4;
466 if (mf
->col
< viewcol
+ VIEW_X
/8)
467 viewcol
= mf
->col
- (VIEW_X
- VIEW_X
/8);
468 else if (mf
->col
> viewcol
+ (VIEW_X
- VIEW_X
/8))
469 viewcol
= mf
->col
- VIEW_X
/8;
478 (void) signal(SIGTSTP
, susp
);