10 REM Read two files (called WRPARTIM and SHBOOT) from a DOS floppy disk 20 REM to a BBC disk 30 : 40 REM As written, this works on a Master to read from a 360kb disk in 50 REM the second floppy disk drive (Drive B: for DOS) to a BBC 60 REM disk in drive :0 70 REM There are variations for: 80 REM a) Using a Model B or B+ - some registers are at different locations 90 REM b) Reading from a 720kb disk 100 REM c) Reading from and writing to a different drive 110 REM See the comments in PROCsetup, and adjust appropriately 120 : 130 : 140 MODE 135 150 DIM side_val%(1) 160 PROCsetup 170 PROCinit 180 PROCfile("WRPARTIM") 190 PROCfile("SHBOOT") 200 PRINT:END 210 : 220 : 230 DEF PROCsetup 240 REM Change values in this PROC if using a different set-up 250 : 260 REM Next are values for the BBC Master 270 REM Change following five values to 280 REM &FE80 and &FE84-&FE87 (in this order) to use with a B or B+ 290 ctrl_reg%=&FE24 300 commstat_reg%=&FE28 310 track_reg%=&FE29 320 sector_reg%=&FE2A 330 data_reg%=&FE2B 340 : 350 REM Next two values are those for a Master reading from 360 REM a DOS disk in Drive B: 370 REM Change to values 5 and &15 to read from Drive A: on a Master 380 REM If using a B or B+ then change them to 390 REM &22 and &26 to use Drive B: 400 REM or &21 and &25 to use Drive A: 410 side_val%(0)=6:side_val%(1)=&16 420 : 430 REM Change next if writing to a different drive (which must be physically 440 REM different from the source drive). Note final "." 450 dest$=":0." 460 : 470 REM Next one is for 360kb (40-track) disks 480 REM For 720kb (80-track) disks use: step%=1 490 step%=2 500 : 510 ENDPROC 520 : 530 : 540 DEF PROCinit 550 PROCassemble 560 ?ctrl_reg%=side_val%(0) 570 ?commstat_reg%=8 580 PROCwait 590 current_track%=0 600 DIM boot_sector% &200 610 PROCreadsector(0,boot_sector%) 620 cluster_size%=boot_sector%?&D:cluster_bytes%=&200*cluster_size% 630 dir_size%=(boot_sector%?&11)DIV&10 640 fat_size%=boot_sector%?&16 650 DIM fat% &200*fat_size% 660 FOR I%=1 TO fat_size% 670 PROCreadsector(I%,fat%+(I%-1)*&200) 680 NEXT 690 DIM dir% &200 700 PROCreadsector(fat_size%*2+1,dir%) 710 DIM data% cluster_bytes% 720 system_size%=1+(fat_size%*2)+dir_size% 730 DIM gbpb% 13 740 ENDPROC 750 : 760 DEF PROCreadsector(N%,B%) 770 PROCassemble 780 store_byte?1=B% 790 store_byte?2=B% DIV &100 800 track%=N% DIV 9 810 side%=track% MOD 2 820 track%=track% DIV 2 830 sector%=(N% MOD 9)+1 840 ?ctrl_reg%=side_val%(side%) 850 ?track_reg%=current_track%*step% 860 ?data_reg%=track%*step% 870 ?commstat_reg%=&18 880 PROCwait 890 current_track%=track% 900 ?track_reg%=track% 910 ?sector_reg%=sector% 920 ?commstat_reg%=&84 930 PROCwait 940 ENDPROC 950 : 960 DEF PROCassemble 970 FOR I%=0 TO 2 STEP 2 980 P%=&D00 990 [OPT I% 1000 pha 1010 lda commstat_reg% 1020 and #&1F 1030 cmp #3 1040 bne done_nmi 1050 lda data_reg% 1060 .store_byte 1070 sta &4000 1080 inc store_byte+1 1090 bne done_nmi 1100 inc store_byte+2 1110 .done_nmi 1120 pla 1130 rti 1140 ] 1150 NEXT 1160 ENDPROC 1170 : 1180 DEF PROCwait 1190 REPEAT:UNTIL ((?commstat_reg%) AND 1)=0 1200 ENDPROC 1210 : 1220 DEF PROCfile(fname$) 1230 PRINT 'fname$ 1240 entry%=dir%-&20 1250 REPEAT 1260 entry%=entry%+&20 1270 this_one$="":L%=0 1280 REPEAT 1290 char%=entry%?L% 1300 IF char%<>&20:this_one$=this_one$+CHR$(char%AND&DF) 1310 L%=L%+1 1320 UNTIL char%=&20 OR L%=8 1330 UNTIL this_one$=fname$ 1340 file_size%=entry%!&1C 1350 cluster%=(entry%!&1A) AND &FFFF 1360 H%=OPENOUT(dest$+fname$) 1370 REPEAT 1380 PROCreadcluster(cluster%) 1390 ?gbpb%=H% 1400 gbpb%!1=data% 1410 IF file_size%&FF7 1460 CLOSE# H% 1470 ENDPROC 1480 : 1490 DEF PROCreadcluster(C%) 1500 PRINT "."; 1510 abs_sect%=system_size%+(C%-2)*cluster_size% 1520 FOR S%=0 TO cluster_size%-1 1530 PROCreadsector(abs_sect%+S%,data%+S%*&200) 1540 NEXT 1550 ENDPROC 1560 : 1570 DEF FNnextcluster(C%) 1580 pair%=fat%!((C%DIV2)*3) 1590 IF (C%AND1)=0:=(pair%AND&FFF):ELSE:=(pair%AND&FFF000)DIV&1000