Global X(),Y(),DTA(),CTR(),PRORET,PA(),WIZ(),PR(),CCT(),MNC,TERM,COMPT
Proc FILARY
Do
Do
Proc TITLE
If TERM=1 Then Exit
Loop
For T=70 To 187
Make Icon Mask T
Next T
Proc HSET
CTR(0)=0
CTR(1)=16
Proc SSPEL
For T=0 To 1
X(T)=Peek(Start(5)+20000+(CTR(T)*20)+2)-4
Y(T)=Peek(Start(5)+20000+(CTR(T)*20)+3)-4
PA(T)=0
Proc PANEL[T]
Proc SCR[T,0,0]
Proc PUD[T,0]
Proc PUD[T,1]
Next T
TERM=0
If COMPT=1 Then WIZ(1,0)=999 : For T=19 To 23 : WIZ(1,T)=99 : Next T
Do
If Key State(25)=-1 Then Clear Key : Amal Freeze : Wait Key : Amal On
Proc MVE
Proc BUTT
Proc CTRL
Proc NASTM
Screen Swap : Wait Vbl
Screen Copy Physic(0) To Logic(0)
If TERM=1 Then Exit
Loop
For X=0 To 1
For Y=0 To 27
WIZ(X,Y)=0
Next Y
Next X
Load ":l1map.ABK"
Loop
Procedure SCR[N,DX,DY]
Add X(N),DX,0 To 99
Add Y(N),DY,0 To 99
XF=N*176
X1=XF : X2=XF+144
Y1=0 : Y2=144
If DX=1 Then X1=X1+16
If DX=-1 Then X2=X2-16
If DY=1 Then Y1=Y1+16
If DY=-1 Then Y2=Y2-16
Screen Copy 0,X1,Y1,X2,Y2 To 0,X1-(16*DX),Y1-(16*DY)
If DX=1 Then X1=8 : Y1=0 : X2=8 : Y2=8 : Gosub RED
If DX=-1 Then X1=0 : Y1=0 : X2=0 : Y2=8 : Gosub RED
If DY=1 Then X1=0 : Y1=8 : X2=8 : Y2=8 : Gosub RED
If DY=-1 Then X1=0 : Y1=0 : X2=8 : Y2=0 : Gosub RED
If DY=0 and DX=0 Then X1=0 : Y1=0 : X2=8 : Y2=8 : Gosub RED
Pop Proc
RED:
Ink 0
Bar XF+(X1*16),Y1*16 To XF+(X2*16)+15,Y2*16+15
For X=X1 To X2
For Y=Y1 To Y2
XT=X(N)+X
YT=Y(N)+Y
If XT>99 Then XT=XT-100
If YT>99 Then YT=YT-100
P=Peek(Start(5)+XT+(YT*100))
If P>0 Then Paste Icon XF+(X*16),Y*16,P
O=Peek(Start(5)+XT+(YT*100)+10000)
If O>0 and O<100 Then Paste Icon X*16+XF,Y*16,O+109
If O=>100 Then Paste Icon X*16+XF,Y*16,Peek(Start(5)+20000+((O-100)*20)+1) : If(O=100 or O=116) Then If WIZ((O-100)/16,1)>0 Then Paste Icon X*16+XF,Y*16,WIZ((O-100)/16,1)+178
If P=66 Then Poke Start(5)+X1+(Y1*100),19 : Proc RED[X1,Y1]
If P=64 Then Poke Start(5)+X1+(Y1*100),17 : Proc RED[X1,Y1]
If P=68 Then Poke Start(5)+X1+(Y1*100),18 : Proc RED[X1,Y1]
If P=67 or P=65 or P=69 Then O=Peek(Start(5)+20000+(T*20)+6) : If O=1 Then Poke Start(5)+X1+(Y1*100),P-1 : Proc RED[X1,Y1] : Poke Start(5)+20000+(T*20)+6,0 : Proc PANEL[T/16]