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