10 MODE 7 20 ROM=2 : REM change this to whatever slot 30 : REM has this MMC DFS ROM in it 40 : 50 protect=&D00 60 copy=HIMEM-(18*256*2) 70 zpcopy=copy-256 80 swap=zpcopy-PAGE+protect 90 asm=swap-512 100 PRINT "Using mem from ";~asm;" to ";~swap;" for asm" 110 PRINT "Using mem from ";~swap;" to ";~zpcopy;" for swap" 120 PRINT "Using mem from ";~zpcopy;" to ";~copy;" for zp" 130 PRINT "Using mem from ";~copy;" to ";~HIMEM;" for copy" 140 HIMEM=asm 150 oldrom=?(&2A1+ROM) 160 : 170 PROCcreate_asm 180 : 190 REM Save the current MMC DFS status by 200 REM copying &D00->PAGE-1 to "swap" 210 CALL memcopy 220 : 230 REM switch to DFS. Hopefully this works 240 REM 'cos otherwise the whole machine 250 REM will have trouble! 260 PRINT "Image what drive (0 or 2)"; 270 INPUT DRIVE 280 IF DRIVE<>0 AND DRIVE<>2 THEN PRINT"Bad drive":END:END IF 290 PROCswapto("DISK") 300 OSCLI("DRIVE "+STR$(DRIVE)) 310 PRINT"Doing *. to ensure disk is readable" 320 *. 330 PRINT 340 PRINT "Press any key to continue: "; 350 A$=GET$ 360 PRINT 370 : 380 REM load the first 2 sectors of track 0. 390 REM from here we can get the disk size 400 REM and calculate number of sectors per 410 REM track 420 IF FNloadtrack(0,2,copy) THEN PRINT "Fail to load track 0": END: END IF 430 PRINT 440 PRINT "If your floppy didn't access at that" 450 PRINT "point then you may have the wrong ROM" 460 PRINT "value set in this script" 470 PRINT 480 SIZE=copy?&107 + 256*(copy?&106 AND 7) 490 SECT=10 500 IF SIZE>&320 SECT=16 510 IF SIZE>&500 SECT=18 520 PRINT "Sectors per track (";SECT;") "; 530 INPUT X 540 IF X<>0 SECT=X 550 PRINT 560 PRINT "Using ";SECT;" sectors" 570 PRINT 580 PRINT "Ensure disks 1 and 3 have been *DIN'd" 590 PRINT 600 PRINT "Press any key to continue: "; 610 A$=GET$ 620 PRINT 630 : 640 REM now we load data in chunks of 2 650 REM tracks, and we do this 40 times 660 REM but we can't do it as FOR loops 670 REM because BRK error from DFS breaks 680 REM loops/functions/etc 690 LET A=0 700 CALL unformat 710 LET B=0 720 T=A*2+B 730 D=copy+B*256*SECT 740 L=256*SECT*2 750 ON ERROR PRINT '"Error loading track":GOTO 770 760 IF FNloadtrack(T,SECT,D) PRINT "Fail to load track "+STR$(T)+", continuing" 770 ON ERROR OFF 780 LET B=B+1 : IF B<=1 GOTO 720 790 : 800 REM Now we save this bunch of tracks 810 REM as a file. In the worst case (18 820 REM sects per track) this is 9K so 830 REM we can only save 20 of these per 840 REM 200K disk. So parts0->19 go on 850 REM drive 1, parts 20->39 on drive 3 860 IF A>19 DISK=3 ELSE DISK=1 870 IF A<10 X$="0" ELSE X$="" 880 CMD$="SAVE :"+STR$(DISK)+".$.PART"+X$+STR$(A)+" "+STR$~copy+" +"+STR$~L 890 : 900 REM switch to CARD mode 910 PROCswapto("CARD") 920 OSCLI CMD$ 930 PROCswapto("DISK") 940 LET A=A+1 : IF A<=39 GOTO 700 950 PRINT 960 PRINT "Finished" 970 PROCswapto("CARD") 980 END 990 : 1000 DEF PROCswapto(D$) 1010 CALL memswap 1020 IF D$="DISK" THEN ?(&2A1+ROM)=0 ELSE ?(&2A1+ROM)=oldrom 1030 OSCLI D$ 1040 ENDPROC 1050 : 1060 DEF PROCcreate_asm 1070 REM Simple code to read a track via OSWORD &7F 1080 FOR A=0 TO 2 STEP 2 1090 P%=asm 1100 [OPT A 1110 .memswap 1120 \ First swap &A0->&CF with zpcopy 1130 LDX #&2F \ this many bytes to copy 1140 .swapzeroloop 1150 LDA &A0,X 1160 PHA 1170 LDA zpcopy,X 1180 STA &A0,X 1190 PLA 1200 STA zpcopy,X 1210 DEX 1220 BPL swapzeroloop 1230 \ Now switch protect->PAGE with swap 1240 \ (&70) is target, (&72) is source 1250 LDA #0 1260 STA &70 1270 LDA #swap DIV 256 1280 STA &71 1290 LDA #0 1300 STA &72 1310 LDA #&D 1320 STA &73 1330 LDX #(PAGE-protect) DIV 256 1340 LDY #0 1350 .memloop 1360 LDA (&70),Y 1370 PHA 1380 LDA (&72),Y 1390 STA (&70),Y 1400 PLA 1410 STA (&72),Y 1420 INY 1430 BNE memloop 1440 INC &71 1450 INC &73 1460 DEX 1470 BNE memloop 1480 RTS 1490 .memcopy 1500 \ First copy &A0->&CF to zpcopy 1510 LDX #&2F \ this many bytes to copy 1520 .pzcpyloop 1530 LDA &A0,X 1540 STA zpcopy,X 1550 DEX 1560 BPL pzcpyloop 1570 \ Now copy protect->PAGE to swap 1580 \ (&70) is target, (&72) is source 1590 LDA #0 1600 STA &70 1610 LDA #swap DIV 256 1620 STA &71 1630 LDA #0 1640 STA &72 1650 LDA #&D 1660 STA &73 1670 LDX #(PAGE-protect) DIV 256 1680 LDY #0 1690 .copyloop 1700 LDA (&72),Y 1710 STA (&70),Y 1720 INY 1730 BNE copyloop 1740 INC &71 1750 INC &73 1760 DEX 1770 BNE copyloop 1780 RTS 1790 .unformat 1800 LDA #0 1810 STA &70 1820 LDA #copy DIV 256 1830 STA &71 1840 LDX #(&7C00-copy)DIV 256 1850 LDA #&E5 1860 LDY #0 1870 .formloop 1880 STA (&70),Y 1890 INY 1900 BNE formloop 1910 INC &71 1920 DEX 1930 BNE formloop 1940 RTS 1950 .read 1960 LDA #&7F 1970 LDX #data MOD 256 1980 LDY #data DIV 256 1990 JSR &FFF1 2000 LDA result 2010 BEQ ok 2020 BRK 2030 EQUB 1 2040 EQUS "Reading error" 2050 BRK 2060 .ok 2070 RTS 2080 .data 2090 EQUB 255 2100 EQUD 0 2110 EQUB 3 2120 EQUB &57 2130 EQUB 0 2140 EQUB 0 2150 EQUB 0 2160 .result 2170 EQUB 0 2180 ] 2190 NEXT 2200 PRINT"Assembly ends ";~P% 2210 ENDPROC 2220 : 2230 DEF FNloadtrack(T%,S%,D%) 2240 PRINT "Loading track ";T%;" to ";~D% 2250 data!1=D% 2260 data?7=T% 2270 data?9=&20+S% 2280 REM ON ERROR PRINT'"Error detected":GOTO ERL+10 2290 CALL read 2300 REM ON ERROR OFF 2310 =?result