Classic Computer Magazine Archive COMPUTE! ISSUE 64 / SEPTEMBER 1985 / PAGE 87

For IBM PC & PCjr
Chess

John Krause, Assistant Technical Editor

In the December 1984 issue, COMPUTE! published "Chess" for the Commodore 64, VIC-20, Atari, and Apple computers. This month, by popular demand, we present an all-new version for the IBM PC, PCjr, and compatibles. Like the original Chess, the IBM version has intelligence routines written entirely in machine language. Additional features make it our most powerful chess program ever. It has multiple skill levels, checking for illegal moves, one-and two-player modes, reverse moving, and many other features. The program requires a PC with at least 128K RAM, color/graphics adapter, BASICA, and a disk drive, or an Enhanced Model PCjr with Cartridge BASIC.


A computer chess game is great for those who can't always find a human opponent. But "Chess" is more than just a substitute for a live player. You might call it a "chess processor." It processes chess positions as easily as a word processor manipulates text. It contains all the features a chess player could ever want. Its thinking routines are written entirely in machine language for greater speed, and they use basic principles of artificial intelligence to simulate an actual human chess player.
    Chess consists of two programs. First, type in and save each program. Then load and run Program 1. You'll have to wait about 15 seconds while it creates a BLOAD file on the disk called CHESS.BLD which contains the machine language. Once this file is created, Program 1 is no longer used. From now on, to play Chess, simply load and run Program 2.
    After running Chess, you'll see a title screen for a few seconds while the computer prepares itself. Then the board is displayed with the pieces in their starting positions. You're in command of the white pieces versus the computer's black pieces on skill level 1, the easiest level. You should see a frame around the square in the lower-left corner of the board. This is the cursor which takes the place of your hand for moving and capturing pieces.

chess for IBM

    Use the cursor keys to move the frame cursor atop the piece you wish to move. Press and release the Enter key. Now move the cursor to the square on which you want to place the piece and hit Enter again. Your piece moves to the new square, and the computer responds instantly with a countermove.

Sorry, No Cheating
One of the most valuable features of IBM Chess is that it checks for illegal moves. If you try to make an illegal move, the computer buzzes and keeps your piece on its square. This feature is not perfect, however. It won't catch illegal moves involving castling or en passant captures. But it will catch 99 percent of all illegal moves, including those that put your king in check, as well as the more obvious ones such as moving a pawn backwards. If the computer accepts your move, it's probably legal, but not necessarily so. If the computer rejects your move, however, you can be sure that it is illegal.
    If you're a beginner at chess, you'll find the move-checking feature especially valuable. Just by trying various moves and noting which ones the computer accepts, you can get a good idea of the way each piece can move.
    Information about the current game is displayed at the top of the screen. Move# indicates the number of the move currently being made, counting from the start of the game. In chess, a move by both sides is considered one move. So, the move number is changed only after both sides have moved.
    To Move indicates which side has the move. W means it is white's turn, and B means it is black's.
    Normally after you move, the computer automatically makes the next move. This can be turned off by pressing the T key to switch to two-player mode. Now you can play against another person with the computer acting as referee to check for illegal moves. To switch back to one-player mode, press T again.
    You can also let the computer make moves for you by pressing the M key. The side that the computer plays depends on whose turn it is. By repeatedly pressing M, you can watch the computer play itself.

Five Skill Levels
One of the advantages of a computer opponent over a human is that you can tell the computer exactly how hard you want it to try to beat you, and it obediently plays at that level of difficulty. This is important because it's no fun if you always lose or always win effortlessly.
    Level shows the current skill level from 1 to 5. You can change the level at any time by pressing keys 1-5. The difference between levels is the number of moves ahead that the computer looks. On level 1, for example, it looks ahead one full move or two half-moves (its move and your reply). Each succeeding level looks ahead one more halfmove than the previous level.
    Alas, the smarter play on the higher levels doesn't come without a price. The further ahead the computer looks, the more moves it must examine and, hence, the longer it thinks. Here's a rundown of the five levels:
    Level 1: Beginner. Thinking time: one second. Look-ahead: two half-moves. Fast but dumb.
    Level 2: Intermediate. Thinking time: five seconds. Look-ahead: three half-moves. Provides a reasonable challenge for impatient players.
    Level 3: Tournament. Thinking time: two minutes. Look-ahead: four half-moves. Since the usual time limit for tournament play is 40 moves in two hours, an average of three minutes per move, this level is best suited for serious players.
    Level 4: Mate in two. Thinking time: 20 minutes. Look-ahead: five half-moves. Capable of solving most mate-in-two problems.
    Level 5: Postal chess. Thinking time: two hours. Look-ahead: six half-moves. Simulates chess by mail where there is no time limit. Can avoid checkmate in two moves. These thinking times are averages. The actual thinking time varies greatly depending on the position. For example, level 5 takes only five seconds with just two kings on the board. Also, these times are for the PC only. Since the PCjr runs at about two-thirds the speed of the PC, the thinking times for the PCjr are greater than the values shown above.

