10 defint a-z:width 40,25:console ,,0,1:print chr$(12);
20 dim dx(3),dy(3),pc$(3,3),cg(5)
30 for i=0 to 3:read dx(i),dy(i)
40 for j=0 to 3:read d$:pc$(i,j)=chr$(val("&h"+d$)):next j,i
50 data 0,-1, 87,86,20,80
60 data 1, 0, 84,85,20,81
70 data 0, 1, 86,87,20,82
80 data -1, 0, 85,84,20,83
90 px=13:py=18:pd=3:dt=&ha5
100 'pcg
110 for i=0 to 5:read d$:cg(i)=val("&h"+d$):next
120 data 95,96,9c,9d,9e,9f
130 '
140 read d$:if d$="*" then 400
150 c=(val("&h"+d$)-&h80)*8:ch=c\256:cl=c mod 256
160 for i=0 to 7:read d$:out 0,val("&h"+d$):out 1,cl+i:out 2,ch or &h10:out 2,ch:next
170 goto 140
200 data 80, 00,42,c3,e7, e7,ff,7e,3c
210 data 81, 3c,7e,f8,e0, e0,f8,7e,3c
220 data 82, 3c,7e,ff,e7, e7,c3,42,00
230 data 83, 3c,7e,1f,07, 07,1f,7e,3c
240 data 84, 03,07,0f,0f, 0f,0f,07,03
250 data 85, c0,e0,f0,f0, f0,f0,e0,c0
260 data 86, 00,00,00,00, 3c,7e,ff,ff
270 data 87, ff,ff,7e,3c, 00,00,00,00
280 data 88, 3c,7e,ff,ff, ff,ff,7e,3c
290 data 95, 00,00,00,ff, ff,00,00,00
300 data 96, 18,18,18,18, 18,18,18,18
310 data 9c, 00,00,00,07, 0f,1c,18,18
320 data 9d, 00,00,00,e0, f0,38,18,18
330 data 9e, 18,18,1c,0f, 07,00,00,00
340 data 9f, 18,18,38,f0, e0,00,00,00
350 data a5, 00,00,00,18, 18,00,00,00
360 data *
400 'map
410 for y=0 to 24:read d$
420 for i=1 to 28:c$=mid$(d$,i,1)
430 if c$="." then color 6:print chr$(dt);:goto 460
440 if c$=" " then print" ";:goto 460
450 color 1:print chr$(cg(val(c$)));
460 next
470 if y<24 then print
480 next
500 data"1............11............1"
510 data"1.2003.20003.11.20003.2003.1"
520 data"1.1 1.1 1.11.1 1.1 1.1"
530 data"1.4005.40005.45.40005.4005.1"
540 data"1..........................1"
550 data"1.2003.23.20000003.23.2003.1"
560 data"1.4005.11.40032005.11.4005.1"
570 data"1......11....11....11......1"
580 data"400003.14003.11.20051.200005"
590 data" 1.12005.45.40031.1 "
600 data"000005.45 45.400000"
610 data" . 10000001 . "
620 data"000003.23 23.200000"
630 data" 1.11 20000003 11.1 "
640 data"200005.45 40032005 45.400003"
650 data"1............11............1"
660 data"1.2003.20003.11.20003.2003.1"
670 data"1.4031.40005.45.40005.1205.1"
680 data"1...11....... ........11...1"
690 data"403.11.23.20000003.23.11.205"
700 data"205.45.11.40032005.11.45.403"
710 data"1......11....11....11......1"
720 data"1.2000054003.11.2005400003.1"
730 data"1.4000000005.45.4000000005.1"
740 data"1..........................1"
750 locate px,py:color 6:print chr$(&h88);
760 beep1:for w=1 to 1000:next:beep 0
1000 'main loop
1010 d=-1:k=inp(0) xor inp(1)
1020 if k=&h01 then if py>0 then d=0
1030 if k=&h40 then d=1
1040 if k=&h04 then if py<24 then d=2
1050 if k=&h10 then d=3
1060 if d=-1 then 1110
1070 c=peek(&hf302+(py+dy(d))*120+(px+dx(d))*2)
1080 if c=&h20 or c=dt then pd=d
1100 '
1110 qx=px+dx(pd):qy=py+dy(pd)
1120 if qx<0 then qx=27
1130 if qx>27 then qx=0
1140 c=peek(&hf302+qy*120+qx*2)
1150 if c<>&h20 and c<>dt then gosub 2020:goto 1010
1160 if c=dt then beep 1:beep 0
1170 gosub 1510
1180 px=qx:py=qy:goto 1010
1500 'move
1510 locate px,py:print pc$(pd,0);
1520 locate qx,qy:print pc$(pd,1);
1530 gosub 2010
1540 locate px,py:print pc$(pd,2);
1550 locate qx,qy:print pc$(pd,3);
1560 gosub 2010
1570 return
2000 'wait
2010 for w=1 to 100:next:return
2020 for w=1 to 200:next:return