
YOU WILL probably recognize Surround as soon as you RUN it. It is a version of a fairly standard routine in which you are required to surround your adversary before he can surround you. Both players are in continuous motion and are not allowed to cross their tracks or those of their opponent, or to hit the boundary or the score display.
What will surprise you is the way in which the T/S1000,ZX81 can recognize two keys when pressed simultaneously. That is not possible using INKEY$ and is achieved by utilizing address 16421. This contains a number which changes as groups of keys are pressed. Lines 185 to 260 translate the number into a series of possible moves.
Black uses keys 1-5 to move up, Z-V to move down, Q-T for right and A-G for left. Grey uses the keys 6-0 for up, Y-P for right, B-M for down, and H-ENTER for left. After a crash the other player scores one; the winner is the first to reach 15.
The routine enabling two players to participate can obviously be used in many graphics games. (T/S1000,ZX81 16K)
1 REM SURROUND BY J.WINCHESTER
5 LET SX=0
6 LET SB=C
7 LET O=PEEK 16396+256*PEEK 16397
10 POKE 16418,0
20 PRINT AT 0,0;"++++++++++++++++++++++++++++++++"
30 FOR P=1 TO 22
40 PRINT "+ +"
50 NEXT P
60 PRINT ;"++++++++++++++++++++++++++++++++"
70 PRINT AT 2,2;STR$ SX; AT 2,28;STR$ SB
80 LET X=12
90 LET Y=3
100 LET B=12
110 LET C=28
120 LET X1=0
130 LET Y1=1
140 LET B1=0
145 LET C1=-1
150 IF PEEK (O + 1 + Y + 33 * X) <> 0 THEN GOTO 400
160 IF PEEK (O + 1 + C + 33 * B) <> 0 THEN GOTO 300
170 PRINT AT X,Y;CHR$(128);AT B,C;CHR$(136)
180 LET A=PEEK 16421
185 IF A=238 OR A=222 OR A=190 OR A=254 OR A=126 THEN LET X1=1
190 IF A=247 OR A=231 OR A=215 OR A=183 OR A=119 THEN LET X1=-1
200 IF X1 <> 0 THEN LET Y1=0
210 IF A=235 OR A=251 OR A=219 OR A=187 OR A=125 THEN LET Y1=1
215 IF A=237 OR A=221 OR A=253 OR A=189 OR A=125 THEN LET Y1=-1
220 IF Y1 <> 0 THEN LET X1=0
230 IF A=231 OR A=239 OR A=235 OR A=237 OR A=238 THEN LET B1=-1
235 IF A=119 OR A=123 OR A=125 OR A=126 OR A=127 THEN LET B1=1
240 IF B1 <> 0 THEN LET C1=0
245 IF A=215 OR A=219 OR A=223 OR A=221 OR A=222 THEN LET C1=1
250 IF A=183 OR A=187 OR A=189 OR A=191 OR A=190 THEN LET C1=-1
260 IF C1 <> 0 THEN LET B1=0
270 LET X=X+X1
280 LET Y=Y+Y1
290 LET B=B+B1
295 GOTO 150
300 LET SX=SX+1
310 IF SX < 15 THEN GOTO 7
320 STOP
400 LET SB=SB+1
410 IF SB < 15 THEN GOTO 7
Media
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.