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