Chain
Reaction
Mark Tuttle
Mark Tuttle
In this explosive strategy game for a variety of computers, the contest is never finished until your last bomb has been thrown. The original version is written for the Commodore 64. We've written new translations for the Atari ST; Amiga; Apple II series (including Apple IIGS); Atari 400, 800, XL, and XE; and IBM PC/PCjr. The ST version requires a color monitor. The Amiga version requires 512K of memory. A joystick is required to play the 64 and eight-bit Atari games. The IBM PC/PCjr version of "Chain Reaction" requires a color monitor as well as BASIC and a color/graphics card for the PC and cartridge BASIC for the PCjr.
"Chain Reaction" is a clever strategy game for one or two players. Whether you play against the computer or another human, the objective is the same: to eliminate all of your opponent's bomb-shaped pieces from the field of play. The game is played on a 5 X 6 grid of squares, and the players alternate turns, placing one bomb in a square on each turn.
The results of a move depend on how many bombs are already in the chosen square and adjacent squares. Whenever any square reaches "critical mass," it explodes and sends its bombs into neighboring squares. If those squares are already loaded to capacity, they explode too, creating a chain reaction that can engulf a large area of the board.
Type in the version for your computer and save a copy of the program. Before you run the game, consult the special instructions for your computer as well. Some games are played with keyboard controls, while others use a joystick.
Bomb Begets Bomb
When you run Chain Reaction, it begins by asking whether you wish to play with one or two players. If you've never played before, you may want to play a game or two against the computer to learn what sort of strategies it favors. When you choose to play against the computer, the program also asks whether you'd like the computer to take the first turn.
The first part of most games involves placement of initial pieces, without many explosions. As the board fills up, however, explosions occur with increasing frequency. Play continues until one player's pieces are completely eliminated from the board.
The position of a square in the grid determines how many bombs it requires to create an explosion. A corner square can hold a maximum of one bomb. When you place a second bomb in a corner square that already holds one, both bombs explode, sending a bomb of your color into two neighboring squares. After an explosion, the original square is emptied.
Other squares require more bombs to create an explosion. A border square that isn't on a corner can hold a maximum of two bombs. When you place a third bomb in a border square, its explosion sends three bombs into the squares that adjoin it. Squares in the center of the game board hold the most bombs and also create the most devastating explosions. When you place a fourth bomb in a central square, it sends four bombs into squares which adjoin that position.
When an explosion sends bombs into adjacent squares, any bombs in that square change color to match the color of the exploding bombs. Should one of the adjoining squares surpass its limit, that square, too, will explode, creating the potential for even more explosions. This process continues until no more explosions are possible.
Thus, the situation in Chain Reaction is often volatile. The lead frequently seesaws back and forth between players, as each creates increasingly more widespread chain reactions. Even if defeat seems almost certain, you can often regain the lead with clever play. When a game ends, the program announces the winner and permits you to play a new game or quit.
Like other games of strategy and placement, Chain Reaction rewards the player who can think ahead. At first, you may be tempted to start making explosions as quickly as possible. But that's not always the best long-term tactic. By spreading bombs of your color throughout the board, you may be able to survive chain reactions that would otherwise wipe you out.
Commodore 64 Version
This version of Chain Reaction (Program 1) requires at least one joystick (plug the joystick into port 2 if you are using one joystick). If you choose the two-player option, the program also asks whether you wish to use one or two joysticks. A movable cursor of your color indicates your current position on the board. To place a bomb, move the cursor to the desired square and press the joystick button.
Atari ST Version
The ST version of Chain Reaction (Program 2) runs on any 520ST or 1040ST computer. A color monitor is required. Use the Set Preferences option to set the computer in low resolution before you activate ST BASIC. Use the cursor keys to move the cursor. To place a bomb, press the space bar.
Amiga Version
Chain Reaction for the Amiga (Program 3) requires 512K of memory. Use the cursor keys to move the cursor and press the space bar to place a bomb in the desired square.
Apple II Version
This version of Chain Reaction (Program 4) runs on any Apple IIseries computer, including the Apple IIGS. Use the 1, J, K, and M keys to move the cursor up, left, right, and down, respectively. To place a bomb, press the space bar.
Atari 400, 800, XL, And XE Version
Chain Reaction for eight-bit Atari computers (Program 5) requires a joystick. Plug the joystick into port 1 before you run the program. This version of Chain Reaction works exactly like the Commodore 64 game. Move the cursor to the square where you wish to place a bomb, then press the fire button.
IBM PC/PCjr Version
The IBM PC/PCjr version of Chain Reaction requires BASICA and a color/graphics card for the PC and cartridge BASIC for the PCjr. A color monitor is also required. Move the cursor with the cursor keys and press the space bar to place a bomb.
For instructions on entering these programs, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.
Program 1. Commodore 64 Chain Reaction
CK 10 Y=30:DIM U(Y),H(Y),L(Y),
J(Y),T1(Y),CA(Y),CD(Y),R
T(Y),TR(Y)
MC 20 POKE 53269,0:PRINT"{CLR}
":POKE 53280,11:POKE 532
81,11:Y=RND(-TI)
HR 30 ML$="[<1>]"+CHR$(8)+"[<X>]<"
+CHR$(3)+"[<23>]XJ"+CHR$(16
)+CHR$(248)+"L[<B>][<T>]":PO
KE 835,0
XJ 40 POKE 53272,PEEK(53272)AN
D 240 OR 12
PR 50 POKE 836,208:POKE 830,0:
POKE 831,216:POKE828,0:P
OKE 829,56:POKE 56334,0
QH 60 POKE 1,51:ML$=ML$:SYS(PE
EK(51)+256*PEEK(52)):POK
E 1,55:POKE56334,1
PP 70 FOR I=12296 TO 12487:REA
D J:POKE I,J:NEXT
DH 80 YY=7:XX=12:GOSUB530:PRIN
T"{CYN}CUAGI MDACOGKI"
HE 90 YY=11:XX=8:GOSUB530:PRIN
T"IBJPDM KE LHAYDMN
{YEL}Q{CYN} KM {YEL}R
EK 100 GOSUB700:IF KT$<>"1" AN
D KT$<>"2" THEN100
FQ 110 NP=VAL(KT$):IF NP=2 THE
N YY=15:GOTO160
CS 120 COMPUTER=1:YY=15:XX=9:G
OSUB530:PRINT"{CYN}CKJL
BODM EGMNO {YEL}Y{CYN)
{SPACE}KM {YEL}I
SE 130 GOSUB700:IF KT$<>"Y" AN
D KT$<>"N" THEN130
HE 140 TU=0:IF KT$="Y" THEN TU
=1
XX 150 GOTO190
HF 160 YY=15:XX=7:GOSUB530:PRI
NT"{CYN}IBJPDM KE SKYNO
GCTN {YEL}Q{CYN} KM
{YEL}R
AD 170 GOSUB700:IF KT$<>"1" AN
D KT$<>"2" THEN170
HF 180 POKE 828,VAL(KT$)-l:F2=
PEEK(828)
CQ 190 YY=19:XX=14:GOSUB530:PR
INT"{CYN}LHDAND WAGO"
EK 200 M$="O[<2 Y>]P{DOWN}
{4 LEFT}[<H>]{2 SPACES}
[<N>]{DOWN}{4 LEFT}[<H>]
{2 SPACES}[<N>]{DOWN}
{4 LEFT}L[<2 P<]@":B$="
{3 UP}":PL(0)=15:PL(1)=
10
PR 210 P$(1)="V {DOWN}{2 LEFT}
{2 SPACES}":P$ (2 )="V
{DOWN}{2 LEFT} V":P$(3)
="VV{DOWN}{2 LEFT} V":P
$(4)="VV{DOWN}{2 LEFT}V
V"
HP 220 UP=79:LM=91:RM=251:DN=2
07:CL(0)=15:CL(1)=10:MV
=1:MA=1:MD=1
FJ 230 FOR J=0 TO 24:POKE 5427
2+J,0:READ X:POKE 54272
+J,X:NEXT
QM 240 FOR V=1 TO 30:READ J(V)
:NEXT
PS 250 SV=53248:MX=79:MY=92:PO
KE 2042,11:FOR I=0 TO62
:READ Q:POKE 704+I,Q:NE
XT
BR 260 FOR I=1 TO 30:READ CD(I
),CA(I):NEXT
BM 270 POKE 53280,6:POKE 53281
,6:PRINT CHR$(31)"{CLR}
{BLU}";
QP 280 FOR I=0 TO 23:PRINT"
{RVS}{39 SPACES}"
CM 290 POKE 1063+(40*I),160:PO
KE 55335+(40*I),6:NEXT
EX 300 PRINT"{RVS}{39 SPACES}
{HOME}{BLK}":POKE2023,1
60:POKE56295,6
RE 310 POKE 53281,11:PRINT SPC
(l4)"{CYN}CUAGI MDACOGK
I{BLK}{DOWN}"
AC 320 FOR I=1 TO 5:PRINT SPC(
8)M$B$M$B$M$B$M$B$M$B$M
$:NEXT
HB 330 PRINT"{DOWN}{RVS}{BLU}
{32 SPACES}{HOME}":POKE
SV+41,7:GOSUB690
KF 340 X=TU:GOTO370
EB 350 FG=0:FOR H=l TO 30:IF U
(H)>=J(H) THEN FG=1:GOS
UB710
EC 360 NEXT:IF FG=l THEN350
ED 370 X=-X+1:PN=PN+1
BR 380 IF COMPUTER AND NOT X T
HEN POKE 53269,0:RD=0:G
OTO970
RH 390 POKE SV+41,CL(X):GOTO54
0
EC 400 H=MV
MA 410 IF L(H)<>X+l AND L(H) T
HEN380
PK 420 U(H)=U(H)+1:FS(X)=FS(X)
+1:IF L(H)=0 THEN L(H)=
X+l
XK 430 GOSUB510:PRINT P$(U(H))
AJ 440 IF U(H)>=J(H) THEN POKE
53269,0:GOSUB710:GOTO3
50
AB 450 GOTO370
MR 460 XX=15:YY=24:GOSUB530:PR
INT"{CYN}FAJD{RVS}{BLU}
{OFF}(CYN}KXDM{HOME}":
FOR Z=1 TO 2000:NEXT
DJ 470 XX=B:YY=24:GOSUB530:PRI
NT"LMDNN{RVS}{BLU}
{OFF}{CYN}EGMDPBOOKI
{RVS}{BLU} {OFF}{CYN}OK
{RVS){BLU} {OFF}{CYN}LH
AY{HOME}"
HS 480 WAIT 56320+X*F2,16,16:R
UN
QD 490 IF L(O)<>X+1 THEN FS(X)
=FS(X)+U(O):FS(-X+l)=FS
(-X+1)-U(O)
JP 500 L(O)=X+I:U(O)=U(O)+1:GO
SUB520:PRINT P$(U(O)):R
ETURN
RB 510 XX=5+(4*CA(H)):YY=4*CD(
H):POKE 646,CL(X):GOSUB
530:RETURN
MG 520 XX=5+(4*CA(O)):YY=4*CD(
O):POKE 646,CL(X):GOSUB
530:RETURN
KF 530 POKE 783,0:POKE 781,YY:
POKE 782,XX:SYS 65520:R
ETURN
PC 540 POKE 53269,4
FF 550 JY=15-(PEEK(56320+X*F2)
AND15):JB=PEEK(56320+X*
F2)AND16
QB 560 IF JB=0 THEN400
SC 570 IF JY=8 THEN JY=3
FF 580 IF JY<l OR JY>4 THEN550
PC 590 ON JY GOTO600,620,640,6
60
QC 600 IF MX-4<UP THEN550
XR 610 MX=MX-32:MV=MV-6:MD=MD-
1:GOTO680
MF 620 IF MX+4>DN THEN550
RJ 630 MX=MX+32:MV=MV+6:MD=MD+
1:GOTO680
GC 640 IF MY+4>RM THEN550
FQ 650 MY=MY+32:MV=MV+1:MA=MA+
1:GOTO680
FR 660 IF MY-4<LM THEN550
AC 670 MY=MY-32:MV=MV-1:MA=MA-
1
JG 680 GOSUB690:GOTO550
XA 690 POKE SV+4,MY:POKE SV+5,
MX:RETURN
MH 700 KT$="":POKE 198,0:WAIT
{SPACE}198,1:GET KT$:RE
TURN
PF 710 POKE 54276,64:POKE 5429
0,128:POKE 24276,65:POK
E 54290,129:FOR V=1 TO
{SPACE}4
CA 720 GOSUB510:POKE 646,PL(X)
:PRINT"{RVS}{UP}{LEFT}"
M$:GOSUB510:PRINT"{BLK}
{UP}{LEFT}"M$
XQ 730 FOR TD=l TO 125:NEXT:NE
XT
KH 740 U(H)=U(H)-J(H)
MR 750 IF U(H)>0 THEN GOSUB510
:PRINT P$(U(H)):GOTO770
GJ 760 L(H)=0
QX 770 IF CD(H)=1. THEN790
ED 780 O=H-6:GOSUB490
AG 790 IF CA(H)=l THEN810
CR 800 O=H-1:GOSUB490
FJ 810 IF CA(H)=6 THEN830
RC 820 O=H+1:GOSUB490
MQ 830 IF CD(H)=5 THEN850
RG 840 O=H+6:GOSUB490
XK 850 IF FS(0)<l OR FS(1)<l T
HEN460
MR 860 RETURN
RH 870 LP=0:IF CD(H)=l THEN890
KQ 880 IF L(H-6)=2 THEN KZ=H-6
:GOTO960
GX 890 IF CA(H)=l THEN910
JC 900 IF L(H-1)=2 THEN KZ=H-1
:GOTO960
MB 910 IF CA(H)=6 THEN930
CA 920 IF L(H+l)=2 THEN KZ=H+1
:GOTO960
RP 930 IF CD(H)=5 THEN RETURN
SP 940 IF L(H+6)=2 THEN KZ=H+6
:GOTO960
CD 950 RETURN
FQ 960 LP=1:RETURN
BF 970 FOR I=l TO 30:RT(I)=0:T
R(I)=0:NEXT
XE 980 XT=0:FOR I=l TO 30:IF L
(I)=2 THEN1000
PP 990 TI(XT+l)=I:XT=XT+l
AH 1000 NEXT:RD=0
HH 1010 XX=16:YY=24:GOSUB530:P
RINT"{CYN}OUGITGIF
{HOME}"
BR 1020 FOR I=30 TO 30-XT STEP
-1:RT(I)=0:NEXT:FOR I=
1 TO XT
XM 1030 H=T1(I):GOSUB870
JD 1040 IF FG=l AND LP AND U(H
)>0 THEN1220
GS 1050 IF U(H)+1=J(H) AND LP=
1 AND U(KZ)+1=J(KZ) TH
EN RT(I)=6:GOTO1170
PB 1060 IF U(H)+1=J(H) AND LP=
1 THEN RT(I)=2:GOTO117
0
RE 1070 IF U(H)+1=J(H) AND LP=
0 THEN RT(I)=1:GOTOll7
0
CH 1080 IF J(H)=2 AND LP=0 AND
U(H)=1 THEN RT(I)=1:G
OTO1170
JS 1090 IF J(H)=2 AND LP=0 AND
U(H)=0 THEN RT(I)=4:G
OTO1170
JQ 1100 IF J(H)=2 AND LP=l AND
U(H)=1 THEN RT(I)=4:G
OTO1170
FE 1110 IF U(KZ)+1=J(KZ) THEN
{SPACE}RT(I)=1:GOTO117
0
SJ 1120 IF U(H)+2>=J(H) AND LP
=l AND U(KZ)+1< J(KZ)
{SPACE}THEN RT(I)=5:GO
TO1170
AH 1130 IF U(H)+2>=J(H) AND LP
=0 THEN RT(I)=3:GOTO11
70
AP 1140 IF U(H)+2>=J(H) THEN R
T(I)=2:GOTO1170
MJ 1150 IF LP=0 THEN RT(I)=2:G
OTO1170
SE 1160 RT(I)=1
MQ 1170 NEXT I:TC=1:ZT=0:AB=6
KS 1180 FOR I=1 TO XT:IF RT(I)
=AB THEN TR(TC)=I:ZT=Z
T+1:TC=TC+1
QQ 1190 NEXT:IF ZT>0 THEN1210
CF 1200 AB=AB-l:GOTO1180
HP 1210 DH=INT(ZT*RND(1))+1:HD
=TR(DH):H=T1(HD)
HJ 1220 XX=15:YY=24:GOSUB530:P
RINT"{RVS}{BLU}
{11 SPACES}{HOME}":FG=
FG+1:GOTO410
HC 1230 DATA 126,102,102,126,1
02,102,102,0,102,102,1
02,102,102,102,126,0
DX 1240 DATA 126,98,96,96,96,9
8,126,0,126,98,96,120,
96,98,126,0,126,98
JS 1250 DATA 98,120,96,96,96,0
,126,102,96,110,102,10
2,126,0,126,90,24,24
QP 1260 DATA 24,90,126,0,96,96
,96,96,98,98,126,0,102
,118,126,126,110,102
MX 1270 DATA 102,0,99,119,127,
107,99,99,99,0,126,102
,102,102,102,102 126
QC 1280 DATA 0,126,102,102,126
,96,96,96,0,126 102,10
2,126,120,108,102,0
GJ 1290 DATA 126,102,96,126,6,
102,126,0,126,90,24,24
,24,24,24,0,124,102
SS 1300 DATA 102,124,102,102,1
24,0,56,24,24,24,24,24
,60,0,60,54,6,12,48
BR 1310 DATA 48,62,0,30,12,12,
12,12,108,124,0,230,10
8,120,112,120,108
GS 1320 DATA 230,0,231,102,102
,126,1_02,102,231,0,0,8
,16,124,222,190,254
AH 1330 DATA 124,198,198,198,2
14,254,238,198,0,231,1
02,102,102,102,60,24
HQ 1340 DATA 0,0,4,0,12,64,10,
0,0,0,0,12,64,12,0,0,4
,0,12,128,12,0,0,50
CF 1350 DATA 244,47,2,3,3,3,3,
2,3,4,4,4,4,3,3,4,4,4,
4,3,3,4,4,4,4,3,2,3
XK 1360 DATA 3,3,3,2,0,0,0,0,0
,0,120,0,30,192,0,3,19
2,0,3,192,0,3,0,0,0
JA 1370 DATA 0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,192,0
CB 1380 DATA 3,192,0,3,192,0,3
,120,0,30,0,0,0,1,1,1,
2,1,3,1,4,1,5,1,6,2,1
AD 1390 DATA 2,2,2,3,2,4,2,5,2
,6,3,1,3,2,3,3,3,4,3,5
,3,6,4,1,4,2,4,3,4
DQ 1400 DATA 4,4,5,4,6,5,1,5,2
,5,3,5,4,5,5,5,6
Program 2. Atari ST Chain Reaction
Version by Tim Midkiff, Editorial Programmer
10 OPENW 2:FULLW 2:CLEARW 2.
RANDOMIZE 0
20 DIM u(4,5),l(4,5),j(4,5),
rt(30),tr(30),tx(30),ty(3
0)
30 FOR i=0 TO l:fs(i)=O:hx(i
=O:hy(i)=0:NEXT
40 FOR i=0 TO 4:FOR j=0 TO 5
:u(i,j)=O:l(i,j)=0:j(i,j)
=4:NEXT
50 j(i,0)=3sj(i,5)=3:NEXT
60 RESTORE 70:FOR j=1 TO 4:j
(0,j)=3:j(4,j)=3:READ a,b
:j(a,b)=2:NEXT
70 DATA 0,0,0,5,4,0,4,5
80 RESTORE 130:FOR i=0 TO 12
:READ a$tFOR j=1 TO 3
90 c$=MID$(a$,j,l):co=VAL(c$
*125:POKE intin+j*2,co:N
EXT
100 POKE intin,i:POKE contrl,
14:POKE contrl+6,4:vdisys
(0):NEXT
110 DATA 224,541,665,651,000,
700,500,300,100,070,050,0
30,010
120 RANDOMIZE 0
130 COLOR 4:GOTOXY 0,3:PRINT
TAB(14)"CHAIN REACTION";
140 COLOR 3:GOTOXY 7,6:PRINT
"Number of players (1/2)?
150 np=VAL(INPUT$(1)):IF np<>
1 AND np<>2 THEN 150
160 IF np=2 THEN 210
170 GOTOXY 0,9:PRINT TAB(10)"
Computer first (Y/N)?";
180 tu=ASC(INPUT$(1)):IF to>1
00 THEN tu=tu-32
190 IF tu<>89 AND tu<>78 THEN
180
200 tu=ABS(tu=89)
210 COLOR 4:PRINT:CLEARW 2:GO
TOXY 11,0:PRINT "CHAIN RE
ACTION";:GOSUB 650
220 tu=-to+l:co=to*4+5
230 IF np=1 AND to=0 THEN GOS
US 970:GOTO 260
240 GOSUB 400
250 IF 1(y,x)<>tu+l AND 1(y,x
)<>0 THEN 240
260 pu=u(y,x):u(y,x)=pu+l:fs(
tu)=fs(tu)+1:IF 1(y,x)=0
THEN 1(y,x)=tu+1
270 GOSUB 770
280 IF u(y,x)=j(y,x) THEN 300
290 GOTO 220
300 e=0:fg=0:FOR p=0 TO 4:FOR
q=0 TO S:y=p:x=q
310 IF u(y,x)>=j(y,x) AND e=0
THEN +g=1:GUSUb 490
320 NEXT q,p:IF e=1 THEN 350
330 IF fg=1 THEN 300
340 GOTO 220
350 COLOR 3:GOTOXY 13,17:PRIN
T "GAME OVER";
360 FOR i=1 TO 3:PRINT CHR$(7
);:FOR j=1 TO 500:NEXT:NE
XT
370 GOTOXY 4,17:PRINT "Press
space bar to play again."
;
380 k=INP(2):IF k<>32 THEN 38
0
390 CLEARW 2:CLEAR:GOTO 20
400 x=hx(tu):y=hy(tu):GOSUB 7
l0:PRINT CHR3(7);
410 dx=0:dy=0:k=INP(2)
420 IF k= 32 THEN hx(tu)=x:hy
(tu)=y:co=0:GOSUS 710:co=
to*4+5:RETURN
430 IF k=200 THEN IF y>0 THEN
dy=-1
440 IF k=208 THEN IF y<4 THEN
dy=1
450 IF k=203 THEN IF x>0 THEN
dx=-1
460 IF k=205 THEN IF x<5 THEN
dx=1
470 IF dx=0 AND dy=0 THEN 410
480 co=0:GOSUB 710:x=x+dx:y=y
+dy:co=to*4+5:GOSUB 710:G
OTO 410
490 tx=x:ty=y:co=4:GOSUB 710
500 IF tx>0 THEN x=tx-I:GOSUB
570
510 IF tx<5 THEN x=tx+1:GOSUB
570
520 x=tx:IF ty>0 THEN y=ty-1:
GOSUB 570
530 IF ty<4 THEN y=ty+1:GOSUB
570
540 IF fs(0)<l OR fs(l)<l THE
N e=1
550 y=ty:pu=u(y,x):u(y,x)=pu-
i(y,x):GOSUB 770:IF u(y,x
=0 THEN 1(y,x)=0
560 co=0:x=tx:y=ty:GDSUB 710:
RETURN
570 IF 1(y,x)<>tu+l THEN fs(t
U)=fs(tu)+u(y,x):fs(-tu+l
)=fs(-to+l)-u(y,x)
580 1(y,x)=to+l:pu=u(y,x)su(y
,x)=pu+1:GOSUB 770:RETURN
590 lp=0:IF y>0 THEN IF 1(y-1
,x)=2 THEN ay=y-1:GOTO 64
0
600 IF x>0 THEN IF 1(y,x-1)=2
THEN ax=x-1:GOTO 640
610 IF x<5 THEN IF 1(y,x+l)=2
THEN ax=x+1:GDTO 640
620 IF y<4 THEN IF 1(y+l,x)=2
THEN ay=y+1:GOTO 640
630 RETURN
640 Ip=1:RETURN
650 COLOR 1,1,2:FOR y=0 TO 4:
yy=28*y+12:FOR x=0 TO 5:x
x=32*x+59
660 LINEF xx,yy,xx+30,yy:LINE
F xx+30,yy,xx+30,yy+26
670 LINEF xx+30,yy+26,xx,yy+2
6:LINEF xx,yy+26,xx,yy
680 NEXT x,y:RETURN
690 COLOR 1,0,tu*4+4+i:CIRCLE
bx,by,i:RETURN
700 COLOR 1,0,0:CIRCLE bx,by,
4-i:RETURN
710 yy=28*y+ll:xx=32*x+58:COL
OR 1,co,co
720 LINEF xx,yy,xx+32,yy:LINE
F xx+32,yy,xx+32,yy+28
730 LINEF xx+32,yy+28,xx,yy+2
S:LINEF xx,yy+28,xx,yy
740 LINEF xx+2,yy+2,xx+30,yy+
2:LINEF xx+30,yy+2,xx+30,
yy+26
750 LINEF xx+30,yy+26,xx+2,yy
+26:LINEF xx+2,yy+26,xx+2
,yy+2
760 RETURN
770 yy=28*y+12:xx=32*x+59
780 ON pu+l GOSUB 890,900,910
,930,950,950
790 k=u(y,x)+1sIF k=6-THEN k=
5
800 ON k GOTO 810,820,830,850
,870,870
810 RETURN
820 FOR i=1 TO 4tbx=xx+15sby=
yy+13:GOSUB 690sNEXT:RETU
RN
830 by=yy+13tFOR i=1 TO 4sbx=
xx+9sGDSUB 690
840 bx=xx+21:GOSUB 690:NEXT:R
ETURN
850 FOR i=1 TO 4:bx-xx+15sby-
yy+9:GOSUB 690sby-yy+17
860 bx=xx+9:GOSUB 690:bx=xx+2
1:GOSUB 690:NEXT:RETURN
870 FOR i=1 TO 4:by=yy+13tbx=
xx+9:GOSUB 690:bx=xx+21:G
OSUB 690
880 bx=xx+15:by=yy+7:GOSUB 69
0:by=yy+19:GOSUB 690:NEXT
:RETURN
890 RETURN
900 FOR i=0 TO 3:bx=xx+15:by=
yy+13:GOSUB 700:NEXT:RETU
RN
910 by=yy+13:FOR i=0 TO 3:bx=
xx+9:GOSUB 700
920 bx=xx+21:GOSUB 700:NEXT:R
ETURN
930 FOR i=0 TO 3:bx=xx+15:by=
yy+9:GOSUB 700:by=yy+17
940 bx=xx+9:GOSUB 700:bx=xx+2
1:GOSUB 700:NEXT:RETURN
950 FOR i=0 TO 3:by=yy+13:bx=
xx+9:GOSUB 700:bx=xx+21:G
OSUB 700
960 bx=xx+15:by=yy+7:GUSUb 70
0:by-yy+19:GOSUB 7001NEXT
:RETURN
970 xt=0:FOR y=0 TO 4:FOR x=0
TO 5:IF 1(y,x)=2 THEN 99
0
980 xt=xt+l:ty(xt)=y:tx(xt)=x
990 NEXT x,y
1000 GOTOXY 0,16:PRINT:PRINT T
AB(15)"Thinking...";
1010 FOR i=1 TO xt:rt(i)=0:tr(
i)=0:y=ty(i):x=tx(i):GOSU
B 590
1020 IF +g=1 AND 1p<>0 AND u(y
,x)>0 THEN 1230
1030 IF u(y,x)+1<>j(y,x) THEN
1070
1040 IF 1p=1 AND u(ay,ax)+1=j(
ay,ax) THEN rt(i)=6:GOTO
1180
1050 IF 1p=1 THEN rt(i)=2:GOTO
1180
1060 IF lp=0 THEN rt(i)=1:GDTO
1180
1070 IF j(y,x)<>2 THEN 1110
1080 IF lp=0 AND u(y,x)=1 THEN
rt(i)=1:GOTO 1180
1090 1F 1p=0 AND u(y,x)=0 THEN
rt(i)=4:GOTO 1180
1100 IF 1p=1 AND u(y,x)=1 THEN
rt(i)=4:GOTO 1180
1110 IF u(ay,ax)+1=j(ay,ax) TH
EN rt(i)=1:GOTO 1180
1120 IF u(y,x)+2<j(y,x) THEN 1
160
1130 IF 1p=1 AND u(ay,ax)+1<j(
ay,ax) THEN rt(i)=5:GOTO
1180
1140 IF lp=0 THEN rt(i)=3:GOTO
1180
1150 rt(i)=2:GOTO 1180
1160 IF lp=0 THEN rt(i)=2:GOTO
1180
1170 rt(i)=1
1180 NEXT:zt=0:ab=6
1190 FOR i=1 TO xt:IF rt(i)=ab
THEN zt=zt+l:tr(zt)=i
1200 NEXT:IF zt>0 THEN 1220
1210 ab=ab-1:GOTO 1190
1220 dh=INT(zt*RND)+1:hd=tr(dh
):y=ty(hd):x=tx(hd)
1230 GOTOXY 0,16:PRINT:PRINT T
AB(15)" ";:fg=f
g+1:RETURN
Program 3. Amiga Chain Reaction
Version by Tim Midkiff, Editorial Programmer
DEFINT a-z:DEFSNG r,g,b←
SCREEN 1,320,200,3,1:WINDOW 3,""
,(0,0)-(311,186),16,1:WINDOW OUT
PUT 3:COLOR 3,0←
DIM s(42,1),u(4,5),p(4,5),j(4,5)
bx(4,5),by(4,5),n(1,5),er(528),
wl(255),w2(255),rt(30),tr(30),tx
(30),ty(30)←
FOR i=0 TO 255:w1(i)=RND*255-128
:w2(i)=RND*255-128:NEXT←
RESTORE PaletteData:FOR i=0 TO 7
:READ r,g,b:PALETTE i,r,g,b:NEXT
←
PaletteData: ←
DATA 0,0,.7,0,0,0,.8,.8,0,.7,.7,
.7,.33,.87,0,.9,.9,.9,.6,0,0,0,.
6,0←
WIDTH 40:CLS:RANDOMIZE TIMER←
GOSUB InitShapes:e=0←
FOR i=1 TO 3:FOR j=1 TO 4:j(i,j)
=4:NEXT:j(i,0)=3:j(i,5)=3:NEXT←
RESTORE Corners:FOR j=1 TO 4:j(0
,j)=3:j(4,j)=3:READ a,b:j(a,b)=2
:NEXT←
Corners: DATA 0,0,0,5,4,0,4,5←
RESTORE BombPos:FOR i=1 TO 4:FOR
j=1 TO i:READ bx(i,j),by(i,j):NE
XT j,i←
bx(4,5)=bx(4,4):by(4,5)=by(4,4)←
BombPos: DATA 13,9,6,9,20,9,13,5
4,15,22,15,13,3,13,17,4,9,22,9←
LOCATE 8,14:PRINT "CHAIN REACTIO
N"←
LOCATE 12,9:PRINT "Number of pla
yers (1/2)?";←
WHILE np<>1 AND np<>2:np=VAL(INK
EY$):WEND←
IF np<>2 THEN←
LOCATE 16,10:PRINT "Computer fir
st (Y/N)?"t←
WHILE k$<>"Y" AND k$<>"N":k$=UCA
'SE$(INKEY$):WEND←
tu=ABS(k$="Y")←
END IF←
CLS:COLOR 3,1:LOCATE 1,13:PRINT
" CHAIN REACTION :;←
GOSUB DrawGrid←
←
MainLoop:←
WHILE e=O:tu=-tu+l:co=tu+6←
IF np=1 AND tu=O THEN←
GOSUB Computer←
ELSE←
GOSUB Human←
WHILE p(y,x)<>tu+l AND p(y,x):GO
SUB Human:WEND←
END IF←
u(y,x)=u(y,x)+1:FS(tu)=FS(tu)+1:
IF p(y,x)=0 THEN p(y,x)=tu+1←
GOSUB P1aceBomb←
IF u(y,x)=j(y,x) THEN ←
CheckGrid: e=0:fg=0:FOR p=0 TO 4
:FOR q=0 TO 5:y=p:x=q←
IF u(y,x)>=j(y,x) AND e=0 THEN f
g=1:GOSUB FullSquare←
NEXT q,p:IF fg=l AND e=0 THEN Ch
eckGrid←
END IF←
WEND←
←
EndGame:←
COLOR 3,1:LOCATE 24,15:PRINT " G
AME OVER ";:FOR i=1 TO 10000:NEX
T←
LOCATE 24,5:PRINT " Press space
bar to play again. ";←
k$='-':WHILE k$<>" ":k$=INKEY$:WE
ND←
SCREEN CLOSE 3:WINDOW CLOSE 3:RU
N←
←
Human:←
WHILE INKEY$<>'-:WEND:x=hx(tu):y
=hy(tu):dx=O:dy=O:GOSUB DrawCurs
or:k$=""←
WHILE k$<>" ":k$=INKEY$←
IF k$=CHR$(28) THEN IF y>0 THEN
dy=-1←
IF k$=CHR$(29) THEN IF y<4 THEN
dy=1←
IF k$=CHR$(31) THEN IF x>0 THEN
dx=-1←
IF k$=CHR$(30) THEN IF x<5 THEN
dx=1←
IF dx<>0 OR dy<>0 THEN←
co=O:GOSUB DrawCursor←
x=x+dx:y=y+dy:co=tu+6:GOSUB Draw
Cursor←
dx=0:dy=0←
END IF←
WEND:hx(tu)=x:hy(tu)=y←
co=O:GOSUB DrawCursor:co=tu+6:RE
TURN←
←
FullSquare:←
r=O:yy=32*y+15:xx=36*x+50:WAVE 0
,wl:WAVE l,w2←
FOR i=l TO 4:PUT(xx+2,yy+2),er,P
SET←
FOR j=1 TO 4:n(l,j)=INT(RND*3)-1
:NEXT←
r=-r+l:k=u(y,x)+l:bn=co-6:IF k=6
THEN k=5←
ON k GOSUB bO,bl,b2,b3,b4,b4←
FOR m=255 TO 10 STEP-20:SOUND 10
0,.l,m,0←4
SOUND 100,.1,m,3:FOR n=1 TO RND*
20:NEXT n,m:NEXT←
tx=x:ty=y:J1=0:K1=k-l:y1=32*y+15
+by(1,1):xl=36*x+50+bx(1,1)←
IF tx>0 THEN x=tx-l:dx=-l:dy=0:G
OSUB ExplodeBombs:GOSUB AddBomb←
IF tx<5 THEN x=tx+l:dx=l:dy=0:GO
SUB ExplodeBombs:GOSUB AddBomb←
x=tx:IF ty>O THEN y=ty-l:dy=-l:d
x=O:GOSUB ExplodeBombs:GOSUB Add
Bomb←
IF ty<4 THEN y=ty+l:dy=l:dx=0:GO
SUB ExplodeBombs:GOSUB AddBomb←
IF FS(0)<1 OR FS(1)<l THEN e=1←
y=ty:u(y,x)=u(y,x)-j(y,x):GOSUB
P1aceBomb:IF u(y,x)=0 THEN p(y,x
)=0←
RETURN←
←
AddBomb:←
IF p(y,x)<>tu+l THEN FS(tu)=FS(t
u)+u(y,x):FS(-to+l)=FS(-to+l)-u(
Y,x)←
p(y,x)=tu+l:u(y,x)=u(y,x)+l:GOSU
B P1aceBomb:RETURN←
←
DrawGrid:←
FOR y=0 TO 4:yy=32*y+16:FOR x=0
TO 5:xx=36*x+51←
LINE(xx,yy)-(xx+34,yy+30),2,b←
NEXT x,y←
GET(xx+l,yy+l)-(xx+33,yy+29),er:
RETURN←
←
DrawCursor:←
yy=32*y+15:xx=36*x+50←
LINE(xx,yy)-(xx+36,yy+32),co,b←
LINE(xx+2,yy+2)-(xx+34,yy+30),co
,b ←
RETURN←
←
P1aceBomb:←
yy=32*y+15:xx=36*x+50:r=0:bn=co-
6←
PUT(xx+2,yy+2),er,PSET:k=u(y,x)+
1:IF k=6 THEN k=5←
ON k GOTO b0,bl,b2,b3,b4,b4←
b0: RETURN←
bl: PUT(xx+bx(l,k-1),yy+by(l,k-1
)),s(0,bn):RETURN←
b2: FOR j=1 TO k-1:PUT(xx+bx(2,j
+n(r,j),yy+by(2,j)+n(r,j)),s(0,
bn):NEXT:RETURN←
b3: FOR j=1 TO k-l:PUT(xx+bx(3,j
+n(r,j),yy+by(3,j)+n(r,j)),s(0,,
bn):NEXT:RETURN←
b4: FOR j=1 TO k-1:PUT(xx+bx(4,j
+n(r,j),yy+by(4,j)+n(r,j)),s(0,
bn):NEXT:RETURN←
←
CheckNeighbor:←
fp=1:IF y>0 THEN IF p(y-l,x)=2 T
HEN ay=y-l:RETURN←
IF x>0 THEN IF p(y,x-1)=2 THEN a
x=x-l:RETURN←
IF x45 THEN IF p(y,x+l)=2 THEN a
x=x+l:RETURN←
IF y<4 THEN IF p(y+l,x)=2 THEN a
y=y+1:RETURN←
fp=0:RETURN←
←
Computer:←
xt=0:FOR y=0 TO 4:FOR x=0 TO 5←
IF p(y,x)<>2 THEN xt=xt+l:ty(xt)
=y:tx(xt)=x←
NEXT x,y←
LOCATE 24,15:COLOR 3,0:PRINT "Th
inking. ..";←
FOR i=1 TO xt:rt(i)=O:tr(i)=O:y=
ty(i):x=tx(i):GOSUB CheckNeighbo
r←
IF fg=1 AND fp AND u(y,x)>0 THEN
EndComputer←
IF u(y,x)+1=j(y,x) THEN ←
IF fp=1 AND u(ay,ax)+1=j(ay,ax)
THEN rt(i)=6:GOTO CheckNext←
IF fp=1 THEN rt(i)=2:GOTO CheckN
ext←
IF fp=0 THEN rt(i)=1:GOTO CheckN
ext←
END IF←
IF j(y,x)=2 THEN-4
IF fp=0 AND u(y,x)=1 THEN rt(i)=
1:GOTO CheckNext←
IF fp=0 AND u(y,x)=0 THEN rt(i)=
4:GOTO CheckNext←
IF fp=1 AND u(y,x)=1 THEN rt(i)=
4:GOTO CheckNext←
END IF←
IF u(ay,ax)+1=j(ay,ax) THEN rt(i
=1:GOTO CheckNext←
IF u(y,x)+2>=j(y,x) THEN←
IF fp=1 AND u(ay,ax)+1<j(ay,ax)
THEN rt(i)=5:GOTO CheckNext←
IF fp=0 THEN rt(i)=3:GOTO CheckN
ext←
rt(i)=2:GOTO CheckNext←
END IF←
IF fp=0 THEN rt(i)=2:GOTO CheckN
ext←
rt(i)=1←
CheckNext: NEXT:zt=0:ab=6←
WHILE zt=0←
FOR i=1 TO xt:IF rt(i)=ab THEN z
t=zt+l:tr(zt)=i←
NEXT:ab=ab-1←
WEND←
dh=INT(zt*RND)+l:hd=tr(dh):y=ty(
hd):x=tx(hd)←
EndComputer: LOCATE 24,15:PRINT
" ";:fg=fg+1:RETURN←
←
ExplodeBombs:←
Jl=Jl+l:xx=xl-bx(1,1):yy=yl-by(1
,1):s=1087:bn=co-6←
WAVE 0,SIN:SOUND 660,.5,255←
FOR j=1 TO 500:NEXT:SOUND 010,0←
PUT(xx+bx(K1,J1)+n(r,Jl),yy+by(K
1,J1)+n(r,Jl)),s(0,bn)←
IF dy=0 THEN ←
X2=xl+35*dx:dx=dx*4:PUT(xl,yl),s
(0,bn)←
FOR i=xl TO X2 STEP dx:s=s-40:SO
UND x,1,50←
PUT(i,yl),s(O,bn):PUT(i+dx,yl),s
(O,bn):NEXT←
PUT(xx+3,yy+3),er←
ELSE←
Y2=yl+31*dy:dy=dy*4:PUT (xl,yl),s
(0,bn)←
FOR i=y1 TO Y2 STEP dy:s=s-40:S0
UND s,1,50←
PUT(xl,i),s(0,bn):PUT(xl,i+dy),s
(0,bn):NEXT←
PUT(xx+3,yy+3),er←
END IF←
RETURN←
←
InitShapes:←
RESTORE RedBomb←
FOR j=0 TO 1:FOR i=0 TO 42←
READ a$:s(i,j)=VAL("&H"+a$):NEXT
i,j:RETURN←
←
RedBomb: DATA B,D,3,200,400,400,
0,1800←
DATA 3000,1B00,A00,400,A00,1B00,
0,0←
DATA 0,0,0,E00,2780,4FC0,E4E0,F5
E0←
DATA FBE0,F5E0,64C0,3F80,E00,200
,400,400←
DATA E00,3F80,7FC0,E4E0,F5E0,FBE
0,F5E0,64C0←4
DATA 3F80,E00,3F80←
←
GreenBomb: DATA B,D,3,200,400,40
0,E00,3F80←
DATA 7FC0,FFE0,FFE0,FFE0,FFE0,7F
C0,3F80,E00←
DATA 0,0,0,E00,2780,4FC0,E4E0,F5
E0←
DATA FBE0,F5E0,64C0,3F80,E00,200
,400,400←
DATA E00,3F80,7FC0,E4E0,F5E0,FBE
0,F5E0,64C0←
DATA 3F80,E00,3F80←
←
←
Program 4. Apple II Chain Reaction
Version by Tim Midkiff, Editorial Programmer
F9 10 DIM U(4,5).L(4,5),J(4,5),B
X(4.5),BY(4,5),RT(30),TR(3
(?)),TX(30),TY(30)
EF 15 FOR I = 1 TO 3: FOR J = 1
TO 4:J(I,J) = 4: NEXT :J(I
,0) = 3:J(I,5) = 3: NEXT
E3 20 FOR J = 1 TO 4:J(0,J) = 3:
J(4,J) = 3: READ A,B:J(A,B
) = 2: NEXT
8B 25 DATA 0,0,0.5,4,0,4,5
A9 30 TEXT : HOME : VTAB 8: HTAB
14: PRINT "CHAIN REACTION
"
C5 35 VTAB 12: HTAB 9: PRINT "NU
MBER OF PLAYERS (1/2)?";
26 40 GET K:$: IF K$ < > "1" AND
K$ < > "2" THEN 40
31 45 NP = VAL (K$): IF NP = 2 T
HEN 310
5B 50 VTAB 16: HTAB 10: PRINT "C
OMPUTER FIRST (Y/N)?";
03 55 GET K$: IF K$ < > "Y" AND
K$ < > "N" THEN 55
6C 60 TU = ABS (K$ = "Y")
3E 310 HGR : VTAB 21: HTAB 14: P
RINT "CHAIN REACTION";: G
OSUB 1000
6B 370 TU = - TU + 1
2F 380 IF NP = 1 AND TU = 0 THEN
GOSUB 1970: GOTO 420
58 390 GOSUB 540
D1 410 IF L(Y,X) = - TU + 2 THEN
390
82 420 U(Y,X) = U(Y,X) + 1:FS(TU
) = FS(TU) + 1: IF L(Y,X)
= 0 THEN L(Y,X) = TU + 1
CC 430 GOSUB 1300
A3 440 IF U(Y,X) = J(Y,X) THEN 4
50
B1 445 GOTO 370
29 450 E = 0: FG = 0: FOR A = 0 T
O 4: FOR B = 0 TO 5:Y = A
:X = B
52 455 IF U(Y,X) : = J(Y,X) AND
E = 0 THEN FG = 1: GOSUB
710
A2 460 NEXT B,A: IF E = 1 THEN 4
70
4B 463 IF FG = 1 THEN 450
B5 465 GOTO 370
CA 470 HTAB 16: VTAB 23: PRINT "
GAME OVER";: FOR I = 1 TO
1000: NEXT
45 480 HTAB 6: PRINT "PRESS SPAC
E BAR TO PLAY AGAIN.";
OB 490 POKE 49168,0:K = PEEK, (49
152) - 128: IF K < > 32 T
HEN 490
A7 500 RUN
0F 540 X = HX(TU + 1):Y = HY(TU
+ 1): HCOLOR= TU t 4 + 1:
GOSUB 1200: POKE (49168)
,0
98 545 DX = 0:DY = 0:K = PEEK (4
9152) - 128: IF K < 0 THE
N 545
26 548 K$ = CHR$ (K): POKE 49168
,0: IF K$ = " " THEN HCOL
OR= 4: GOSUB 1200:HX(TU +
1) = X:HY(TU + 1) = Y: R
ETURN
97 550 IF K$ = "I" THEN IF Y > 0
THEN DY = - 1
BE 560 IF K$ = "M" THEN IF Y < 4
THEN DY = 1
99 570 IF K$ = "J" THEN IF X > 0
THEN DX = - 1
C2 580 IF Kf ="K" THEN IF X < 5
THEN DX = 1
9E 585 IF DX = 0 AND DY = 0 THEN
545
23 590 HCOLOR= 4: GOSUB 1200:X =
X + DX:Y = Y + DY: HCOLO
R= TU * 4 + 1: GOSUB 1200
: GOTO 545
D0 710 R = 0: YY = 30 * Y: XX = 38
* X + 30
ED 715 FOR I = 1 TO U(Y,X):S = P
EEK ( - 16336): FOR J = 1
TO 5: NEXT J,I
0C 720 U(Y,X) = U(Y,X) - J(Y,X):
GOSUB 1300
D5 730 IF U(Y,X) = 0 THEN L(Y,X)
= 0
B1 740 TX = X: TY = Y
02 750 IF TX > 0 THEN X = TX - 1
: GOSUB 800
04 760 IF TX < 5 THEN X = TX + 1
: GOSUB 800
6A 770 X = TX: IF TY > 0 THEN Y
= TY - 1: GOSUB 800
68 780 IF TY < 4 THEN Y = TY + 1
: GOSUB 800
84 790 IF FS(0) < 1 OR FS(1) < 1
THEN E = 1
82 795 Y = TY: RETURN
84 800 IF L(Y,X) < > TU + 1 THEN
FS(TU) - FS(TU) + U(Y,X)
:FS( - TU + 1) = FS( - TU
+ 1) - U(Y,X)
37 810 L(Y,X) = TU + 1:U(Y,X) =
U(Y,X) + 1:S = PEEK ( - 1
6336): GOSUB 1300: RETURN
67 870 LP = 0: IF Y > 0 THEN IF
L(Y - I,X) = 2 THEN AY =
Y - 1: GOTO 960
9C 890 IF X > 0 THEN IF L(Y,X -
1) = 2 THEN AX = X - 1: G
OTO 960
7D 910 IF X < 5 THEN IF L(Y,X +
1) = 2 THEN AX = X + 1: G
OTO 960
9D 930 IF Y < 4 THEN IF L(Y + 1,
X) = 7 THEN AY = Y + 1 : G
OTO 960
23 950 RETURN
46 960 LP = 1: RETURN
E5 1000 HCOLOR= 7: FOR I = 0 TO
1 : FOR Y = 0 TO 5: YY = 3
0 * Y + I
6E 1010 HPLOT 30,YY TO 258,YY: N
EXT Y,I
BA 1020 FOR I = 0 TO 1: FOR X =
0 TO 6: XX = 38 * X + 30
+ I: HPLOT XX,0 TO XX,15
0: NEXT X,I
DD 1030 RETURN
IC 1100 HCOLOR= 7: HPLOT P + 3,Q
: HPLOT P + 4,0
A2 1105 HCOLOR= TU * 4 + 1: HPLO
T P + 2,0 + 1 TO P + 4,Q
+ 1
F9 1110 FOR N = 2 TO 5: HPLOT P,
Q + N TO P + 6,Q + N: NE
XT
37 1120 HPLOT P + 2,Q + 6 TO P +
4,Q + 6: RETURN
79 1200 FOR I = 2 TO 3:X1 = 38
X + 30 + I:X2 = X1 + 33
:Y1 = 30 * Y + I:Y2 = Y1
+ 26
BA 1210 HPLOT X1,Y1 TO X2,Y1 TO
X2,Y2 TO X1,Y2 TO XI,Y1:
NEXT : RETURN
27 1300 XX = 38 * X + 30:YY = 30
* Y: HCOLOR= 4:K = U(Y,
X) + 1: IF K = 6 THEN K
= 5
89 1305 FOR Q = YY + 6 TO YY + 2
6: HPLOT XX + 10,0 TO XX
+ 28,Q: NEXT : HCOLOR=
TU * 4 + 1
E7 1310 ON K GOTO 1320,1330,1340
,1350,1360,1360
DF 1320 RETURN
85 1330 P = XX + 16:Q = YY + 13:
GOSUB 1100: RETURN
EF 1340 P = XX + 10:Q = YY + 13:
GOSUB 1100:P = XX + 20:
GOSUB 1100: RETURN
El 1350 P = XX + 16:Q = YY + 10:
GOSUB 1100:P = XX + 10:
Q = YY + 17: GOSUB 1100:
P = XX + 20: GOSUB 1100:
RETURN
C5 1360 P = XX + 16:Q = YY + 6:
GOSUB 1100:Q = YY + 19:
GOSUB 1100:P = XX + 10:Q
= YY + 13: GOSUB 1100:P
= XX + 22: GOSUB 1100:
RETURN
40 1970 XT = 0: FOR Y = 0 TO 4:
FOR X = 0 TO 5: IF L(Y,X
) = 2 THEN 2000
E0 1990 XT = XT + 1:TY(XT) = Y:T
X(XT) = X
3C 2000 NEXT X,Y
D0 2010 HTAB 15: VTAB 23: PRINT
"THINKING...";
6C 2020 FOR I = 1 TO XT:RT(I) =
0:TR(I) = 0:Y = TY(I):X
= TX(I): GOSUB 870
4E 2040 IF FG = 1 AND LP AND U(Y
,X) > 0 THEN 2220
62 2045 IF U(Y,X) + 1 < > J(Y,X)
THEN 2075
3D 2050 IF LP = 1 AND U(AY,AX) +
1 = J(AY,AX) THEN RT(I)
= 6: GOTO 2170
13 2060 IF LP = 0 AND U(Y,X) = 0
THEN RT(I) = 4: GOTO 21
70
13 2070 IF LP = 0 THEN RT(I) = 1
: GOTO 2170
5E 2075 IF J(Y,X) < > 2 THEN 211
0
A9 2080 IF LP = 0 AND U(Y,X) = 1
THEN RT(I) = 1: GOTO 21
70
1F 2090 IF LP = 0 AND U(Y,X) = 0
THEN RT(I) = 4: GOTO 21
70
8D 2100 IF LP = 1 AND U(Y,X) = 1
THEN RT(I) = 1: GOTO 21
70
51 2110 IF U(AY,AX) + 1 = J(AY,A
X) THEN RT(I) = 1: GOTO
2170
27 2115 IF U(Y,X) + 2 < J(Y,X) T
HEN 2150
AE 2120 IF LP = 1 AND U(AY,AX) +
1 < J(AY,AX) THEN RT(I)
= 5: GOTO 2170
25 2130 IF LP = 0 THEN RT(I) = 3
: GOTO 2170
19 2140 RT(I) = 2: GOTO 2170
ID 2150 IF LP = 0 THEN RT(I) = 2
:GOTO 2170
39 2160 RT(I) = 1
DI 2170 NEXT :ZT = 0:AB = 6
34 2180 FOR I = 1 TO XT: IF RT(I
) = AB THEN ZT = ZT + 1:
TR(ZT) = I
77 2190 NEXT : IF ZT > 0 THEN 22
10
F1 2200 AB = AB - 1: GOTO 2180
E9 2210 DH = INT (ZT * RND (1))
+ 1:HD = TR(DH):Y = TY(H
D):X = TX(HD)
8B 2220 HTAB 15: PRINT "
";:FG + FG + 1: RETUR
N
Program 5. Chain Reaction For Atari 400, 800, XL, And XE
Version by Tim Midkiff, Editorial Programmer
GE 10 GRAPHICS 0:POKE 752,1:
SETCOLOR 2,0,0:? "PLEA
SE WAIT...":GOSUB 690
JJ 20 OPEN 41,4,0,"K:"
GI 30 DIM U(4,5),L(4,5),J(4,
5),FS(1),PB$(2),PS$(2)
,TS$(2),B$(1),S$(1),BL
$(2)
DH 40 DIM RT(30),TR(30),TX(3
0),TY(30)
CP 50 FS(0)=0:FS(1)=0:HX=0:H
Y=0:PS$="#$":PB$="%&":
BL$=" "
GB 60 FOR I=0 TO 4:FOR J=0 T
O 5:U(I,J)=0:L(I,J)=0:
J(I,J)=4:NEXT J
MI 70 J(I,0)=3:J(I,S)=3:NEXT
I
DK 80 RESTORE 90:FOR J=1 TO
4:J(0,J)=3:J(4,J)=3:RE
AD A,B:J(A,B)=2:NEXT J
EJ 90 DATA 0,0,0,5,4,0,4,5
LK 100 ? CHR$ (1 25 )
ED 110 POSITION 13,7:? "CHAI
N REACTION"
GG 120 POSITION 8,11:? "NUMB
ER OF PLAYERS (1/2)?"
;
NA 130 GET #1,NP:NP=NP-48:IF
NP<>1 AND NP<>2 THEN
130
PJ 140 IF NP-2 THEN 180
CL 150 POSITION 9,15:? "COMP
UTER FIRST (Y/N)?";
CI 160 GET #1,TU:IF TU<>89 A
ND TU<>78 THEN 160
CL 170 TU=(TU=89):GOTO 200
BC 180 POSITION 7,15:? "NUMB
ER OF JOYSTICKS (1/2)
?";
BN 190 GET #1,F2:F2-F2-49:IF
F2<>0 AND F2<>1 THEN
190
JP 200 ? CHR$(125):POSITION
13,0:? "CHAIN REACTIO
N"
NA 210 FOR Y=0 TO 4:FOR X=0
TO 5:GOSUB 770:NEXT X
:NEXT Y
AC 220 TU=-TU+1:S$=PS$(TU+1,
TU+1):B$=PB$(TU+1,TU+
1)
IN 230 IF NP=1 AND -TU+1 THE
N GOSUB 940:GOTO 260
LC 240 GOSUB 390
DB 250 IF L(Y,X)<>TU+1 AND L
(Y,X) THEN 240
ML 260 U(Y,X)=U(Y,X)+1:FS(TU
)=FS(TU)+1:IF L(Y,X)=
0 THEN L(Y,X)=TU+1
LI 270 GOSUB 870
CD 280 IF U(Y,X)=J(Y,X) THEN
300
GI 290 GOTO 220
PF 300 E=0:FG=0:FOR Y=0 TO 4
:FOR X=0 TO 5
JO 310 IF U(Y,X)>=J(Y,X) AND
E=0 THEN FG=1:OOSUB
480
EB 320 NEXT X:NEXT Y:IF E=1
THEN 350
OC 330 IF FG=1 THEN 300
GE 340 GOTO 220
J0 350 POSITION 15,23:PRINT
"GAME OVER";:FOR I=1
TO 1000:NEXT I
OC 360 POSITION 5,23:PRINT "
PRESS FIREBUTTON TO P
LAY AGAIN";
NK 370 IF STRIG(0) AND STRIG
(1) THEN 370
DJ 380 GOTO 50
JG 390 X=HX:Y=HY:GOSUB 820
BF 400 DX=0:DY=0:JY=STICK(TU
*F2)
PN 410 IF STRIG(TU*F2)=0 THE
N HX=X:HY=Y:GOSUB 770
:RETURN
FG 420 IF JY=14 THEN IF Y>0
THEN DY=-1
CL 430 IF JY=13 THEN IF Y<4
THEN DY=1
FD 440 IF JY=11 THEN IF X>0
THEN DX=-1
PP 450 IF JY=7 THEN IF X<5 T
HEN DX=1
NC 460 IF DX=0 AND DY=0 THEN
400
PD 470 GOSUB 770:X=X+DX:Y=Y+
DY:GOSUB 820:GOTO 400
FC 480 V=15:DV=INT(15/(U(Y,X
)*2)):TS$=S$:XX=X*4+8
:YY=Y*4+2:FOR I=1 TO
U(Y,X):BL$(1)=S$:BL$(
2)=S$:S$=" "
BB 490 GOSUB 890:80SUB 820:G
OSUB 1210:BL$=" ":S$
=TS$:GOSUB 890
NG 500 GOSUB 820:GOSUB 1210:
NEXT I:GOSUB 770:FOR
I=0 TO 3:SOUND 1,0,0,
0:NEXT I
NH 510 U(Y,X)=U(Y,X)-J(Y,X):
GOSUB 870
CH 520 IF U(Y,X)=0 THEN L(Y,
X)=0
FG 530 TX=X:TY=Y
GA 540 IF TX>0 THEN X=TX-1:G
OSUB 600
GC 550 IF TX<5 THEN X=TX+1:G
OSUB 600
OA 560 X=TX:IF TY>0 THEN Y=T
Y-1:GOSUB 600
GG 570 IF TY<4 THEN Y=TY+1:G
OSUB 600
LO 580 IF FS(0)<1 OR FS(1)<1
THEN E=1
PL 590 Y=TY:RETURN
LN 600 IF L(Y,X)<>TU+1 THEN
FS(TU)=FS(TU)+U(Y,X):
FS(-TU+1)=FS(-TU+1)-U
(Y,X)
JP 610 L(Y,X)=TU+1:U(Y,X)=U(
Y,X)+1:GOSUB 870:RETU
RN
PD 620 LP=0:IF Y>0 THEN IF L
(Y-1,X)=2 THEN Y1=Y-1
:GOTO 670
KO 630 IF X>0 THEN IF L(Y,X-
1)=2 THEN X1=X-1:GOTO
670
KO 640 IF X<5 THEN IF L(Y,X+
1)=2 THEN X1=X+1:GOTO
670
LB 650 IF Y<4 THEN IF L(Y+1,
X)=2 THEN Y1=Y+1:GOTO
670
HM 660 RETURN
MB 670 LP=1:RETURN
HF 680 GOTO 680
CA 690 POKE 752,1:CHBAS=5734
4:CHSET=(PEEK(106)-8)
*256
CL 700 FOR I=0 TO 1024:POKE
CHSET+I,PEEK(CHBAS+I)
:NEXT I
NI 710 POKE 756,CHSET/256
EH 720 RESTORE 730:FOR I-CHS
ET+24 TO CHSET+55:REA
D A:POKE I,A:NEXT I:R
ETURN
KI 730 DATA 170,170,170,170,
170,170,170,170
FB 740 DATA 85,85,85,85,85,8
5,85,85
KN 750 DATA 3,12,40,170,138,
162,170,40
PH 760 DATA 3,12,20,85,69,81
,85,20
AC 770 XX=X*4+B:YY=Y*4+2:POS
ITION XX,YY:? "(F)
{2 M}{G}"
BE 780 FOR K=1 TO 2
IA 790 POSITION XX,YY+K:? "
(V)":POSITION XX+3,YY
+K:? "{B}":NEXT K
BC 800 POSITION XX,YY+3:? "
{G}{2 N}{F}":POKE 77,
0
HJ 810 RETURN
CA 820 XX=X*4+8:YY-Y*4+2:POS
ITION XX,YY:? S$;S$;S
$;S$
BA 830 FOR K=1 TO 2
MK 840 POSITION XX,YY+K:? S$
:POSITION XX+3,YY+K:?
S$:NEXT K
AE 850 POSITION XX,YY+3:? S$
;S$;S$;S$
HO 860 RETURN
OC 870 XX=X*4+8:YY-Y*4+2
NI 880 ON U(Y,X)+1 GOTO 890,
900,910,920,930,930
MC 890 POSITION XX+1,YY+1:?
BL$:POSITION XX+1,YY+
2:? BL$:RETURN
KI 900 GOSUB 890:POSITION XX
+1,YY+1:? B$:RETURN
KD 910 GOSUB 900:POSITION XX
+2,YY+2:? B$:RETURN
KE 920 GOSUB 910:POSITION XX
+2,YY+1:? B$:RETURN
KG 930 GOSUB 920:POSITION XX
+1,YY+2:? B$:RETURN
LC 940 XT=0:FOR Y=0 TO 4:FOR
X=0 TO 5:IF L(Y,X)=2
THEN 960
IB 950 XT-XT+1:TY(XT)=Y:TX(X
T)=X
AI 960 NEXT X:NEXT Y
OK 970 POSITION 15,23:? "THI
NKING...";
NK 980 FOR I=1 TO XT:RT(I)=0
:TR(I)=0:Y=TY(I):X=TX
(I):GOSUB 620
FB 990 IF FG=1 AND LP AND U(
Y,X)>0 THEN 1200
BF 1000 IF U(Y,X)+1<>J(Y,X)
THEN 1040
KC 1010 IF LP=1 AND U(Y1,X1)
+1=J(Y1,X1) THEN RT(
I)=6:GOTO 1150
HE 1020 IF LP=1 THEN RT(I)=2
:GOTO 1150
MD 1030 IF LP=0 THEN RT(I)-1
:GOTO 1150
HA 1040 IF J(Y,X)<>2 THEN 10
80
DJ 1050 IF LP=0 AND U(Y,X)=1
THEN RT(I)=1:GOTO 1
150
DM 1060 IF LP=0 AND U(Y,X)=0
THEN RT(I)=4:GOTO 1
150
DP 1070 IF LP=1 AND U(Y,X)=1
THEN RT(I)=4:GOTO 1
150
MH 1080 IF U(Yl,Xl)+1=J(Yl,X
1) THEN RT(I)=1:GOTO
1150
OB 1090 IF U(Y,X)+2<J(Y,X) T
HEN 1130
KA 1100 IF LP=1 AND U(YI,Xl)
+1<J(Y1,X1) THEN RT(
I)=5:GOTO 1150
HE 1110 IF LP=0 THEN RT(I)=3
:GOTO 1150
KN 1120 RT(I)=2:GOTO 1150
HF 1130 IF LP=0 THEN RT(I)=2
:GOTO 1150
HE 1140 RT(I)=1
NE 1150 NEXT I:ZT=0:AB=6
AH 1160 FOR I=1 TO XT:IF RT(
I)=AB THEN ZT=ZT+1:T
R(ZT)=I
DA 1170 NEXT I:IF ZT>0 THEN
1190
KG 1180 AB=AB-1:GOTO 1160
KB 1190 DH=INT(ZT*RND(0))+1:
HD=TR(DH):Y-TY(HD):X
=TX(HD)
CO 1200 POSITION 15,23:? "
{11 SPACES}";:FG=FG+1
:RETURN
HE 1210 V=V-DV
BO 1220 SOUND 0,200,4,V
CK 1230 SOUND 1,255,4,V
CJ 1240 SOUND 2,225,4,V
EG 1250 SOUND 3,150,8,V:RETU
RN
Program 6. IBM PC/PCjr Chain Reaction
Version by Tim Midkiff, Editorial Programmer
MARK TUTTLE/CHAIN REACTION
Program (IBM VERSION)
BM 10 KEY OFF:DEF SEG=0:DEFINT A
-Z:POKE 1047,PEEK(1047) OR
64:RANDOMIZE TIMER
NM 20 SCREEN 1,0:COLOR 1,0:WIDTH
40:CLS
MK 30 DIM U(4,5),L(4,5),J(4,5),B
X(4,5),BY(4,5),N(1,5),ER(2
56),RT(30),TR(30),TX(30),T
Y(30),BR(22),BG(22)
CJ 40 GOSUB 1170
GJ 50 FOR I=1 TO 3:FOR J=1 TO 4:
J(I,J)=4:NEXT:J(I,0)=3:J(I
,5)=3:NEXT
GG 60 RESTORE 70:FOR J=1 TO 4:J(
0,J)=3:J(4,J)=3:READ A,B:J
(A,B)=2:NEXT
KB 70 DATA 0,0,0,5,4,0,4,5
GI 80 RESTORE 100:FOR I=1 TO 4:F
OR J=1 TO I:READ BX(I,J),B
Y(I,J):NEXT J,I
CB 90 BX(4,5)=BX(4,4):BY(4,5)=BY
(4,4)
ED 100 DATA 13,9,6,9,20,9,13,5,4
,15,22,15,13,3,13,17,4,9,
22,9
HL 110 LOCATE 8,14:PRINT "CHAIN
REACTION"
AE 120 LOCATE 12,9:PRINT "Number
of players (1/2)?";
JJ 130 K$=INKEY$:IF K$<>"1" AND
K$<>"2" THEN 130
KN 140 NP=VAL(K$):IF NP=2 THEN 1
80
DC 150 LOCATE 16,10:PRINT "Compu
ter first (Y/N)?";
IP 160 K$=INKEY$:IF K$<>"Y" AND
K$<>"N" THEN 160
LM 170 TU=ABS(K$="Y")
EA 180 CLS:LOCATE 1,14:PRINT "CH
AIN REACTION";:GOSUB 670
HD 190 TU=-TU+1:CO=TU+1
BL 200 IF NP=1 AND TU=0 THEN GOS
UB 900:GOTO 230
JJ 210 GOSUB 360
FA 220 IF L(Y,X)<>TU+1 AND L(Y,X
) THEN 210
CN 230 U(Y,X)=U(Y,X)+1:FS(TU)=FS
(TU)+1:IF L(Y,X)=0 THEN L
(Y,X)=CO
JG 240 GOSUB 820
JJ 250 IF U(Y,X)=J(Y,X) THEN 270
HM 260 GOTO 190
PG 270 E=0:FG=0:FOR P=0 TO 4:FOR
Q=0 TO 5:Y=P:X=Q
KL 280 IF U(Y,X)>=J(Y,X) AND E=0
THEN FG=1:GOSUB 450
EF 290 NEXT Q,P:IF E=1 THEN 320
OI 300 IF FG=1 THEN 270
GD 310 GOTO 190
FC 320 LOCATE 24,16:PRINT "GAME
OVER";:FOR I=1 TO 5000:NE
XT
JP 330 LOCATE 24,6:PRINT "Press
space bar to play again."
HG 340 K$=INKEY$:IF K$<>" " THEN
340
GH 350 RUN
OI 360 X=HX(CO):Y=HY(CO):GOSUB 7
80:WHILE INKEY$<>"":WEND
OG 370 DX=0:DY=0:K$=RIGHT$(INKEY
$,1):IF K$="" THEN 370
ON 380 K=ASC(K$):IF K=32 THEN HX
(CO)=X:HY(CO)=Y:CO=0:GOSU
B 780:CO=TU+I:RETURN
JE 390 IF K=72 THEN IF Y>0 THEN
DY=-1
LJ 400 IF K=80 THEN IF Y<4 THEN
DY=1
HC 410 IF K=75 THEN IF X>0 THEN
DX=-1
ND 420 IF K=77 THEN IF X<5 THEN
DX=1
OK 430 IF DX=0 AND DY=0 THEN 370
KN 440 CO=0:GOSUB 780:X=X+DX:Y=Y
+DY:CO=TU+1:GOSUB 780:GOT
O 370
HM 450 R=0:YY=32*Y+15:XX=36*X+50
:FOR I=1 TO 4
CP 460 PUT(XX+2,YY+2),ER,PSET
MN 470 FOR J=1 TO 4:N(1,J)=INT(R
ND(1)*3)-1:NEXT:R=-R+1:K=
U(Y,X)+1:IF K=6 THEN K=5
IN 480 IF CO=1 THEN ON K GOSUB 7
30,740,750,760,770,770
FE 490 IF CO=2 THEN ON K GOSUB 8
50,860,870,880,890,890
CB 500 FOR J=1 TO 25:SOUND 37,1:
NEXT:SOUND 37,0:NEXT
GM 510 TX=X:TY=Y:J1=0:K1=K-1:Yl=
32*Y+15+BY(1,1):X1=36*X+5
0+BX(1,1)
LH 520 IF TX>0 THEN X=TX-1:DX=-1
:DY=0:GOSUB 1270:GOSUB 59
0
DD 530 IF TX<5 THEN X=TX+1:DX=1:
DY=0:GOSUB 1270:GOSUB 590
II 540 X=TX:IF TY>0 THEN Y=TY-1:
DY=-1:DX=0:GOSUB 1270:GOS
UB 590
FH 550 IF TY<4 THEN Y=TY+1: DY=1:
DX=0:GOSUB 1270:GOSUB 590
KJ 560 IF FS(0)<l OR FS(1)<l THE
N E=1
AB 570 Y=TY:U(Y,X)=U(Y,X)-J(Y,X)
:GOSUB 820:IF U(Y,X)=0 TH
EN L(Y,X)=0
NP 580 RETURN
GN 590 IF L(Y,X)<>TU+1 THEN FS(T
U)=FS(TU)+U(Y,X):FS(-TU+1
=FS(-TU+1)-U(Y,X)
DD 600 L(Y,X)=TU+1:U(Y,X)=U(Y,X)
+1:GOSUB 820:RETURN
ML 610 LP=0:IF Y>0 THEN IF L(Y-1
,X)=? THEN AY=Y-1:GOTO 66
0
HJ 620 IF X>0 THEN IF L(Y,X-1)=2
THEN AX=X-1:GOTO 660
BJ 630 IF X<5 THEN IF L(Y,X+1)=2
THEN AX=X+1:GOTO 660
KF 640 IF Y<4 THEN IF L(Y+1,X)=2
THEN AY=Y+1:GOTO 660
NK 650 RETURN
MF 660 LP=1:REFURN
CL 670 FOR Y=0 TO 4:YY=32*Y+16:F
OR X=0 TO 5:XX=36*X+51
LJ 680 DRAW "BM=XX;,=YY;R34D30L3
4U30"
PN 690 NEXT X,Y:GET(XX+1,YY+1)-(
XX+33,YY+29),ER
MB 700 RETURN
FF 710 PUT(XX+2,YY+2),ER,PSET:K=
U(Y,X)+1:IF K=6 THEN K=5
PO 720 ON K GOTO 730,740,750,760
,770,770
MH 730 RETURN
PH 740 PUT(XX+BX(1,K-1),YY+BY(1,
K-1)),BG:RETURN
KL 750 FOR J=1 TO K-1:PUT(XX+BX(
2,J)+N(R,J),YY+BY(2,J)+N(
R,J)),BG:NEXT:RETURN
PL 760 FOR J=1 TO K-1:PUT(XX+BX(
3,J)+N(R,J),YY+BY(3,J)+N(
R,J)),BG:NEXT:RETURN
EL 770 FOR J=1 TO K-1:PUT(XX+BX(
4,J)+N(R,J),YY+BY(4,J)+N(
R,J)),BG:NEXT:RETURN
ON 780 YY=32*Y+15:XX=36*X+50
IF 790 DRAW "C=CO;BM=XX;,=YY;R36
D32L36U32"
CE 800 DRAW "C=CO;BM+2,+2R32D2BL
32U28"
ME 810 RETURN
DN 820 YY=32*Y+15:XX=36*X+50:R=0
:IF CO=1 THEN 710
GK 830 PUT(XX+2,YY+2),ER,PSET:K=
U(Y,X)+1:IF K=6 THEN K=5
MB 840 ON K GOTO 850,860,870,880
,890,890
NM 850 RETURN
JD 860 PUT(XX+BX(l,K-1),YY+BY(1,
K-1)),BR:RETURN
FK 870 FOR J=1 TO K-1:PUT(XX+BX(
2,J)+N(R,J),YY+BY(2,J)+N(
R,J)),BR:NEXT:RETURN
KK 880 FOR J=1 TO K-1:PUT(XX+BX
3,J)+N(R,J),YY+BY(3,J)+N(
R,J)),BR:NEXT:RETURN
PK 890 FOR J=1 TO H:-1:PUT(XX+BX(
4,J)+N(R,J),YY+BY(4,J)+N(
R,J)),BR:NEXT:RETURN
AG 900 XT=0:FOR Y=0 TO 4:FOR X=0
TO 5:IF L(Y,X)=2 THEN 92
0
OF 910 XT=XT+1:TY(XT)=Y:TX(XT)=X
IJ 920 NEXT X, Y
IB 930 LOCATE 23,15:PRINT "Think
ing...";
FO 940 FOR I=1 TO XT:RT(I)=0:TR(
I)=0:Y=TY(I):X=TX(I):GOSU
B 610
FK 950 IF FG=1 AND LP AND U(Y,X)
>0 THEN 1160
BM 960 IF U(Y,X)+1<>J(Y,X) THEN
1000
GC 970 IF LP=1 AND U(AY,AX)+1=J(
AY,AX) THEN RT(I)=6:GOTO
1110
MM 980 IF LP=1 THEN RT(I)=2:GOTO
1110
KL 990 IF LP=0 THEN RT(I)=1:GOTO
1110
JD 1000 IF J(Y,X)<>2 THEN 1040
NI 1010 IF LP=0 AND U(Y,X)=1 THE
N RT(I)=1:GOTO 1110
CE 1020 IF LP=0 AND U(Y,X)=0 THE
N RT(I)=4:GOTO 1110
FM 1030 IF LP=1 AND U(Y,X)=1 THE
N RT(I)=4:GOTO 1110
OF 1040 IF U(AY,AX)+1=J(AY,AX) T
HEN RT(I)=1:GOTO 1110
MD 1050 IF U(Y,X)+2<J(Y,X) THEN
1090
NN 1060 IF LP=1 AND U(AY,AX)+1<J
(AY,AX) THEN RT(I)=5:GOT
O 1110
NO 1070 IF LP=0 THEN RT(I)=3:GOT
O 1110
AD 1080 RT(I)=2:GOTO 1110
MA 1090 IF LP=0 THEN RT(I)=2:GOT
O 1110
BB 1100 RT(I)=1
OA 1110 NEXT:ZT=0:AB=6
OL 1120 FOR I=1 TO XT:IF RT(I)=A
B THEN ZT=ZT+1:TR(ZT)=I
GK 1130 NEXT:IF ZT>0 THEN 1150
NI 1140 AB=AB-1:GOTO 1120
BI 1150 DH=INT(ZT*RND(1))+1:HD=T
R(DH):Y=TY(HD):X=TX(HD)
EE 1160 LOCATE 23,15:PRINT "
";:FG=FG+1:RETURN
EH 1170 RESTORE 1210
HB 1180 READ BR(0),BR(1):FOR I=2
TO 22:READ A$:BR(I)=VAL
("&H"+A$):NEXT
DA 1190 READ BG(0),BG(1):FOR I=2
TO 22:READ A$:BG(I)=VAL
("&H"+A$):NEXT
IP 1200 RETURN
IH 1210 DATA 22,13,F00,0,30,3000
,200,AA
DJ 1220 DATA AA02,A00,80AA,2028,
AAA0,AB22,8AAA,AAA8
OE 1230 DATA AB22,2028,AA0,80AA,
AA02,0,0
CN 1240 DATA 22,13,F00,0,30,3000
,100,55
KF 1250 DATA 5501,500,4055,1014,
5550,5411,4555,5554
LH 1260 DATA 5411,1014,550,4055,
5501,0,0
BC 1270 J1=JI+1:XX=X1-BX(1,1):YY
=Yl-BY(1,1):S=1087:IF CO
=1 THEN 1360
PF 1280 PUT(XX+BX(K1,Jl)+N(R,J1)
,YY+BY(K1,J1)+N(R,J1)),B
R
GM 1290 IF DY<>0 THEN 1330
AB 1300 X2=X1+35*DX:DX=DX*4:PUT(
X1,Y1),BR
AE 1310 FOR I=X1 TO X2 STEP DX:S
=S-40:SOUND S,1:PUT(I,Y1
),BR:PUT(I+DX,Y1),BR:NEX
T
GL 1320 PUT(XX+3,YY+3),ER:RETURN
CO 1330 Y2=Y1+31*DY:DY=DY*4:PUT(
X1,Y1),BR
DD 1340 FOR I=Y1 TO Y2 STEP DY:S
=S-40:SOUND S,1:PUT(X1,I
),BR:PUT(X1,I+DY),BR:NEX
T
GE 1350 PUT(XX+3,YY+3),ER:RETURN
KP 1360 PUT(XX+BX(K1,J1)+N(R,J1)
,YY+BY(K1,J1)+N(R,J1)),B
G
EB 1370 IF DY<>0 THEN 1410
HH 1380 X2=X1+35*DX:DX=DX*4:PUT(
X1,Y1),BG
IG 1390 FOR I=X1 TO X2 STEP DX:S
=S-40:SOUND S,1:PUT(I,Y1
),BG:PUT(I+DX,Y1),BG:NEX
T
FH 1400 PUT(XX+3,YY+3),ER:RETURN
II 1410 Y2=Y1+31*DY:DY=DY*4:PUT(
X1,Y1),BG
KJ 1420 FOR I=Y1 TO Y2 STEP DY:S
=S-40:SOUND S,1:PUT(X1,I
),BG:PUT(X1,I+DY),BG:NEX
T
GA 1430 PUT(XX+3,YY+3),ER:RETURN