A Spectacular Blunder
It happens to everyone. It's inevitable. You've played for an hour, somehow managing to maneuver into a superior position in what you consider to be the best game of your life, only to throw it all away in a single, spectacular blunder.
    Don't panic. You can take back the last half-move by pressing the B key. If you're in one-player mode, you need to press B again to take back your move and the computer's reply. In fact, you can press B repeatedly to take back several moves until you reach the starting position. This is possible because the computer records every move made in the game.
    Another use for this feature is to allow the computer to suggest a move for you. If you don't have a good idea of where to move next, press M and the computer will move for you. If you like that move, press M again to continue with the computer's next move. But if you think you've found a better move, press B to take back the suggested move and make your own move.
    Pressing the F key does the opposite of B. It moves forward through the move list up to the most advanced position. Note that every time a new move is made, the resulting position becomes the most advanced. So if you use B to backtrack to a previous position, and then make a new move, all subsequent stored moves are erased because they are no longer relevant.
    If you have a printer, you can print the move list by pressing the P key. The list appears in three col umns: the move numbers, white's moves, and black's moves. Each move is indicated by the square the piece moved from followed by the square it moved to. Each square is specified by its coordinates according to the numbers along the left side of the board and letters along the bottom.
    You can also dump the screen image to the printer to get a hardcopy of a particularly interesting position. Before loading BASIC from DOS, type GRAPHICS with the DOS master disk in the drive. Then run Chess and press Shift-PrtSc (FnPrtSc on the PCjr) whenever you want to print the position.

Checkmate
The computer thinks by analyzing thousands of possible moves and countermoves and choosing what it considers to be the best move based on the relative value of the pieces. Most positions don't have just one best move but several which are equally good, in which case the computer chooses among them at random. This random factor insures that every game will be different, and makes for varied and interesting play.
    The computer announces checkmate when it occurs. However, there are a few quirks in the way the computer evaluates a checkmate. On levels 3-5, it announces checkmate prematurely. When this happens, the computer has determined that it's impossible to avoid checkmate on the next move or two - assuming both sides make the best moves.
    Also, the computer doesn't know the subtle difference between checkmate and stalemate. Consequently, when a game is stalemated, the computer announces checkmate even though the game is a draw. Since the computer tries as hard as it can to checkmate its opponent, it also tries to achieve stalemate, possibly forcing a draw when it could have won. Fortunately, this rarely happens, because a stalemate requires unusual circumstances, such as when one side has only the king remaining.
    You can start a new game at any time by pressing the N key. This sets up the pieces in the starting position with white on the bottom. If you want to play the black pieces, you can press the I key to invert the board, so you still play from the bottom. As with the N command, the board is reset to the starting position. However, the N and I commands retain the move list from the previous game. This allows you to replay the game using the F command. When replaying a game, be sure to reset the board by pressing I if the game was played in the inverted mode, or N if normal mode was used.

