40 DEFFNdisk(addr%,cmd%,drv%,trk%,sec%,num%,den%):LOCALfs%,n%
50 fs%=FNfs:IFfs%<>4:*FX143,18,4
60 REPEAT:n%=num%:IFsec%+n%>10:n%=10-sec%
70 REPEAT:X%?0=drv%+den%*24+8+2*(trk%DIV80):X%!1=addr%:X%?5=3-7*(cmd%>127)
80 X%?6=cmd%:X%?7=trk%MOD80:X%?8=sec%:X%!9=n%OR&1E20:A%=127:CALL&FFF1
90 A%=X%?(7+X%?5):UNTILA%<>&10:addr%=addr%+n%*256:num%=num%-n%:sec%=(sec%+n%)MOD10:trk%=trk%+1
100 UNTILA%<>0ORnum%<1:IFfs%<>4:OSCLI"FX143,18,"+STR$fs%
110 =A%
130 DEFFNscsi(addr%,cmd%,drv%,sect%,num%):LOCALfs%
140 fs%=FNfs:IFfs%<>8:*FADFS
150 X%?0=0:X%!1=addr%:X%?5=cmd%:X%?6=drv%*32+((sect%AND&1F0000)DIV65536)
160 X%?7=((sect%AND&FF00)DIV256):X%?8=sect%:X%!9=num%:X%!11=0
170 A%=&72:CALL&FFF1:A%=?X%:IFfs%<>8:OSCLI"FX143,18,"+STR$fs%
180 =A%
200 DEFFNlvfs(addr%,cmd%,drv%,sect%,num%):LOCALfs%
210 fs%=FNfs:IFfs%<>10:*FX143,18,10
220 X%?0=0:X%!1=addr%:X%?5=cmd%:X%?6=drv%*32+((sect%AND&1F0000)DIV65536)
230 X%?7=((sect%AND&FF00)DIV256):X%?8=sect%:X%!9=num%:X%!11=0
240 A%=&62:CALL&FFF1:A%=?X%:IFfs%<>10:OSCLI"FX143,18,"+STR$fs%
250 =A%
270 DEFFNfs:LOCALA%,E%,Y%:=(USR&FFDA)AND&FF
290 DEFFNscsi_err(A%,S%)
300 IFA%:PRINT"Disk error ";FNh0(A%,2);" (";MID$("fddhdd",(A%AND64)/64+1,3);") at ";FNh0(S%,6)
310 =A%
330 DEFFNdisk_err(A%,S%)
340 IFA%:PRINT"Disk error ";FNh0(A%,2);" at ";FNh0(S%,4)
350 =A%
110 DEFFNbyte(A%,X%,Y%)=((USR&FFF4)AND&FF00)DIV256
120 DEFFNfx(A%,X%):LOCALY%:Y%=X%DIV256:=((USR&FFF4)AND&FFFF00)DIV256
100 DEFFNh0(A%,N%):=RIGHT$("0000000"+STR$~A%,N%)
130 DEFFNh(A%,N%):=RIGHT$(" "+STR$~A%,N%)
160 DEFFNd0(A%,N%):=RIGHT$("00000000"+STR$A%,N%)
190 DEFFNd(A%,N%):=RIGHT$(" "+STR$A%,N%)
220 DEFFNo0(A%,N%):LOCALA$,B%,L%:IFA%<0:B%=2:A%=A%AND&7FFFFFFF
230 REPEATA$=STR$(A%AND7)+A$:A%=A%DIV8:L%=L%+3:UNTILL%>27:=RIGHT$(STR$(A%+B%)+A$,N%)
260 DEFFNo(A%,N%):LOCALA$:IFA%<0:=FNo0(A%,N%)
270 REPEATA$=STR$(A%AND7)+A$:A%=A%DIV8:UNTILA%=0:=RIGHT$(STRING$(N%," ")+A$,N%)
300 DEFFNb0(A%,N%):LOCALA$,B$,L%:B$="0":IFA%<0:B$="1":A%=A%AND&7FFFFFFF
310 REPEATA$=STR$(A%AND1)+A$:A%=A%DIV2:L%=L%+1:UNTILL%>30:=RIGHT$(B$+A$,N%)
340 DEFFNb(A%,N%):LOCALA$:IFA%<0:=FNb0(A%,N%)
350 REPEATA$=STR$(A%AND1)+A$:A%=A%DIV2:UNTILA%=0:=RIGHT$(STRING$(N%," ")+A$,N%)
380 DEFFNdrv(A%):=CHR$(48+A%-7*(A%>9))
410 DEFFNDrv(A$):=ASCA$-48+7*(A$>"9")AND31
80 DEFFNs(A$):IFLEFT$(A$,1)=" ":REPEATA$=MID$(A$,2):UNTILLEFT$(A$,1)<>" "
90 IFRIGHT$(A$,1)=" ":REPEATA$=LEFT$(A$,LENA$-1):UNTILRIGHT$(A$,1)<>" "
100 =A$
140 DEFFNuc(A$):LOCALB$:IFA$="":=""
150 REPEATB$=B$+CHR$(ASCA$AND((A$<"@")OR&DF)):A$=MID$(A$,2):UNTILA$="":=B$
190 DEFFNlc(A$):LOCALB$:IFA$="":=""
200 REPEATB$=B$+CHR$(ASCA$OR((A$<"_")AND&20)):A$=MID$(A$,2):UNTILA$="":=B$
170 DEFFNfile(A$,A%):IFA%-8:IFPAGE<&FFFFF:$name%=A$:?X%=name%:X%?1=name%DIV256:=(USR&FFDD)AND&FF
180 A$=FNf_name(A$):IFA%=255ORA%=5:X%!14=OPENIN(A$):IFX%!14:X%!10=EXT#X%!14:CLOSE#X%!14:X%!14=&33
190 IFA%=255:IFX%?6=0:OSCLI"LOAD """+A$+""" "+STR$~X%!2:=1
200 IFA%=5:IFX%!14:=1ELSEIFA%=5:=0
210 IFA%=0:OSCLI"SAVE """+A$+""" "+STR$~X%!10+" "+STR$~X%!14:X%!10=X%!14-X%!10:=1
220 IFA%=7:OSCLI"SAVE """+A$+""" "+STR$~PAGE+"+"+STR$~X%!10:X%!10=X%!14-X%!10:=1
230 IFA%-8:=0
240 IF(os%AND-24):A$="mkdir "+A$ELSEA$="cdir "+A$
250 IFHIMEM>&FFFF:LOCALERROR:ONERRORLOCAL:=0
260 OSCLIA$:=2
300 DEFPROCf_gbpb(A%,chn%,addr%,num%,ptr%)
310 ?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:IFPAGE<&FFFFF:CALL&FFD1:ENDPROC
320 IFA%=1ORA%=3:PTR#?X%=X%!9
330 REPEAT:IFA%=1ORA%=2:BPUT#?X%,?X%!1ELSEIFA%=3ORA%=4:?X%!1=BGET#?X%
340 X%!1=X%!1+1:X%!5=X%!5-1:UNTIL(EOF#?X%ANDA%>2)ORX%!5<1:ENDPROC
360 DEFPROCgbpb(A%,chn%,addr%,num%,ptr%)
370 ?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:IFPAGE<&FFFFF:CALL&FFD1:ENDPROC
380 IFA%=1ORA%=3:PTR#?X%=X%!9
390 REPEAT:IFA%=1ORA%=2:BPUT#?X%,?X%!1ELSEIFA%=3ORA%=4:?X%!1=BGET#?X%
400 X%!1=X%!1+1:X%!5=X%!5-1:UNTIL(EOF#?X%ANDA%>2)ORX%!5<1:ENDPROC
440 DEFFNgbpb(A%):IFPAGE>&FFFFF:=""
450 X%!1=name%:CALL&FFD1:A%=name%+((1+?name%)AND((A%AND-2)=6)):A%?(1+?A%)=13:=$(A%+1)
490 DEFFNf_scan(ptr%):IFPAGE>&FFFFF:=""
500 X%!1=name%:X%!5=1:X%!9=ptr%:A%=8:CALL&FFD1:IFX%!5=1:=""
510 A%=name%+1:A%!(A%?-1)=&D20:A%?(INSTR($A%," ")-1)=13:=$A%
530 DEFFNgbpb8(ptr%):IFPAGE>&FFFFF:=""
540 X%!1=name%:X%!5=1:X%!9=ptr%:A%=8:CALL&FFD1:IFX%!5=1:=""
550 A%=name%+1:A%!(A%?-1)=&D20:A%?(INSTR($A%," ")-1)=13:=$A%
590 DEFFNf_args(A%,Y%,ptr%):LOCALX%,E%:IF?(TOP-3)=0:E%=Y%:Y%=0
600 IFFALSETHEN
610 LOCAL!&70:X%=&70:!X%=ptr%:CALL&FFDA:=!X%
620 ELSE
630 SYS"OS_Args",A%,Y%,ptr%TO,,ptr%
640 SAVE:=ptr%
660 DEFFNargs(A%,Y%,ptr%):LOCALX%,E%:IF?(TOP-3)=0:E%=Y%:Y%=0
670 IFFALSETHEN
680 LOCAL!&70:X%=&70:!X%=ptr%:CALL&FFDA:=!X%
690 ELSE
700 SYS"OS_Args",A%,Y%,ptr%TO,,ptr%
710 SAVE:=ptr%
750 DEFFNf_argsA(A%):IFFALSETHEN
760 LOCALX%,Y%,E%,!&70:X%=&70:=(USR&FFDA)AND&FF
770 ELSE
780 SYS"OS_Args",A%TOA%
790 SAVE:=A%
810 DEFFNargsA(A%):IFFALSETHEN
820 LOCALX%,Y%,E%,!&70:X%=&70:=(USR&FFDA)AND&FF
830 ELSE
840 SYS"OS_Args",A%TOA%
850 SAVE:=A%
890 DEFFNfs:IF(os%AND-32)=0:LOCALA%,Y%,E%:=(USR&FFDA)AND&FF
900 =29
940 DEFPROCf_delete(A$):IF(os%AND-24):A$="del "+A$ELSEA$="delete "+A$
950 OSCLIA$:ENDPROC
990 DEFPROCf_dir(A$):IF(os%AND-24):A$="cd "+A$ELSEA$="dir "+A$
1000 OSCLIA$:ENDPROC
1040 DEFPROCf_cdir(A$)
1050 IF(os%AND-24):A$="mkdir "+A$ELSEA$="cdir "+A$
1060 IFFALSETHEN
1070 OSCLIA$:ENDPROC
1080 ENDIF
1090 LOCALERROR:ONERRORLOCAL:ENDPROC
1100 OSCLIA$
1110 ENDPROC
1150 DEFFNf_openin(A$)=OPENIN(FNf_name(A$))
1190 DEFFNf_openout(A$)=OPENOUT(FNf_name(A$))
1230 DEFFNf_openup(A$)=OPENUP(FNf_name(A$))
1250 DEFFNf_name(A$):IFos%AND-32:LOCALA%,B%:REPEATB%=A%:A%=INSTR(A$,"\",A%+1):UNTILA%=0:IFINSTR(A$,".",B%)=0:A$=A$+"."
1260 =A$
100 DEFFNNetFS_Op(A%,A$)=FNNetFS_OpN(A%,0,7,A$)
110 DEFFNNetFS_OpN(A%,T%,O%,A$):LOCALN%:!X%=0:X%?1=O%+1+LENA$:X%!3=A%:X%?7=T%:$(X%+O%)=A$
120 IFHIMEM>&FFFF:FORN%=4TOX%?1:X%?N%=X%?(N%+3):NEXT:SYS&60048,A%,X%+4,O%+LENA$,120TOA%:IFA%=0:X%?3=0:=0
130 IFHIMEM>&FFFF:IFA%>&FFFF:X%?3=?A%:SYS&2002B,A%+4TO$(X%+4):=X%?3
140 A%=&14:CALL&FFF1:=X%?3