]>
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.5 1993/11/10 15:59:04 cgd 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);
69 /* alarm already turned off */
71 (void) wmove(scroll_w
, SCROLL_Y
- 1, 0);
72 (void) wclrtoeol(scroll_w
);
81 repaired
= loaded
= fired
= changed
= 0;
85 if (mf
->readyL
& R_LOADING
)
86 if (mf
->readyL
& R_DOUBLE
)
87 mf
->readyL
= R_LOADING
;
89 mf
->readyL
= R_LOADED
;
90 if (mf
->readyR
& R_LOADING
)
91 if (mf
->readyR
& R_DOUBLE
)
92 mf
->readyR
= R_LOADING
;
94 mf
->readyR
= R_LOADED
;
96 Write(W_DDEAD
, SHIP(0), 0, 0, 0, 0, 0);
99 (void) wmove(scroll_w
, sc_line
, 0);
100 (void) wclrtoeol(scroll_w
);
107 (void) wprintw(scroll_w
, "%s%s", sc_prompt
, sc_buf
);
110 Write(W_ALIVE
, SHIP(0), 0, 0, 0, 0, 0);
111 if (mf
->FS
&& (!mc
->rig1
|| windspeed
== 6))
112 Write(W_FS
, ms
, 0, 0, 0, 0, 0);
114 Write(W_FS
, ms
, 0, 2, 0, 0, 0);
118 if (mf
->captured
!= 0)
119 leave(LEAVE_CAPTURED
);
121 leave(LEAVE_HURRICAN
);
126 (void) signal(SIGALRM
, newturn
);
131 Signal(fmt
, ship
, a
, b
, c
, d
)
133 register struct ship
*ship
;
141 (void) wprintw(scroll_w
, fmt
, a
, b
, c
, d
);
143 (void) wprintw(scroll_w
, fmt
, ship
->shipname
,
144 colours(ship
), sterncolour(ship
), a
, b
, c
, d
);
150 if (++sc_line
>= SCROLL_Y
)
152 (void) wmove(scroll_w
, sc_line
, 0);
153 (void) wclrtoeol(scroll_w
);
163 (void)sprintf(buf
, p
, ship
->shipname
, colours(ship
),
170 (void) waddstr(scroll_w
, p
);
181 sgetch(p
, ship
, flag
)
190 (void) wrefresh(scroll_w
);
192 while ((c
= wgetch(scroll_w
)) == EOF
)
194 if (flag
&& c
>= ' ' && c
< 0x7f)
195 (void) waddch(scroll_w
, c
);
206 register char *p
= buf
;
208 prompt(pr
, (struct ship
*)0);
213 (void) wrefresh(scroll_w
);
215 while ((c
= wgetch(scroll_w
)) == EOF
)
224 (void) waddstr(scroll_w
, "\b \b");
229 if (c
>= ' ' && c
< 0x7f && p
< buf
+ n
- 1) {
231 (void) waddch(scroll_w
, c
);
233 (void) putchar('\a');
244 (void) wrefresh(scroll_w
); /* move the cursor */
249 register struct ship
*sp
;
251 (void) werase(view_w
);
254 && sp
->file
->row
> viewrow
255 && sp
->file
->row
< viewrow
+ VIEW_Y
256 && sp
->file
->col
> viewcol
257 && sp
->file
->col
< viewcol
+ VIEW_X
) {
258 (void) wmove(view_w
, sp
->file
->row
- viewrow
,
259 sp
->file
->col
- viewcol
);
260 (void) waddch(view_w
, colours(sp
));
262 sternrow(sp
) - viewrow
,
263 sterncol(sp
) - viewcol
);
264 (void) waddch(view_w
, sterncolour(sp
));
267 (void) wrefresh(view_w
);
272 (void) wmove(turn_w
, 0, 0);
273 (void) wprintw(turn_w
, "%cTurn %d", dont_adjust
?'*':'-', turn
);
274 (void) wrefresh(turn_w
);
279 (void) wmove(stat_w
, STAT_1
, 0);
280 (void) wprintw(stat_w
, "Points %3d\n", mf
->points
);
281 (void) wprintw(stat_w
, "Fouls %2d\n", fouled(ms
));
282 (void) wprintw(stat_w
, "Grapples %2d\n", grappled(ms
));
284 (void) wmove(stat_w
, STAT_2
, 0);
285 (void) wprintw(stat_w
, " 0 %c(%c)\n",
286 maxmove(ms
, winddir
+ 3, -1) + '0',
287 maxmove(ms
, winddir
+ 3, 1) + '0');
288 (void) waddstr(stat_w
, " \\|/\n");
289 (void) wprintw(stat_w
, " -^-%c(%c)\n",
290 maxmove(ms
, winddir
+ 2, -1) + '0',
291 maxmove(ms
, winddir
+ 2, 1) + '0');
292 (void) waddstr(stat_w
, " /|\\\n");
293 (void) wprintw(stat_w
, " | %c(%c)\n",
294 maxmove(ms
, winddir
+ 1, -1) + '0',
295 maxmove(ms
, winddir
+ 1, 1) + '0');
296 (void) wprintw(stat_w
, " %c(%c)\n",
297 maxmove(ms
, winddir
, -1) + '0',
298 maxmove(ms
, winddir
, 1) + '0');
300 (void) wmove(stat_w
, STAT_3
, 0);
301 (void) wprintw(stat_w
, "Load %c%c %c%c\n",
302 loadname
[mf
->loadL
], readyname(mf
->readyL
),
303 loadname
[mf
->loadR
], readyname(mf
->readyR
));
304 (void) wprintw(stat_w
, "Hull %2d\n", mc
->hull
);
305 (void) wprintw(stat_w
, "Crew %2d %2d %2d\n",
306 mc
->crew1
, mc
->crew2
, mc
->crew3
);
307 (void) wprintw(stat_w
, "Guns %2d %2d\n", mc
->gunL
, mc
->gunR
);
308 (void) wprintw(stat_w
, "Carr %2d %2d\n", mc
->carL
, mc
->carR
);
309 (void) wprintw(stat_w
, "Rigg %d %d %d ", mc
->rig1
, mc
->rig2
, mc
->rig3
);
311 (void) waddch(stat_w
, '-');
313 (void) wprintw(stat_w
, "%d", mc
->rig4
);
314 (void) wrefresh(stat_w
);
319 if (!boarding(ms
, 0)) {
320 (void) mvwaddstr(slot_w
, 0, 0, " ");
321 (void) mvwaddstr(slot_w
, 1, 0, " ");
323 (void) mvwaddstr(slot_w
, 1, 0, "OBP");
324 if (!boarding(ms
, 1)) {
325 (void) mvwaddstr(slot_w
, 2, 0, " ");
326 (void) mvwaddstr(slot_w
, 3, 0, " ");
328 (void) mvwaddstr(slot_w
, 3, 0, "DBP");
330 (void) wmove(slot_w
, SLOT_Y
-4, 0);
332 (void) wprintw(slot_w
, "%dRH", mf
->RH
);
334 (void) waddstr(slot_w
, " ");
335 (void) wmove(slot_w
, SLOT_Y
-3, 0);
337 (void) wprintw(slot_w
, "%dRG", mf
->RG
);
339 (void) waddstr(slot_w
, " ");
340 (void) wmove(slot_w
, SLOT_Y
-2, 0);
342 (void) wprintw(slot_w
, "%dRR", mf
->RR
);
344 (void) waddstr(slot_w
, " ");
347 (void) wmove(slot_w
, 7, 1);
348 (void) wprintw(slot_w
,"%d", windspeed
);
349 (void) mvwaddch(slot_w
, Y
, 0, ' ');
350 (void) mvwaddch(slot_w
, Y
, 2, ' ');
351 (void) mvwaddch(slot_w
, Y
-1, 0, ' ');
352 (void) mvwaddch(slot_w
, Y
-1, 1, ' ');
353 (void) mvwaddch(slot_w
, Y
-1, 2, ' ');
354 (void) mvwaddch(slot_w
, Y
+1, 0, ' ');
355 (void) mvwaddch(slot_w
, Y
+1, 1, ' ');
356 (void) mvwaddch(slot_w
, Y
+1, 2, ' ');
357 (void) wmove(slot_w
, Y
- dr
[winddir
], 1 - dc
[winddir
]);
361 (void) waddch(slot_w
, '|');
365 (void) waddch(slot_w
, '/');
369 (void) waddch(slot_w
, '-');
373 (void) waddch(slot_w
, '\\');
376 (void) mvwaddch(slot_w
, Y
+ dr
[winddir
], 1 + dc
[winddir
], '+');
377 (void) wrefresh(slot_w
);
385 (void) werase(view_w
);
386 (void) werase(slot_w
);
387 (void) werase(scroll_w
);
388 (void) werase(stat_w
);
389 (void) werase(turn_w
);
393 (void) move(BOX_T
, BOX_L
);
394 for (n
= 0; n
< BOX_X
; n
++)
396 (void) move(BOX_B
, BOX_L
);
397 for (n
= 0; n
< BOX_X
; n
++)
399 for (n
= BOX_T
+1; n
< BOX_B
; n
++) {
400 (void) mvaddch(n
, BOX_L
, '|');
401 (void) mvaddch(n
, BOX_R
, '|');
403 (void) mvaddch(BOX_T
, BOX_L
, '+');
404 (void) mvaddch(BOX_T
, BOX_R
, '+');
405 (void) mvaddch(BOX_B
, BOX_L
, '+');
406 (void) mvaddch(BOX_B
, BOX_R
, '+');
409 #define WSaIM "Wooden Ships & Iron Men"
410 (void) wmove(view_w
, 2, (VIEW_X
- sizeof WSaIM
- 1) / 2);
411 (void) waddstr(view_w
, WSaIM
);
412 (void) wmove(view_w
, 4, (VIEW_X
- strlen(cc
->name
)) / 2);
413 (void) waddstr(view_w
, cc
->name
);
414 (void) wrefresh(view_w
);
416 (void) move(LINE_T
, LINE_L
);
417 (void) printw("Class %d %s (%d guns) '%s' (%c%c)",
419 classname
[mc
->class],
429 viewrow
= mf
->row
- VIEW_Y
/ 2;
430 viewcol
= mf
->col
- VIEW_X
/ 2;
435 viewrow
-= VIEW_Y
/ 3;
440 viewrow
+= VIEW_Y
/ 3;
445 viewcol
-= VIEW_X
/ 5;
450 viewcol
+= VIEW_X
/ 5;
457 if (mf
->row
< viewrow
+ VIEW_Y
/4)
458 viewrow
= mf
->row
- (VIEW_Y
- VIEW_Y
/4);
459 else if (mf
->row
> viewrow
+ (VIEW_Y
- VIEW_Y
/4))
460 viewrow
= mf
->row
- VIEW_Y
/4;
461 if (mf
->col
< viewcol
+ VIEW_X
/8)
462 viewcol
= mf
->col
- (VIEW_X
- VIEW_X
/8);
463 else if (mf
->col
> viewcol
+ (VIEW_X
- VIEW_X
/8))
464 viewcol
= mf
->col
- VIEW_X
/8;