Set Up Any Position
You don't have to begin a game from the starting position. You can set up any position and begin playing from that point. If you want, you can first clear the board by pressing the C key. To add a piece or change a piece to a different one, move the cursor to the appropriate square, hold down either Shift or Ctrl, and press P, N, B, R, Q, or K for pawn, knight, bishop, rook, queen, or king, respectively. Holding down Shift adds one of the lower player's pieces, and Ctrl adds one of the upper player's pieces. (Just remember that Ctrl is above Shift on the keyboard.) A piece can be removed from the board by pressing the space bar. Note that these changes are not stored in the move list.
    These commands allow you to experiment with hypothetical or downright ridiculous positions. The position doesn't even have to be legal. Live out your fantasy by giving yourself ten queens versus the computer's lone king. Or invent your own type of chess by giving each side two kings, for example (although in this case the computer might get confused trying to determine a checkmate).
    You can also set up a problem for the computer to solve, such as the mate-in-two problems published in many newspapers. To solve a mate-in-two problem, press C to clear the board, set up the position, press 4 to select level 4, and press M to start the computer thinking. After several minutes of deep thought, the computer will make a move (the solution) and announce checkmate. The only mate-in-two problems that the computer cannot solve are those which involve castling, en passant captures, or pawn promotion.

Special Moves
The computer never castles or captures en passant because, due to their complexity, these moves are not included in its thinking routine. But you can make these special moves. To castle, move the king two squares to the left or right. The rook moves automatically. To capture en passant, move your pawn diagonally to the proper square. The opponent's pawn is removed automatically. Remember, the computer doesn't check for illegal moves involving castling or en passant captures, so if you're a beginner, you should familiarize yourself with the rules on these special moves.
    When a pawn reaches the opposite side of the board, it's automatically promoted to a queen. In the rare event that you would rather promote to a knight, bishop, or rook, you can easily make the change by positioning the cursor over the new queen and pressing N, B, or R with Shift or Ctrl. Note, however, that underpromotions are not stored in the move list.

