10
20 :
30
40
50 DEFPROCio_reset:ENDPROC
60 :
70 DEFFNio_rd(A%):IF ports%=0:=mem%?A%
80 LOCAL C%:C%=FNio_type:IF C%<0:=mem%?A%
90 IF(A%AND&FFFC)<>port%(C%,0):=mem%?A%
100 A%=A%AND15:=EVAL("FNio_rd"+STR$port%(C%,1))
110 :
120 DEFPROCio_wr(A%,B%):IF ports%=0:mem%?A%=B%:ENDPROC
130 LOCAL C%:C%=FNio_type:IF C%<0:mem%?A%=B%:ENDPROC
140 IF(A%AND&FFFC)<>port%(C%,0):mem%?A%=B%:ENDPROC
150 A%=A%AND15:A%=EVAL("FNio_wr"+STR$port%(C%,1)):ENDPROC
160 :
170 DEFFNio_type:C%=A%AND&FFFC
180 IF port%(0,0):IF C%=port%(0,0):=0
190 IF port%(1,0):IF C%=port%(1,0):=1
200
210
220 =-1
230 :
240
250
260
270
280
290
300
310
320
330
340 DEFFNio_rd0
350 IFA%=1:=GET :
360 IFA%=0:IF INKEY-256=ASC"W":=2+((ADVAL(-1)<>&FF)AND1) :
370 IFA%=0:=2+((ADVAL(-1)<>&00)AND1)
380 =&7F
390 DEFFNio_wr0
400 IFA%=1:VDU B%:=0:
410 IFA%=0:=0 :
420 =0
430 :
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630 DEFFNio_rd1
640 IFA%=0:=GET :
650 IFA%=1:IF INKEY-256=ASC"W":=(ADVAL(-1)<>&FF)AND8 :
660 IFA%=1:=(ADVAL(-1)<>&00)AND8
670 =&7F
680 DEFFNio_wr1
690 IFA%=0:VDU B%:=0:
700 IFA%=1:=0 :
710 =0