|
|
1.1 root 1: /*
2: * Copyright (c) 1980 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: static char sccsid[] = "@(#)board.c 5.3 (Berkeley) 6/18/88";
20: #endif /* not lint */
21:
22: #include "back.h"
23:
24: static int i, j, k;
25: static char ln[60];
26:
27: wrboard () {
28: register int l;
29: static char bl[] =
30: "| | | |\n";
31: static char sv[] =
32: "| | | | \n";
33:
34: fixtty (noech);
35: clear();
36:
37: if (tflag) {
38: fboard();
39: goto lastline;
40: }
41:
42: writel ("_____________________________________________________\n");
43: writel (bl);
44: strcpy (ln,bl);
45: for (j = 1; j < 50; j += 4) {
46: k = j/4+(j > 24? 12: 13);
47: ln[j+1] = k%10+'0';
48: ln[j] = k/10+'0';
49: if (j == 21)
50: j += 4;
51: }
52: writel (ln);
53: for (i = 0; i < 5; i++) {
54: strcpy (ln,sv);
55: for (j = 1; j < 50; j += 4) {
56: k = j/4+(j > 24? 12: 13);
57: wrbsub ();
58: if (j == 21)
59: j += 4;
60: }
61: if (-board[25] > i)
62: ln[26] = 'w';
63: if (-board[25] > i+5)
64: ln[25] = 'w';
65: if (-board[25] > i+10)
66: ln[27] = 'w';
67: l = 53;
68: if (off[1] > i || (off[1] < 0 && off[1]+15 > i)) {
69: ln[54] = 'r';
70: l = 55;
71: }
72: if (off[1] > i+5 || (off[1] < 0 && off[1]+15 > i+5)) {
73: ln[55] = 'r';
74: l = 56;
75: }
76: if (off[1] > i+10 || (off[1] < 0 && off[1]+15 > i+10)) {
77: ln[56] = 'r';
78: l = 57;
79: }
80: ln[l++] = '\n';
81: ln[l] = '\0';
82: writel (ln);
83: }
84: strcpy (ln,bl);
85: ln[25] = 'B';
86: ln[26] = 'A';
87: ln[27] = 'R';
88: writel (ln);
89: strcpy (ln,sv);
90: for (i = 4; i > -1; i--) {
91: for (j = 1; j < 50; j += 4) {
92: k = ((j > 24? 53: 49)-j)/4;
93: wrbsub();
94: if (j == 21)
95: j += 4;
96: }
97: if (board[0] > i)
98: ln[26] = 'r';
99: if (board[0] > i+5)
100: ln[25] = 'r';
101: if (board[0] > i+10)
102: ln[27] = 'r';
103: l = 53;
104: if (off[0] > i || (off[0] < 0 && off[0]+15 > i)) {
105: ln[54] = 'w';
106: l = 55;
107: }
108: if (off[0] > i+5 || (off[0] < 0 && off[0]+15 > i+5)) {
109: ln[55] = 'w';
110: l = 56;
111: }
112: if (off[0] > i+10 || (off[0] < 0 && off[0]+15 > i+10)) {
113: ln[56] = 'w';
114: l = 57;
115: }
116: ln[l++] = '\n';
117: ln[l] = '\0';
118: writel (ln);
119: }
120: strcpy (ln,bl);
121: for (j = 1; j < 50; j += 4) {
122: k = ((j > 24? 53: 49)-j)/4;
123: ln[j+1] = k%10+'0';
124: if (k > 9)
125: ln[j] = k/10+'0';
126: if (j == 21)
127: j += 4;
128: }
129: writel (ln);
130: writel ("|_______________________|___|_______________________|\n");
131:
132: lastline:
133: gwrite ();
134: if (tflag)
135: curmove (18,0);
136: else {
137: writec ('\n');
138: writec ('\n');
139: }
140: fixtty(raw);
141: }
142:
143: wrbsub () {
144: register int m;
145: register char d;
146:
147: if (board[k] > 0) {
148: m = board[k];
149: d = 'r';
150: } else {
151: m = -board[k];
152: d = 'w';
153: }
154: if (m>i)
155: ln[j+1] = d;
156: if (m>i+5)
157: ln[j] = d;
158: if (m>i+10)
159: ln[j+2] = d;
160: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.