Saving A Game
If you want to stop the present game and continue later, you can save the game on disk (in drive A) by pressing the S key. You'll see the prompt Save:. Type in a filename for your game and press Enter. The filename can be up to eight characters long. Don't type an extender; CHS is added automatically. If a file on the disk already has the same name, it will be replaced.
    To load a previously saved game, press the L key. Answer the Load: prompt with the filename and press Enter. (Don't type the CHS extender.) The L command restores the game exactly as it was when it was saved. Not only the position is restored, but also the move list and even the position of the cursor.
    If the computer is unable to save or load a game, an error number is displayed. See Appendix A of the BASIC Reference Manual for a description of the error.
    Besides allowing you to continue a game at a later time, the S and L commands can be used to create a library of your best games. To do this, press N or I just before saving. The game will come up in the starting position when loaded and can be replayed using the F command.

   IBM Chess Commands

B: Move backward
C: Clear board
F: Move forward
I: New game (inverted)
L: Load game
M: Computer's move
N: New game
P: Print move list
S: Save game
T: Two players
1-5: Level
Cursor Keys: Move cursor
Enter: Your move
Space Bar: Remove piece
Shift-P: Lower player's pawn
Shift-N: Lower player's knight
Shift-B: Lower players bishop
Shift-R: Lower players rook
Shift-Q: Lower player's queen
Shift-K: Lower player's king
Ctrl-P: Upper player's pawn
Ctrl-N: Upper players knight
Ctrl-B: Upper player's bishop
Ctrl-R: Upper players rook
Ctrl-Q: Upper player's queen
Ctrl-K: Upper player's king

For instructions on entering these listings,
please refer to "COMPUTE's Guide to Typing
In Programs" published bimonthly in COMPUTE!.

Program 1: IBM Chess
(Machine Language)

IG 10 DEF SEG=&HFFFF:IF PEEK(14)
      =253 THEN DEF SEG=&H1700:G
      OTO 30
IE 20 DEF SEG=&H1C00
EE 30 FOR I=1 TO 31:READ A$:FOR
      J-1 TO 143 STEP 2
BB 40 POKE K,VAL("&h"+MID$(A$,J,
      2)):K=K+1:IF K<825 THEN NE
      XT:NEXT
KC 50 BSAVE"chess.bld",0,825
JG 60 DATA IEB831ICBEDBBC16EI008
      926E300B8401C8ED0B00001E80
      A008E16E1008B26E3001FCBFAB
      908008BD9C6875E00C0E2F7C60
      65E0000C606E00000BB0000BFF
      FFFE90B018AS54C0002
OJ 70 DATA 85540050BAD88AS767008
      A9D4C00888767008A852C005B8
      88767000406508BlE290006876
      000005BBABF10002ASD6000C68
      560000083FF0075523A0E5F007
      C4B7511B000E643E440
IB 80 DATA E4403A065E00723BA25E0
      0803EDF0000741DA04C003A065
      0007528020654003A065D00751
      E80F9E57E19FE06E000C3880E5
      F008A0E4000B80E5C008A0E540
      0880E5D00033ASD5F00
ND 90 DATA 7EF9888D5F008A9D2B008
      0C306BAB710002AS55F003AS55
      E007C4083FF0174DB3A855E007
      435C38ASD4C00028D54008AD98
      A876700803E2B000075063C017
      DBB7C0830007CB53C07
PF 100 DATA 74BISS8520003C067404
       3CFA750AC6B55F002E5A5AEB5
       C908A9D4C008A876700068767
       00008AD988B767003B3E29007
       503E9EFFE47C6854C00148036
       2B0001FE854C008A9D4C008A
EK 110 DATA 9F6700803E2B0000750D
       B0FB017CI580FB077410ES089
       080FB007D08F6DBD0E3FF971B
       0080BD$C00627CCC83FF00740
       980362B00014FE9A2FEA05C00
       00065D00FBC3803E2B000075
HO 120 DATA 5ESA9D400080C30A80BF
       6700007523C68554000AE838F
       FSA9D4C0080FB277D1680C314
       80BF6700007508C685540014E
       81DFFBA9D4C0080C30980BF67
       00007D0BC685540009E807FF
DN 130 DATA 8A9D4C0080C30B80BF67
       00007D0BC68554000BE8FIFEC
       3BA9D4C0080C3F680BF670000
       7523C6855400F6E8DAFEBA9D4
       C0080FB517C1680C3EC80BF67
       000075013C6855400ECEBBFFE
FL 140 DATA 8A9D4C0080C3F780BF67
       00007E0SC6B55400F7E8A9FE8
       A9D4C0080C3F580BF6700007E
       08C6855400F5E893FEC3C6853
       40000B3008AB700008S855400
       EB80FEFE8534008A9D340080
OB 150 DATA FB087CESC3C685440004
       C685340000EB1890C68544000
       8C685340004EB0B90C6854400
       08C685340000SA9D3400BA870
       8008885300088855400E83BFE
       BA854C0002855400BADBB0BF
MI 160 DATA 670000750ABA85540002
       853000EBDEFE8534008A9D340
       03A9D44007CC8C3C685340000
       B3008A87080088855400EBFFF
       DFE8534008A9D340080FB0S7C
       E8C30000150CFBEDEBF40813
KB 170 DATA 0BF7F5090A01F6FF2E09
       050303010001030305092EAA0
       16D02BD029A02A702EE02


Program 2: IBM Chess (Main Program)

KN 10 C0=&H1C00:DEF SEG=&HFFFF:I
      F PEEK(14)=253 THEN CO=&H1
      700:I=1
AB 20 DA=CO+49:DEF SEG=CO:BLOAD"
      chess.bld",0:IF I THEN POK
      E 3,23:POKE 16,23
JD 30 DEF SEG=DA:GOSUB 690
BF 40 M=40:N=158:K=21
NF 50 POKE 43,1-BB:GOTO 180
KO 60 IF C2 THEN 180
NC 70 POKE 223,0:DEF SEG=CO:SOUN
      D 99,0:CALL ML:DEF SEG=DA
LO 80 IF PEEK(95)<229 AND PEEK(9
      5)>150 THEN I=0:GOTO 120
BF 90 K1=PEEK(92):K=PEEK(93):SOU
      ND 500,1:GOSUB 1190:GOSUB
      950
QI 100 IF PEEK(95)>99 OR PEEK(95
       )<28 THEN 180
NF 110 I=1
OF 120 X=I+BB+PEEK(43):IF I=0 TH
       EN POKE 43,-(PEEK(43)=0)
BH 130 GOSUB 1410:PRINT"Checkmat
       e!  ";
LO 140 IF X/2-INT(X/2) THEN PRIN
       T"White wins.":GOTO 160
IB 150 PRINT"Black wins."
FD 160 SOUND 999,9:FOR J=0 TO 20
       0:NEXT
HP 170 SOUND 260,9:FOR J=0 TO 20
       0:NEXT
KG 180 F=0:M=M-B:N=N-3
NB 190 GOSUB 680
NM 200 C$=INKEY$:IF C$="" THEN 2
       00
EP 210 IF LEN(C$)=1 THEN 270
PO 220 C=ASC(RIGHT$(C$,1)):IF C=
       75 AND M>32 THEN GOSUB 68
       0:M=M-31:K-K-1:GOTO 190
KB 230 IF C=77 AND M<249 THEN GO
       SUB 680:M=M+31:K=K+1:GOTO
        190
DN 240 IF C=72 AND N>8 THEN GOSU
       B 680:N=N-21:K=K+10:GOTO
       190
DB 250 IF C=80 AND N<155 THEN GO
       SUB 680:N=N+21:K=K-10:GOT
       O 190
BD 260 GOTO 200
QP 270 C=ASC(C$):GOSUB 1400:IF C
       <>13 OR F=0 THEN 360
GF 280 POKE 92,K1:POKE 93,K:J=PE
       EK(41):POKE 41,1:POKE 223
       ,1
FF 290 DEF SEG=CO:CALL ML:DEF SE
       G=DA
DO 300 POKE 41,J:IF PEEK(224)=0
       THEN 320
CK 310 GOSUB 1190:GOSUB 950:GOTO
        60
MG 320 X=PEEK(103+Kl):IF (X=6 OR
        X=250) AND ABS(K-K1)=2 T
       HEN GOSUB 1190:GOSUB 950:
       Y=K1:Kl=21-70*(X>6)-7*(K>
       K1):K=K+(K>Y)-(Y>K):MM=MM
       -1:GOSUB 1190:PR(MV)=1:GO
       SUB 950:GOTO 60
DO 330 IF PEEK(103+K) THEN 350
MI 340 IF (X=1 OR X=255) AND (AB
       S(K-K1)=9 OR ABS(K-K1)=11
       ) THEN GOSUB 1190:GOSUB 9
       50:K=K+10*(X=1)-10*(X>1):
       MM-MM-1:GOSUB 1190:PR(MV)
       =1:GOSUB 950:GOTO 60
PE 350 SOUND 100,4:17=0:POKE 43,-
       (PEEK(43)=0):GOTO 200
GA 360 IF F THEN 200
JO 370 IF C<>13 OR PEEK(103+K)=0
        THEN 410
QJ 380 IF PEEK(43) AND PEEK(103+
       K)<7 THEN 400
DH 390 IF PEEK(43) OR PEEK(103+K.
       )<7 THEN 410
NO 400 K1=K:F=1:SOUND 500,1:GOTO
        200
AD 410 S=0
JL 420 IF D(S)=C THEN 450
EN 430 S=S+1:IF S<28 THEN 420
BB 440 GOTO 200
JA 450 IF S>22 THEN SOUND 500,1:
       LOCATE 1,22:PRINT C$:POKE
        41,VAL(C$):GOTO 200
HA 460 IF S=13 THEN SOUND 500,1:
       GOSUB 680:M=M+B:N=N+3:GOT
       O 70
IF 470 IF S=14 THEN SOUND 500,1:
       FOR I=0 TO 70 STEP 10:FOR
        J=0 TO 7:POKE 124+I+J,0:
       NEXT:NEXT:MX=0:MV=0:MM=0:
       BB=0:GOSUB 900:GOTO 40
NN 480 IF S<>15 OR MV=0 THEN 530
LJ 490 SOUND 500,1:POKE 43,-(PEE
       K(43)=0):GOSUB 680:GOSUB
       1200:MM=MM-l:GOSUB 1430
GD 500 IF ABS(PC(MV)-128)=122 AN
       D ABS(FR(MV)-T(MV))=2 THE
       N GOSUB 1200
FG 510 IF ABS(PC(MV)-128)=127 AN
       D PC(MV+1)=0 AND MV<MX TH
       EN GOSUB 1200
GM 520 GOTO 180
HN 530 IF S<>16 OR MV>=MX THEN 5
       80
FH 540 SOUND 500,1:POKE 43,-(PEE
       K(43)=0):GOSUB 680:GOSUB
       1210:MM=MM+1:GOSUB 1430
LO 550 IF ABS(PC(MV)-128)=122 AN
       D ABS(FR(MV)-T(MV))=2 THE
       N GOSUB 1210
KC 560 IF ABS(PC(MV)-128)=127 AN
       D PC(MV+1)=0 AND MV<MX TH
       EN GOSUB 1210
GG 570 GOTO 180
NJ 580 IF S=17 THEN BB=0:GOTO 67
       0
PO 590 IF S=18 THEN 1280
HA 600 IF S=19 THEN 1220
FE 610 IF S=20 THEN 1340
KL 620 IF S=21 THEN BB=1:GOTO 67
       0
MG 630 IF S=22 THEN SOUND 500,1:
       C2=1-C2
BI 640 IF S>12 THEN 200
HN 650 SOUND 500,1:IF S>6 THEN S
       =262-S
PI 660 POKE 103+K,S:GOSUB 950:M=
       M-8:N=N-3:GOTO 190
EG 670 SOUND 500,1:MV=0:MM=0:FOR
        I=0 TO 77:POKE I+124,BD(
       I):NEXT:GOSUB 890:GOTO 40
QL 680 PUT (M,N),F,XOR:RETURN
NH 690 KEY OFF:SCREEN 1,0:COLOR
       0,l:CLS
BG 700 POKE 41,1
AB 710 DEFINT P,N,B,R,Q,K,F
LD 720 DIM A(64),C(64),D(27),P(3
       0),N(30),B(30),R(30),Q(30
       ),K(30),F(82),FR(200),T(2
       00),PC(200),CA(200),PR(20
       0),BD(77)
PP 730 FOR I=0 TO 27:READ D(I):N
       EXT
GJ 740 LINE (0,0)-(29,19),1,BF
NF 750 GET (0,0)-(29,19),A:CLS
HF 760 LINE (0,0)-(29,19),2,BF
AH 770 GET (0,0)-(29,19),C:CLS
QO 780 LOCATE 10,18:PRINT "CHESS
       "
ON 790 LOCATE 12,15:PRINT"John K
       rause"
MN 800 FOR I=103 TO 222:POKE 1,7
       :NEXT
GL 810 FOR I=0 TO 77:READ BD(I):
       POKE I+124,BD(I):NEXT
PN 820 FOR K=0 TO 30:READ P(K):N
       EXT
MP 830 FOR K=0 TO 30:READ N(K):N
       EXT
KB 840 FOR K=0 TO 30:READ B(k):N
       EXT
CD 850 FOR K=0 TO 30:READ R(K):N
       EXT
BN 860 FOR K=0 TO 30:READ Q(K):N
       EXT
IP 870 FOR K=0 TO 30:READ K(K):N
       EXT
PL 880 FOR K=0 TO 82:READ F(K):N
       EXT:CLS
JC 890 IF BB THEN POKE 127,6:POK
       E 128,5:POKE 197,250:POKE
        198,251
HM 900 LOCATE 1,5:PRINT"Move#  
          Level"PEEK(41)"  To mo
       ve:":GOSUB 1430
EE 910 FOR I=0 TO 7:FOR J=0 TO 7
IM 920 H=70-10*I+J:GOSUB 960:NEX
       T:NEXT
CD 930 FOR I=1 TO 8:LOCATE 3*1-1
       +(I>4),2:PRINT 9-I:NEXT
DI 940 GOSUB 1400:RETURN
OO 950 H=K-21:I=INT(H/10):J=H-10
       *I:I=7-I
PA 960 M=31*J+40:N=21*I+11
FF 970 IF INT((I+J)/2)-(I+J)/2 T
       HEN PUT (M-8,N-3),C,PSET:
        GOTO 990
MI 980 PUT (M-8,N-3),A,PSET
HC 990 L=PEEK(124+H):IF I=0 AND
       L=1 THEN L=5:POKE 124+H,L
JF 1000 IF I=7 AND L=255 THEN L=
        251:POKE 124+H,L
PM 1010 IF L>6 THEN L=L-256
ON 1020 ON ABS(L) GOTO 1040,1050
        ,1060,1070,1080,1090
IL 1030 GOTO 1100
NF 1040 PUT (M,N),P,OR:GOTO 1100
MI 1050 PUT (M,N),N,OR:GOTO 1100
BL 1060 PUT (M,N),B,OR:GOTO 1100
QO 1070 PUT (M,N),R,OR:GOTO 1100
PB 1080 PUT (M,N),Q,OR:GOTO 1100
IG 1090 PUT (M,N),K,OR
PG 1100 IF BB THEN L=-L
KF 1110 IF L>=0 THEN RETURN
PF 1120 ON -L GOTO 1130,1140,115
        0,1160,1170,1180
FD 1130 PUT (M,N),P,XOR:RETURN
DG 1140 PUT (M,N),N,XOR:RETURN
IJ 1150 PUT (M,N),B,XOR:RETURN
IM 1160 PUT (M,N),R,XOR:RETURN
HP 1170 PUT (M,N),Q,XOR:RETURN
BC 1180 PUT (M,N),K,XOR:RETURN
QN 1190 K2=K:K=K1:MV=MV+1:PR(MV)
        =0:MM=MM+1:MX=MV:FR(MV)=
        K:PC(MV)=PEEK(103+K):POK
        E 103+K,0:GOSUB 950:K=K2
        :T(MV)=K:CA(MV)=PEEK(103
        +K):POKE 103+K,PC(MV):GO
        SUB 1430:RETURN
QN 1200 POKE 103+FR(MV),PC(MV):P
        OKE 103+T(MV),CA(MV):K=T
        (MV):GOSUB 950:K=FR(MV):
        GOSUB 950:MV=MV-1:RETURN
FO 1210 MV=MV+1:POKE 103+T(MV),P
        EEK(103+FR(MV)):POKE 103
        +FR(MV),0:K=FR(MV):GDSUB
         950:K=T(MV):GOSUB 950:R
        ETURN
DM 1220 SOUND 500,1:GOSUB 1410:I
        NPUT"Save:",N$
KO 1230 ON ERROR GOTO 1420
LA 1240 OPEN N$+".chs" FOR OUTPU
        T AS #1
NC 1250 FOR I=124 TO 201:PRINT #
        1,PEEK(I):NEXT
GM 1260 PRINT #1,PEEK(41),PEEK(4
        3),MV,MX,MM,BB,M,N,K,C2
