1616 bx = 3
1717 by = 13
1818
19+ b=49154
20+ {:readasm}
21+ read c
22+ if c=-1 then goto {:doneasm}
23+ poke b,c
24+ b=b+1
25+ goto {:readasm}
26+ {:doneasm}
1927
20-
28+ ' This little bit here patches the nopalicious routine in the machine code portion
29+ ' with the value poked into 50003 if 50000,50001 and 50002 are poked to 20, 16 and 128 respectively.
30+ if peek(50000)<>20 then goto {:restart}
31+ if peek(50001)<>64 then goto {:restart}
32+ if peek(50002)<>128 then goto {:restart}
33+ poke 49389,peek(50003)
34+
2135{:restart}
2236 GOSUB {:printtop}
2337 '1234567890123456789012345678901234567890
3650 POKE 56334,PEEK(56334) AND 254
3751
3852 gosub {:handshake}
53+
3954 if RP=0 then goto {:joytest}
4055
4156 cm=1:gosub {:communicate}
256271{:controlloop}
257272 gosub {:readpad}
258273 if pd%(4)=0 then cp=0:goto {:controlloop}
259- if pd%(4)<>0 and cp>0 and cp<20 then cp=cp+1:goto {:controlloop}
274+ if pd%(4)<>0 and cp>0 and cp<14 then cp=cp+1:goto {:controlloop}
260275 if pd%(4)<>0 and cp<1 then cp=1
261- if cp=20 then cp=cp-1
276+ ' if cp=20 then cp=cp-1
262277 if pd%(2)=4 and cx>bx and (cx<=30 or cx=37) then cx=cx-3:dm=0:gosub {:drawcurse}:goto {:editloop}
263278 if pd%(2)=4 and cx=34 then cx=cx-4:dm=0:gosub {:drawcurse}:goto {:editloop}
264279 if pd%(2)=8 and (cx<30 or cx=34) then cx=cx+3:dm=0:gosub {:drawcurse}:goto {:editloop}
@@ -452,48 +467,17 @@ return
452467
453468
454469{:communicate}
455- td=0
456- poke op,cm
457- {:commloop}
458- RP=PEEK(IP)AND 31
459- td=td+1
460- if td=255 then goto {:commtimeout}
461- IF (RP AND 16)<>0 THEN GOTO {:commloop}
462- rp=(not rp) and 15
463- poke op,0
464- {:ackloop}
465- ac=PEEK(IP)
466- IF (ac AND 16)=0 THEN GOTO {:ackloop}
470+
471+ poke 49152,cm
472+ sys 49154
473+ RP=PEEK(49153)
474+ if (RP and 128)=128 then goto {:commtimeout}
467475return
468476
469477{:handshake}
470- POKE 56322,239:poke 56323,0
471- POKE OP,240
472- {:handshakeloop}
473- A=PEEK(IP) and 31
474- RP=PEEK(OP) and 16
475- IF A<>0 and RP=16 THEN GOTO {:handshakeloop}
476- if RP=0 then return
477- POKE 53280,1
478- POKE 56322,255
479- POKE OP,1
480- A=32000
481- {:hs1}
482- if a=0 goto {:commtimeout}
483- a=a-1
484- b=PEEK(IP) and 31
485- IF b=0 goto {:hs1}
486- POKE 53280,2
487- poke op,4
488- A=10000
489- {:hs2}
490- if a=0 goto {:commtimeout}
491- a=a-1
492- b=PEEK(IP) and 31
493- IF b<>0 goto {:hs2}
494- POKE 53280,0
495-
496- poke op,0
478+ sys 49157
479+ RP=PEEK(49153)
480+ if (RP and 128)=128 then goto {:commtimeout}
497481
498482return
499483
@@ -502,7 +486,6 @@ return
502486{:commtimeout}
503487
504488 print"{clear}{white}{down:10} communications timeout with interface!{down:5}{gray3}"
505-
506489 goto {:freeze}
507490
508491{:freeze}
@@ -512,4 +495,43 @@ return
512495 print " restart is possible with the"
513496 print " 'run' command"
514497{:freezed}
515- goto {:freezed}
498+ goto {:freezed}
499+
500+ ' Handshake and communications machine code 'comms_unit.asm'
501+ ' assembled and converted to DATA statements.
502+
503+ DATA 076,139,192,120,169,239,141
504+ DATA 002,220,169,000,141,003,220
505+ DATA 169,240,141,000,220,173,000
506+ DATA 220,041,016,208,005,141,001
507+ DATA 192,088,096,173,001,220,041
508+ DATA 031,208,237,032,234,192,169
509+ DATA 255,141,002,220,169,001,141
510+ DATA 000,220,162,255,160,255,173
511+ DATA 001,220,041,031,208,019,202
512+ DATA 208,246,202,136,208,242,169
513+ DATA 128,141,001,192,088,169,001
514+ DATA 141,032,208,096,032,234,192
515+ DATA 169,004,141,000,220,162,255
516+ DATA 160,255,173,001,220,041,031
517+ DATA 240,019,202,208,246,202,136
518+ DATA 208,242,169,128,141,001,192
519+ DATA 088,169,002,141,032,208,096
520+ DATA 169,000,141,032,208,032,234
521+ DATA 192,141,000,220,169,001,141
522+ DATA 001,192,088,096,120,032,234
523+ DATA 192,173,000,192,141,000,220
524+ DATA 162,255,160,255,173,001,220
525+ DATA 141,001,192,041,016,240,019
526+ DATA 202,208,243,202,136,208,239
527+ DATA 169,128,141,001,192,088,169
528+ DATA 003,141,032,208,096,173,001
529+ DATA 192,073,255,041,015,141,001
530+ DATA 192,162,255,202,208,253,169
531+ DATA 000,141,000,220,162,255,160
532+ DATA 255,173,001,220,041,016,208
533+ DATA 019,202,208,246,202,136,208
534+ DATA 242,169,128,141,001,192,169
535+ DATA 004,141,032,208,088,096,088
536+ DATA 096,162,255,160,005,202,208
537+ DATA 253,202,136,208,249,096,-1
0 commit comments