10MODE 7 20 30OSARGS = &FFDA 40OSFILE = &FFDD 50OSWRCH = &FFEE 60 70 REM Use language workspace as this code causes reset anyway. 80 90zp = &70 100from = &74 110to = &76 120 130FOR PASS = 0 TO 2 STEP 2 140P% = &7000 150 160[OPT PASS 170 180 \ 190 \ Set Mode 7 - 200 \ This sits at &7000, 210 \ file sits at &3000 to &7000 220 \ 230 240 Lda #22: Jsr OSWRCH 250 Lda #7: Jsr OSWRCH 260 270 \ 280 \ Pick up command line from OSARGS 1 290 \ 300 Lda #1 310 Ldx #zp 320 Ldy #0 330 Jsr OSARGS 340 \ 350 \ zp(0..3) points to command line 360 \ 370 Ldy #&FF \ Y points to parameter 380 Ldx #0 \ X points to destination 390 400.copy_strings 410 Iny 420 Lda (zp),Y 430 Cmp #32 440 Beq copy_strings 450 Sta filename,X \ Copy filename into OSFILE 460 Inx \ parameter block 470 Cmp #&0D 480 Bne copy_strings 490 \ 500 \ Call OSFILE to load up ROM image 510 \ to &3000. 520 \ 530 Lda #&FF 540 Ldx #CB MOD 256 550 Ldy #CB DIV 256 560 Jsr OSFILE 570 \ 580 \ Return code in A: 590 \ 0 - Not exist 600 \ 1 - File 610 \ 2 - Directory 620 \ 630 Cmp #1 640 Beq Load_ROM_emulator 650 \ 660 \ failed to find file 670 \ 680 BRK: EQUB 1: EQUS "Failed to load file": EQUB 0 690 \ 700.Load_ROM_emulator 710 \ 720 \ Loop over 3000 to 7000, copying into ROM 730 \ locations, which are made available 740 \ by writing to the S/W rom latch. 750 \ 760 \ Care has to be taken to write to RAM image of latch first, 770 \ for any stray NMIs which may occur during the transfer 780 \ 790 PHP:SEI 800 \ *** Interrupts disabled 810 \ 820 Lda &F4: Sta Old_latch 830 Ldx #15 840.grope_RAM \ Find a sideways rom which remembers data... (he he he) 850 Stx &F4 860 Stx &FE30 870 Lda #17 \ The most random number in the universe 880 Sta &8001 890 Lda #42 \ The least random number ... 900 Sta &8023 910 Lda &8001 920 Cmp #17 930 Beq found_RAM 940 Dex 950 Cpx #11 960 Bne grope_RAM 970 980 BRK: EQUB 3: EQUS "No ROM Emulator": EQUB 0 990 1000 \ 1010 \ Emulator found in ROM X 1020 \ 1030.found_RAM 1040 Ldy #0 1050 \ 1060 Lda #&30: Sta from+1 1070 Lda #&0: Sta from+0 1080 Lda #&80: Sta to+1 1090 Lda #&0: Sta to+0 1100 \ 1110 \ 1120.Load_up 1130 Lda (from),Y 1140 Stx &F4 1150 Stx &FE30 1160 Sta (to),Y 1170 Lda (to),Y 1180 Cmp (from),Y 1190 Bne Read_failed 1200 Inc from 1210 Bne from_1 1220 Inc from+1 1230.from_1 1240 Inc to 1250 Bne to_1 1260 Inc to+1 1270.to_1 1280 Lda from+1 1290 Cmp #&70 \ stop when from = &7000 1300 Bne Load_up 1310 \ 1320 \ Completed. restore latch. 1330 \ 1340 Lda Old_latch 1350 Sta &F4 1360 Sta &FE30 1370 PLP 1380 \ 1390 \ Now call HARD BREAK to initialise new ROM. 1400 \ 1410 BRK: EQUB 5: EQUS "Completed OK!": EQUB 0 1420 \ 1430.Read_failed 1440 Lda Old_latch 1450 Sta &F4 1460 Sta &FE30 1470 PLP 1480 \ 1490 BRK: EQUB 4: EQUS "Read-back error in ROM": EQUB 0 1500 \ 1510 \ 1520 \ DATA follows 1530 \ 1540.Old_latch 1550 EQUB 0 1560.filename 1570 EQUS "Any old filename goes here....................." 1580.CB 1590 EQUW filename 1600 EQUD &3000 1610 EQUD 0 1620 EQUD 0 1630 EQUD 0 1640] 1650NEXT 1660PRINT "Assembled OK." 1670OSCLI("SAVE USE 7000 7200 7000") 1680END