B0 1270 FOR I=1 TO MX:PRINT #1,T
        (I),FR(I),PC(I),CA(I),PR
        (I):NEXT:CLOSE #1:ON ERR
        OR GOTO 0:GOSUB 1400:GOT
        O 200
BC 1280 SOUND 500,1:GOSUB 1410:1
        NPUT"Load:",N$
LA 1290 ON ERROR GOTO 1420
GN 1300 OPEN N$+".chs" FOR INPUT
        AS #1
FJ 1310 FOR I=124 TO 201:INPUT #
        1,J:POKE I,J:NEXT
EM 1320 INPUT #1,X,J,MV,MX,MM,BB
        ,M1,N1,K1,C2:POKE 41,X:P
        OKE 43,J
MI 1330 FOR I=1 TO MX: INPUT #1,T
        (I),FR(I),PC(I),CA(I),PR
        (I):NEXT:CLOSE #l:ON ERR
        OR GOTO 0:GOSUB 900:M=M1
        :N=N1:K=K1:GOTO 190
PC 1340 SOUND 500,1:X=0:FOR I=1
        TO MX:IF PR(I) THEN 1370
BD 1350 X=X+1:IF X/2-INT(X/2) TH
        EN LPRINT(X+1)/2" ";:GOS
        UB 1380:GOTO 1370
