]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - gomoku/bdisp.c
1 /* $NetBSD: bdisp.c,v 1.8 2003/08/07 09:37:16 agc Exp $ */
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/cdefs.h>
38 static char sccsid
[] = "@(#)bdisp.c 8.2 (Berkeley) 5/3/95";
40 __RCSID("$NetBSD: bdisp.c,v 1.8 2003/08/07 09:37:16 agc Exp $");
48 #define SCRNH 24 /* assume 24 lines for the moment */
49 #define SCRNW 80 /* assume 80 chars for the moment */
52 static char pcolor
[] = "*O.?";
54 extern int interactive
;
58 * Initialize screen display.
67 leaveok(stdscr
, TRUE
);
71 * Restore screen display.
77 leaveok(stdscr
, FALSE
);
85 * Initialize board display.
93 for (i
= 1; i
< BSZ1
; i
++) {
97 /* left and right edges */
98 for (j
= BSZ1
; --j
> 0; ) {
101 move(20 - j
, 2 * BSZ1
+ 1);
105 for (i
= 1; i
< BSZ1
; i
++) {
111 addstr("# black white");
117 * Update who is playing whom.
127 i
= 6 - strlen(plyr
[BLACK
]) / 2;
128 move(21, i
> 0 ? i
: 0);
129 printw("BLACK/%s", plyr
[BLACK
]);
130 i
= 30 - strlen(plyr
[WHITE
]) / 2;
132 printw("WHITE/%s", plyr
[WHITE
]);
140 * Update the board display after a move.
148 for (j
= BSZ1
; --j
> 0; ) {
149 for (i
= 1; i
< BSZ1
; i
++) {
150 move(BSZ1
- j
, 2 * i
+ 1);
151 sp
= &board
[i
+ j
* BSZ1
];
152 if (debug
> 1 && sp
->s_occ
== EMPTY
) {
153 if (sp
->s_flg
& IFLAGALL
)
155 else if (sp
->s_flg
& CFLAGALL
)
160 c
= pcolor
[sp
->s_occ
];
169 * Dump board display to a file.
179 fprintf(fp
, " A B C D E F G H J K L M N O P Q R S T\n");
181 for (j
= BSZ1
; --j
> 0; ) {
183 fprintf(fp
, "%2d ", j
);
184 for (i
= 1; i
< BSZ1
; i
++) {
185 sp
= &board
[i
+ j
* BSZ1
];
186 if (debug
> 1 && sp
->s_occ
== EMPTY
) {
187 if (sp
->s_flg
& IFLAGALL
)
189 else if (sp
->s_flg
& CFLAGALL
)
194 c
= pcolor
[sp
->s_occ
];
199 fprintf(fp
, "%d\n", j
);
203 fprintf(fp
, " A B C D E F G H J K L M N O P Q R S T\n");
208 * Display a transcript entry
215 if (++lastline
>= SCRNH
- 1) {
220 addnstr(str
, SCRNW
- 46 - 1);
222 move(lastline
+ 1, 46);
227 * Display a question.
234 int len
= strlen(str
);
253 end
= buf
+ size
- 1; /* save room for the '\0' */
254 while (cp
< end
&& (c
= getchar()) != EOF
&& c
!= '\n' && c
!= '\r') {