10
20
30 :
40 disk$="2.11BSD_rq.dsk"
50 disk$="bsd2-11.dsk"
60 :
70 wr%=2:rd%=4:blsz%=512
80 DIM ctrl% 31,mem% blsz%-1,chk% 7:X%=ctrl%:Y%=X%DIV256
90 ON ERROR PRINT:REPORT:PROCCloseAll:PRINT:END
100 INPUT "File to import: "in$
110 in%=OPENIN(in$):IF in%=0:in%=OPENIN(in$+".")
120 IF in%=0:PRINT"File '"in$"' not found":END
130 up%=OPENUP(disk$):IF up%=0:PRINT"Disk image '"disk$"' not found":PROCCloseAll:END
140 :
150 $chk%="FILE"
160 ptr%=0:ext%=EXT#up%
170 done%=0:size%=(EXT#in%+blsz%-1)AND-blsz%
180 REPEAT
190 PROCgbpb(rd%-1,up%,mem%,blsz%,ptr%)
200 IF !mem%=!chk%:PROCsector
210 ptr%=ptr%+blsz%
220 UNTIL done%>=size% OR ptr%>=ext%
230 PRINT
240 PROCCloseAll
250 PRINT TAB(0,25);"Press a key";:IFGET
260 QUIT
270 :
280 DEFPROCsector
290 fail%=mem%?4<>32:FOR A%=8 TO blsz%-1:IF mem%?A%<>32:fail%=TRUE
300 NEXT A%:IF fail%:ENDPROC
310 FOR A%=5 TO 7:IF mem%?A%>95:mem%?A%=mem%?A%AND&DF
320 NEXT:mem%?8=13:sec%=EVAL("&"+$(mem%+5))
330 PRINTTAB(40*(sec% DIV 24),1+(sec% MOD 24));
340 PRINT"Offset: &";$(mem%+5);
350 IF sec%*blsz%>size%:PRINT:ENDPROC
360 PROCgbpb(rd%-1,in%,mem%,blsz%,sec%*blsz%)
370 PROCgbpb(wr%-1,up%,mem%,blsz%,ptr%)
390 done%=done%+blsz%
400 PRINT" ";done%;" of ";size%
410 ENDPROC
420 :
430 :
440 DEFPROCCloseAll
450 up%=up%:IFup%:A%=up%:up%=0:CLOSE#A%
460 in%=in%:IFin%:A%=in%:in%=0:CLOSE#A%
470 ENDPROC
480 :
490 DEFPROCgbpb(A%,chn%,addr%,num%,ptr%)
500 ?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:IFPAGE<&FFFFF:CALL&FFD1:ENDPROC
510 IFA%=1ORA%=3:PTR#?X%=X%!9
520 REPEAT:IFA%=1ORA%=2:BPUT#?X%,?X%!1 ELSE IFA%=3ORA%=4:?X%!1=BGET#?X%
530 X%!1=X%!1+1:X%!5=X%!5-1:UNTIL(EOF#?X% AND A%>2)OR X%!5<1:ENDPROC