121206Sdist /* 2*60746Sbostic * Copyright (c) 1980, 1993 3*60746Sbostic * The Regents of the University of California. All rights reserved. 433487Sbostic * 542561Sbostic * %sccs.include.redist.c% 621206Sdist */ 76752Srrh 821206Sdist #ifndef lint 9*60746Sbostic static char sccsid[] = "@(#)board.c 8.1 (Berkeley) 05/31/93"; 1033487Sbostic #endif /* not lint */ 1121206Sdist 126752Srrh #include "back.h" 136752Srrh 146752Srrh static int i, j, k; 156752Srrh static char ln[60]; 166752Srrh wrboard()176752Srrhwrboard () { 186752Srrh register int l; 196752Srrh static char bl[] = 206752Srrh "| | | |\n"; 216752Srrh static char sv[] = 226752Srrh "| | | | \n"; 236752Srrh 246752Srrh fixtty (noech); 256752Srrh clear(); 266752Srrh 276752Srrh if (tflag) { 286752Srrh fboard(); 296752Srrh goto lastline; 306752Srrh } 316752Srrh 326752Srrh writel ("_____________________________________________________\n"); 336752Srrh writel (bl); 346752Srrh strcpy (ln,bl); 356752Srrh for (j = 1; j < 50; j += 4) { 366752Srrh k = j/4+(j > 24? 12: 13); 376752Srrh ln[j+1] = k%10+'0'; 386752Srrh ln[j] = k/10+'0'; 396752Srrh if (j == 21) 406752Srrh j += 4; 416752Srrh } 426752Srrh writel (ln); 436752Srrh for (i = 0; i < 5; i++) { 446752Srrh strcpy (ln,sv); 456752Srrh for (j = 1; j < 50; j += 4) { 466752Srrh k = j/4+(j > 24? 12: 13); 476752Srrh wrbsub (); 486752Srrh if (j == 21) 496752Srrh j += 4; 506752Srrh } 516752Srrh if (-board[25] > i) 526752Srrh ln[26] = 'w'; 536752Srrh if (-board[25] > i+5) 546752Srrh ln[25] = 'w'; 556752Srrh if (-board[25] > i+10) 566752Srrh ln[27] = 'w'; 576752Srrh l = 53; 586752Srrh if (off[1] > i || (off[1] < 0 && off[1]+15 > i)) { 596752Srrh ln[54] = 'r'; 606752Srrh l = 55; 616752Srrh } 626752Srrh if (off[1] > i+5 || (off[1] < 0 && off[1]+15 > i+5)) { 636752Srrh ln[55] = 'r'; 646752Srrh l = 56; 656752Srrh } 666752Srrh if (off[1] > i+10 || (off[1] < 0 && off[1]+15 > i+10)) { 676752Srrh ln[56] = 'r'; 686752Srrh l = 57; 696752Srrh } 706752Srrh ln[l++] = '\n'; 716752Srrh ln[l] = '\0'; 726752Srrh writel (ln); 736752Srrh } 746752Srrh strcpy (ln,bl); 756752Srrh ln[25] = 'B'; 766752Srrh ln[26] = 'A'; 776752Srrh ln[27] = 'R'; 786752Srrh writel (ln); 796752Srrh strcpy (ln,sv); 806752Srrh for (i = 4; i > -1; i--) { 816752Srrh for (j = 1; j < 50; j += 4) { 826752Srrh k = ((j > 24? 53: 49)-j)/4; 836752Srrh wrbsub(); 846752Srrh if (j == 21) 856752Srrh j += 4; 866752Srrh } 876752Srrh if (board[0] > i) 886752Srrh ln[26] = 'r'; 896752Srrh if (board[0] > i+5) 906752Srrh ln[25] = 'r'; 916752Srrh if (board[0] > i+10) 926752Srrh ln[27] = 'r'; 936752Srrh l = 53; 946752Srrh if (off[0] > i || (off[0] < 0 && off[0]+15 > i)) { 956752Srrh ln[54] = 'w'; 966752Srrh l = 55; 976752Srrh } 986752Srrh if (off[0] > i+5 || (off[0] < 0 && off[0]+15 > i+5)) { 996752Srrh ln[55] = 'w'; 1006752Srrh l = 56; 1016752Srrh } 1026752Srrh if (off[0] > i+10 || (off[0] < 0 && off[0]+15 > i+10)) { 1036752Srrh ln[56] = 'w'; 1046752Srrh l = 57; 1056752Srrh } 1066752Srrh ln[l++] = '\n'; 1076752Srrh ln[l] = '\0'; 1086752Srrh writel (ln); 1096752Srrh } 1106752Srrh strcpy (ln,bl); 1116752Srrh for (j = 1; j < 50; j += 4) { 1126752Srrh k = ((j > 24? 53: 49)-j)/4; 1136752Srrh ln[j+1] = k%10+'0'; 1146752Srrh if (k > 9) 1156752Srrh ln[j] = k/10+'0'; 1166752Srrh if (j == 21) 1176752Srrh j += 4; 1186752Srrh } 1196752Srrh writel (ln); 1206752Srrh writel ("|_______________________|___|_______________________|\n"); 1216752Srrh 1226752Srrh lastline: 1236752Srrh gwrite (); 1246752Srrh if (tflag) 1256752Srrh curmove (18,0); 1266752Srrh else { 1276752Srrh writec ('\n'); 1286752Srrh writec ('\n'); 1296752Srrh } 1306752Srrh fixtty(raw); 1316752Srrh } 1326752Srrh wrbsub()1336752Srrhwrbsub () { 1346752Srrh register int m; 1356752Srrh register char d; 1366752Srrh 1376752Srrh if (board[k] > 0) { 1386752Srrh m = board[k]; 1396752Srrh d = 'r'; 1406752Srrh } else { 1416752Srrh m = -board[k]; 1426752Srrh d = 'w'; 1436752Srrh } 1446752Srrh if (m>i) 1456752Srrh ln[j+1] = d; 1466752Srrh if (m>i+5) 1476752Srrh ln[j] = d; 1486752Srrh if (m>i+10) 1496752Srrh ln[j+2] = d; 1506752Srrh } 151