JH 1360 LPRINT"      ";:GOSUB 1380:
        LPRINT
HH 1370 NEXT:LPRINT:GOTO 200
HE 1380 J=INT(FR(I)/10):LPRINT C
        HR$(64+FR(I)-10*J);MID$(
        STR$(J-1),2,1)"-";
MD 1390 J=INT(T(I)/10):LPRINT CH
        R$(64+T(I)-10*J);MID$(ST
        R$(J-1),2,1);:RETURN
LC 1400 LOCATE 23,6:PRINT"A   B
          C   D   E   F   G   H"
        :RETURN
LE 1410 LOCATE 23,6:PRINT"    
                               "
        :LOCATE 23,9:RETURN
LD 1420 GOSUB 1410:PRINT"Error #
        "ERR:RESUME 200
LF 1430 LOCATE 1,10:PRINT INT(MM
        /2+1)" ":LOCATE 1,35:IF
        INT(MM/2)=MM/2 THEN PRIN
        T CHR$(87):RETURN
FE 1440 PRINT CHR$(66):RETURN
NB 1450 DATA 32,80,78,66,82,81,7
        5,16,14,2,18,17,11,109,9
        9,98,102,110,108,115,112
        ,105,116,49,50,51,52,53
CL 1460 DATA 4,2,3,5,6,3,2,4,7
FO 1470 DATA 7,1,1,1,1,1,1,1,1,7
LB 1480 DATA 7,0,0,0,0,0,0,0,0,7
LE 1490 DATA 7,0,0,0,0,0,0,0,0,7
KL 1500 DATA 7,0,0,0,0,0,0,0,0,7
KO 1510 DATA 7,0,0,0,0,0,0,0,0,7
BJ 1520 DATA 7,255,255,255,255,2
        55,255,255,255,7
