1: #include "old.h"
2:
3: rline()
4: {
5: char *p1;
6: int c;
7:
8: p1 = sbuf;
9: while((c = getchar()) != '\n')
10: if(c <= 0)
11: onhup(); else
12: *p1++ = c;
13: *p1++ = '\0';
14: }
15:
16: getchar()
17: {
18: int c;
19:
20: loop:
21: c = 0;
22: read(0, &c, 1);
23: if(c == 0 && intrp) {
24: intrp = 0;
25: goto loop;
26: }
27: intrp = 0;
28: return(c);
29: }
30:
31: pboard()
32: {
33: int i, x, y, c, p;
34:
35: c = 0;
36: i = 0;
37: x = 8;
38: while(x--) {
39: if(!mantom || mfmt)
40: putchar('1'+x); else
41: putchar('8'-x);
42: putchar(' ');
43: c++;
44: y = 8;
45: while(y--) {
46: c++;
47: putchar(' ');
48: if(p = board[i++])
49: putchar("kqrbnp PNBRQK"[p+6]); else
50: if((c&1)!=0)
51: putchar('*'); else
52: putchar('-');
53: }
54: putchar('\n');
55: if(intrp)
56: return;
57: }
58: if(mfmt)
59: printf("\n a b c d e f g h"); else
60: printf("\n q q q q k k k k\n r n b b n r");
61: printf("\n");
62: }
63:
64: out1(m)
65: {
66: printf("%d. ", moveno);
67: if(mantom)
68: printf("... ");
69: out(m);
70: putchar('\n');
71: }
72:
73: out(m)
74: int m;
75: {
76: int from, to, epf, pmf;
77:
78: from = m>>8;
79: to = m&0377;
80: if(mfmt) {
81: algco(from);
82: algco(to);
83: return;
84: }
85: mantom? bmove(m): wmove(m);
86: epf = pmf = 0;
87: switch(amp[-1]) {
88:
89: case 0:
90: case 1:
91: stdp(board[to]);
92: ed:
93: putchar('/');
94: stdb(from);
95: if(amp[-2]) {
96: putchar('x');
97: stdp(amp[-2]);
98: putchar('/');
99: } else
100: putchar('-');
101: stdb(to);
102: break;
103:
104: case 3:
105: putchar('o');
106: putchar('-');
107:
108: case 2:
109: putchar('o');
110: putchar('-');
111: putchar('o');
112: break;
113:
114: case 4:
115: epf = 1;
116: putchar('p');
117: goto ed;
118:
119: case 5:
120: pmf = 1;
121: putchar('p');
122: goto ed;
123: }
124: if(pmf) {
125: putchar('(');
126: putchar('q');
127: putchar(')');
128: }
129: if(epf) {
130: putchar('e');
131: putchar('p');
132: }
133: if(check())
134: putchar('+');
135: mantom? bremove(): wremove();
136: }
137:
138: stdp(p)
139: int p;
140: {
141:
142: if(p < 0)
143: p = -p;
144: p = "ppnbrqk"[p];
145: putchar(p);
146: }
147:
148: stdb(b)
149: int b;
150: {
151: int r, f;
152:
153: r = b/8;
154: if((f = b%8) < 4)
155: putchar('q'); else {
156: putchar('k');
157: f = 7-f;
158: }
159: f = "rnb\0"[f];
160: if(f)
161: putchar(f);
162: putchar(mantom? r+'1': '8'-r);
163: }
164:
165: algco(p)
166: int p;
167: {
168: putchar('a'+(p%8));
169: putchar('8'-(p/8));
170: }
171:
172: putchar(c)
173: {
174:
175: switch(c) {
176:
177: case '\t':
178: do
179: putchar(' ');
180: while(column%8);
181: return;
182:
183: case '\n':
184: column = 0;
185: break;
186:
187: default:
188: column++;
189: }
190: write(1, &c, 1);
191: }
192:
193: prtime(a, b)
194: {
195:
196: printf("time = %d/%d\n", a, b);
197: }
198:
199: score1(m)
200: {
201: if(intrp)
202: return;
203: if(!mantom) {
204: if(moveno < 10)
205: putchar(' '); else
206: putchar(moveno/10 + '0');
207: putchar(moveno%10 + '0');
208: putchar('.');
209: putchar(' ');
210: } else
211: while(column < 20)
212: putchar(' ');
213: out(m);
214: if(mantom)
215: putchar('\n');
216: }
217:
218: score()
219: {
220: int *p;
221:
222: putchar('\n');
223: p = amp;
224: while(amp[-1] != -1) {
225: mantom? wremove(): bremove();
226: decrem();
227: }
228: posit(score1, p);
229: putchar('\n');
230: }
Defined functions
out
defined in line
73; used 2 times
out1
defined in line
64;
never used
rline
defined in line
3;
never used
stdb
defined in line
148; used 2 times
stdp
defined in line
138; used 2 times