SPECTRUM CHESS by Christopher Leigh from Sinclair User, October 1982 [I've corrected several errors in the listing, which are marked in] [INVERSE in SPECHESS.TAP. ] [Some of the English in this article doesn't make much sense. JimG] UPGRADING THE MANUAL Christopher Leigh details attempts to improve Sinclair chess pieces. WHEN I received my Spectrum, just six weeks after it was arrived I working quickly through the instruction manual provided. I found very few mistakes and some stimulating ideas but the chess routine which was provided gave such a tiny display a magnifying glass was needed to distinguish the pieces. I set to work to write a bigger version. I started with a piece of graph paper, thinking about the chess pieces and how they could be improved. The obvious aim was to make them bigger but that meant using more than one character space for each chess piece. It would have been good to fill the screen with a 24*24 display but I settled for a 16*16 one. That meant that each chess-board square consisted of four printing spaces arranged 2*2. Printing the board was fairly easy; the labelling was added later. A white screen was kept for ease of reading, though a black screen would probably look more impressive. The board was printed using PAPER colour controls so that INK could be reserved for the pieces. It seemed more sensible than, for example, to print one large magenta and then to put green ink squares over it, which would have involved using "Inverse"; Inverse can be confusing. Using the graph paper I drew the pieces, shading-in with a pencil each little square - representing a pixel - which needed inking-in. That was translated into a binary code which could be POKEd. The user graphics are of memory. Three considerations affected the shape of the pieces. They had to leave enough margin to show clearly the colour of the square on which they were printed. They had to be very clearly distinguishable. For that reason pawns were made smaller than other pieces. The third consideration was more awkward. Each piece occupies a 2*2 square, requiring four user graphics to define it. There are six different pieces in chess so that 24 graphic characters would seem necessary but only 21 are available. The answer was to share some of them between pieces; the fourth quarter of the queen is the same as the corresponding quarter of the knight and the complete bottom half of the king is the same as that of the rook. The rook consists of USR "a" followed by USR "b" with USR "e" and USR "d" underneath. Each drawing was labelled with the appropriate USR letter and then the binary codes worked out for each graphic. Each pixel is represented by a 0 for paper and a 1 for ink. The codes can be POKEd into memory as binary numbers using BIN but as there were so many to do they were translated into decimal to reduce the typing. The original drawings and binary codes have been kept for ease of operation should I wish to change the shape of any piece. Figure 1 [Not included here. JimG] shows how this all works out for the rook. With the pieces complete the most laborious part of the job was over. The next task was to put the pieces on the blank board. The user graphics could be typed-in but that would make any kind of game impossible. The pieces must be held in a string or array. I settled for an 8*8*4 string array so that each board position was fully- defined and all four labels for the user graphics could be put into the array for each piece, which proved to be fairly simple. The use of upper- and lower-case letters gives the array an extra dimension so the computer always knows the colour of any pieces referred to. Once the board array was set up, printing it was merely a question of getting the numbers correct so that the proper graphic was printed at the correct position. Number juggling was also needed when entering moves. At that stage I was able to run the program and see if it worked. It did; I was bothered by the blank screen at the start of the program, which occurs while the machine processes lines 1-1000. To prevent the player thinking something was wrong lines 70-90 were added. Other improvements were made. There was a long wait between printing white and black pieces. The Spectrum was printing blanks all over the centre of the board. Variable "w" was used to suppress such stupidity on the first run. On subsequent runs the player has to suffer space printing, as it is used to erase pieces which are out of place. The complete listing is shown in figure two. The program puts board and pieces on the screen and then allows you to move them at will. Pawns automatically become queens on last rank, castling has to be done in two moves. Games can start with the pieces put in any position. Lines 70-90 print a title and flashing "Thinking!" so the screen is not blank during the few seconds it takes to run through the user graphics and setting-up the board array. Lines 100-350 poke the user graphics. Since only 21 are available, three are used twice by the chess pieces. Lines 500-640 set up the two- dimensional string array which is used to hold the positions and the make-up of each piece. Each letter of the string points to the user graphic which defines a quarter of the piece. The use of upper- and lower-case allows you to distinguish between black and white pieces. The dimension statement (520) re-sets the array automatically. Lines 1000-1130 print the blank board using magenta and green. They were chosen to give maximum contrast and therefore clarity for the pieces which were black and white for simplicity [The listing actually uses blue and white. JimG]. It is spaces that are printed using colour control characters (see page 115 of the manual) [Actually page 86. JimG] to define their paper colour. Remember to switch back to white paper after the fourth space. Lines 1500-1620 print the pieces on the board using black [blue] or white ink. Paper 8 keeps the board squares their original colour [The printed listing used PAPER 0. JimG]. Lines 1580 and 1590 keep the print position within the correct 2*2 square. Lines 2000-2200 enter the piece moves checking at 2120 that the move is within the board and allowing you to stop the game. Either capitals or lower-case are accepted in input, 2140 unprints the old position and 2160 prints the new, 2155 and 2156 convert pawns to queens. The variable set in 2150 allows use of earlier lines as a subroutine. It is re-set in 1520. Variable w (set in 260) allows the omission of some printing - blank squares on the initial run (line 1615) and reprinting the board (line 650) in subsequent games. w is reset at 2190.