HO 1530 DATA 7,252,254,253,251,2
        50,253,254,252
BO 1540 DATA 28,14,0,0,0,0,3840,
        0
OE 1550 DATA 16128,192,16128,192
        ,3840,0,16128,192
AF 1560 DATA 3840,0,3840,0,16128
        ,192,-256,240
DG 1570 DATA -256,240,0,0,0,0,12
        8
PK 1580 DATA 28,14,3,0,-16381,0,
        -1021,0
LC 1590 DATA-241,192,-244,240,-2
        41,240,-241,252
PL 1600 DATA -193,252,-12481,255
        ,3852,255,16128,255
KF 1610 DATA -256,255,-253,255,-
        253,255,-253
PB 1620 DATA 28,14,-4096,240,-40
        96,240,-1021,252
CF 1630 DATA -253,60,-253,204,-2
        53,204,-253,204
KK 1640 DATA -256,240,-16384,48,
        -256,240,-16384,48
LL 1650 DATA -193,-16129,-3841,-
        3841,192,12288,-253
OP 1660 DATA 28,14,16143,207,161
        43,207,-241,255
IJ 1670 DATA 3,12,-253,252,-253,
        252,-253,252
NO 1680 DATA -253,252,-253,252,-
        253,252,3,12
EG 1690 DATA -241,255,-193,-1612
        9,-193,-16129,-193
