8-Bit Software Online Conversion
User Port Utility - Listing
10DEFFNS="UPortCt"
20MODE7
30*K.0 0
40*K.1 1
50*K.2 2
60*K.3 3
70*K.4 4
80*K.5 5
90*K.6 6
100*K.7 7
110VDU23;8202;0;0;0;
120PRINT'" User Port Utility by C.J.R
ichardson."
130PRINT'" Press SPACE to toggle byte
to alter."
140PRINT" Press f0-f7 or 0 to 7 to tog
gle bit."
150P%=7:R%=P%:REM FIRST LINE
160Q%=8:REM LAST LINE
170ONERROR IFERR=17 OSCLI"FX151,98,0":
OSCLI"FX151,96,255" ELSE PRINTERL:REPORT
:END
180IORB%=?&FE60
190DDRB%=?&FE62
200PROCscreen
210REPEAT
220A%=(INKEY(0))-48
230*FX21
240IF A%=16 A%=0
250IF A%>=0 AND A%<8 PROCflip:A%=-1
260IFA%=-16 PRINTTAB(5,P%)" ";:P%=P%+
1:IFP%=Q%+1P%=R%
270IFA%=-16 PRINTTAB(5,P%)"
280PRINTTAB(6,R%+5);" Value in &FE60 (
IORB)=";STR$?&FE60;" "
290PRINTTAB(3,R%+6)" Pending for &FE60
(IORB)=";STR$IORB%;" "
300PRINTTAB(6,R%+7);" Value in &FE62 (
DDRB)=";STR$?&FE62;" "
310PROCpbits
320UNTILFALSE
330DEFPROCflip
340RESTORE
350FORL%=0TOA%
360READ B%
370NEXT
380IF P%=R% IORB%=IORB% EOR B%
390IF P%=R%+1DDRB%=DDRB% EOR B%
400OSCLI"FX 151,98,"+STR$DDRB%
410OSCLI"FX 151,96,"+STR$IORB%
420PROCscreen
430ENDPROC
440DATA1,2,4,8,16,32,64,128
450DEFPROCscreen
460PRINTTAB(0,R%-1);
470PRINT" BIT 7 6 5 4 3
2 1 0"
480PRINT"&FE60";
490IFP%=R% PRINT"
500PROCpbyte(IORB%,999," OFF"," ON ")
510PRINT"&FE62";
520IFP%=R%+1 PRINT"
;
530PROCpbyte(?&FE62,999," OUT"," IN ")
540ENDPROC
550DEFPROCpbits
560PRINTTAB(0,Q%+1);"INPUT ";
570PROCpbyte(255-?&FE62,255-?&FE60," I
N "," ")
580ENDPROC
590DEFPROCpbyte(T%,V%,A$,B$):REM BYTE
TO EXAMINE,VALUE IN,IF BIT 1, IF BIT 0
600L%=256
610REPEAT
620L%=L%/2
630IFT%>L%-1 T%=T%-L%:IF V%>L%-1 PRINT
A$; ELSE PRINTB$;
640IF V%>L%-1 V%=V%-L%
650UNTILL%=1
660PRINT
670ENDPROC