10
20
30
40
50 :
60 MODE&87:mem%=&3C00:HIMEM=mem%
70 A%=0:X%=1:M%=((USR&FFF4)AND&FF00)DIV256
80 DIM mcode%&100:PROCassem:romtab%=&2A1:IFM%=0:romtab%=&2A0
90 FOR Y%=0 TO 16:PRINT"ROM ";Y%;": ";:PROCCopy
100 F$="":A%=mem%+9:REPEAT:F$=F$+CHR$?A%:A%=A%+1:UNTILA%?-1=0 OR LENF$>20
110 IFRIGHT$(F$,1)<"A":REPEATF$=LEFT$(F$,LENF$-1):UNTILRIGHT$(F$,1)>"@" OR F$=""
120 I%=INSTR(F$," "):IFI%:REPEATF$=MID$(F$,I%+1):I%=INSTR(F$," "):UNTILI%=0
130 F$=STR$~Y%+"_"+LEFT$(F$,6)+RIGHT$("0"+STR$~mem%?8,2)
140 IFmem%!(mem%?7)<>&29432800 OR romtab%?Y%<&10:F$=""
150 A$="0 FFFBBC00":IF Y%=16:F$="MOS":A$="FFFFC000 FFFFC000"
160 IFF$="":PRINT"<Empty>"; ELSE PRINTF$;:OSCLI"SAVE "+F$+" "+STR$~mem%+"+4000 "+A$
170 PRINT:NEXT:END
180 :
190 DEFPROCCopy:IFM%>0 OR Y%>15:CALLCopy%:ENDPROC
200 FORA%=0TO&3FFF:!&F6=A%+&8000:mem%?A%=USR&FFB9:NEXT:ENDPROC
210 :
220 DEFPROCassem
230 FOR P=0 TO 1
240 P%=mcode%
250 [OPT P*2
260 .Copy% :\ X=ROM number
270 PHP:SEI :\ Disable IRQs
280 CPX #16:BCS CopyMOS
290 LDA &F4:PHA:STX &F4:STX &FE30
300 LDA #&80:JSR CopyRom
310 PLA:STA &F4:STA &FE30
320 PLP:RTS
330 :
340 .CopyMOS
350 LDA #0:LDX #1:JSR &FFF4
360 CPX #3:BCC NotMaster
370 LDA &FE34:PHA
380 AND #&F7:ORA #&40:STA &FE34
390 .NotMaster
400 PHP :\ Save Master flag
410 LDA #&C0:JSR CopyRom
420 PLP:BCC NotMasExit
430 PLA:STA &FE34
440 .NotMasExit
450 PLP:RTS
460 :
470 .CopyRom:\ A=Start
480 STA &71:LDA #mem%DIV256:STA &73
490 LDY #0:STY &70:STY &72
500 .LP
510 LDA (&70),Y:STA (&72),Y:INY:BNE LP
520 INC &73:INC &71:LDA &71
530 AND #&3F:BNE LP:RTS
540 ]NEXT:ENDPROC