CE 1700 DATA 28,14,-16384,192,-1
        6384,192,-16384,192
FA 1710 DATA -16192,-16192,-3133
        ,-16144,-3277,243,-3277,
        243
ED 1720 DATA -193,255,12,12,-241
        ,252,-3313,252
KI 1730 DATA -241,252,12,12,-241'
        ,252,0
CD 1740 DATA 28,14,-256,192,-133
        12,192,-3268,207
KP 1750 DATA -13057,-16129,-1,-1
        6129,-16129,-16129,-3265
        ,255
FP 1760 DATA -193,255,12,12,-241
        ,252,-3313,252
KE 1770 DATA -241,252,12,12,-241
        ,252,0
CJ 1780 DATA 60,20,-1,-1,-1,-384
        1,-1,-1
GB 1790 DATA -1,-3841,252,0,0,-4
        093,252,0
DF 1800 DATA 0,-4093,252,0,0,-40
        93,252,0
EI 1810 DATA 0,-4093,252,0,0,-40
        93,252,0
EL 1820 DATA 0,-4093,252,0,0,-40
        93,252,0
EO 1830 DATA 0,-4093,252,0,0,-40
        93,252,0
EB 1840 DATA 0,-4093,252,0,0,-40
        93,252,0
EE 1850 DATA 0,-4093,252,0,0,-40
        93,252,0
EH 1860 DATA 0,-4093,252,0,0,-40
        93,252,0
II 1870 DATA 0,-4093,-1,-1,-1,-3
        841,-1,-1
IF 1880 DATA -1,-3841,0