1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)board.c 5.4 (Berkeley) 06/01/90"; 10 #endif /* not lint */ 11 12 #include "back.h" 13 14 static int i, j, k; 15 static char ln[60]; 16 17 wrboard () { 18 register int l; 19 static char bl[] = 20 "| | | |\n"; 21 static char sv[] = 22 "| | | | \n"; 23 24 fixtty (noech); 25 clear(); 26 27 if (tflag) { 28 fboard(); 29 goto lastline; 30 } 31 32 writel ("_____________________________________________________\n"); 33 writel (bl); 34 strcpy (ln,bl); 35 for (j = 1; j < 50; j += 4) { 36 k = j/4+(j > 24? 12: 13); 37 ln[j+1] = k%10+'0'; 38 ln[j] = k/10+'0'; 39 if (j == 21) 40 j += 4; 41 } 42 writel (ln); 43 for (i = 0; i < 5; i++) { 44 strcpy (ln,sv); 45 for (j = 1; j < 50; j += 4) { 46 k = j/4+(j > 24? 12: 13); 47 wrbsub (); 48 if (j == 21) 49 j += 4; 50 } 51 if (-board[25] > i) 52 ln[26] = 'w'; 53 if (-board[25] > i+5) 54 ln[25] = 'w'; 55 if (-board[25] > i+10) 56 ln[27] = 'w'; 57 l = 53; 58 if (off[1] > i || (off[1] < 0 && off[1]+15 > i)) { 59 ln[54] = 'r'; 60 l = 55; 61 } 62 if (off[1] > i+5 || (off[1] < 0 && off[1]+15 > i+5)) { 63 ln[55] = 'r'; 64 l = 56; 65 } 66 if (off[1] > i+10 || (off[1] < 0 && off[1]+15 > i+10)) { 67 ln[56] = 'r'; 68 l = 57; 69 } 70 ln[l++] = '\n'; 71 ln[l] = '\0'; 72 writel (ln); 73 } 74 strcpy (ln,bl); 75 ln[25] = 'B'; 76 ln[26] = 'A'; 77 ln[27] = 'R'; 78 writel (ln); 79 strcpy (ln,sv); 80 for (i = 4; i > -1; i--) { 81 for (j = 1; j < 50; j += 4) { 82 k = ((j > 24? 53: 49)-j)/4; 83 wrbsub(); 84 if (j == 21) 85 j += 4; 86 } 87 if (board[0] > i) 88 ln[26] = 'r'; 89 if (board[0] > i+5) 90 ln[25] = 'r'; 91 if (board[0] > i+10) 92 ln[27] = 'r'; 93 l = 53; 94 if (off[0] > i || (off[0] < 0 && off[0]+15 > i)) { 95 ln[54] = 'w'; 96 l = 55; 97 } 98 if (off[0] > i+5 || (off[0] < 0 && off[0]+15 > i+5)) { 99 ln[55] = 'w'; 100 l = 56; 101 } 102 if (off[0] > i+10 || (off[0] < 0 && off[0]+15 > i+10)) { 103 ln[56] = 'w'; 104 l = 57; 105 } 106 ln[l++] = '\n'; 107 ln[l] = '\0'; 108 writel (ln); 109 } 110 strcpy (ln,bl); 111 for (j = 1; j < 50; j += 4) { 112 k = ((j > 24? 53: 49)-j)/4; 113 ln[j+1] = k%10+'0'; 114 if (k > 9) 115 ln[j] = k/10+'0'; 116 if (j == 21) 117 j += 4; 118 } 119 writel (ln); 120 writel ("|_______________________|___|_______________________|\n"); 121 122 lastline: 123 gwrite (); 124 if (tflag) 125 curmove (18,0); 126 else { 127 writec ('\n'); 128 writec ('\n'); 129 } 130 fixtty(raw); 131 } 132 133 wrbsub () { 134 register int m; 135 register char d; 136 137 if (board[k] > 0) { 138 m = board[k]; 139 d = 'r'; 140 } else { 141 m = -board[k]; 142 d = 'w'; 143 } 144 if (m>i) 145 ln[j+1] = d; 146 if (m>i+5) 147 ln[j] = d; 148 if (m>i+10) 149 ln[j+2] = d; 150 } 151