.OPT NO LIST,NO EJECT ; SAVE #D1:CARTDUMP.M65 ; ; ; ASM ,,#D1:CARTDUMP.COM ; ; Copy OSS cartridge banks to ; D1:CARTIMAGE.CBx where x is bank ; ICCOM = $0342 ICBAL = $0344 ICBLL = $0348 ICAX1 = $034A CIOV = $E456 PORTB = $D301 DMACTL = $D400 SDMCTL = $022F GINTLK = $03FA TRIG3 = $D013 ; *= $2F00 ; ; The first 64 bytes are dumped to ; the CARIMAGE.MAP file ; RAMROM *= *+16 0=rom $FF=ram BANKNO *= *+16 byte at $AFFF BARRAY *= *+16 0=valid rom bank TRIG3A *= *+16 trig3 reading for bank CURBNK *= *+1 Base test bank TESTBK *= *+1 Bank being tested vs base CBSAVE *= *+1 Entry cart status PBSAVE *= *+1 Entry portb status ; *= $3000 START LDA #$60 STA START LDX #0 TXA ZLOOP STA $2F00,X Clear data page INX BNE ZLOOP ; LDA PORTB STA PBSAVE DEX STX PORTB LDY #$08 LDA GINTLK BEQ HAVBNK LDY $AFFF HAVBNK STY CBSAVE ; SEI Kill vblank 2 before LDX #15 playing with cart LOOP0 STA $D500,X First test LDA TRIG3 if rom or ram STA TRIG3A,X LDA $AFFF Get any bank number STA BANKNO,X INC $AFFF Check ram CMP $AFFF BEQ ISROM No, it's rom STA $AFFF DEC RAMROM,X Set rom/ram map to ram DEC BARRAY,X Show no rom to test ISROM DEX BPL LOOP0 ; STA $D500,Y Cartridge normal CLI vblank now ok ; STX CURBNK Start base at -1 LDY #$FF LOOP1 INY CPY #16 All higher ones tested? BCS NEXTBASE Yes, bump test base LDA BARRAY,Y Unique rom this bank? BMI LOOP1 No, ram or a dup TYA TAX LOOP2 INX Test all higher CPX #16 banks for duplicate BCS LOOP1 All higher tested. LDA BANKNO,X Was there a valid CMP #16 bank number? BCS FAIL No EOR BANKNO,Y Same as current? BNE LOOP2 No FAIL DEC BARRAY,X Yes, flag a duplicate BMI LOOP2 Go always NEXTBASE INC CURBNK If at bank 15 there's LDX CURBNK none higher to compare CPX #15 with BCS MAPWRT So go finish up ; LDA BARRAY,X Check if bank valid BMI NEXTBASE No, ram or duplicate STA $D500,X Enable it LDY #0 Copy it to $6000 LDA #$A0 STA CLOOP+2 LDA #$60 STA CLOOP+5 CLOOP LDA $A000,Y STA $6000,Y INY BNE CLOOP INC CLOOP+2 INC CLOOP+5 BPL CLOOP JSR WRITE Write it to disk JMP NEXTBASE MAPWRT LDX CBSAVE STA $D500,X LDA PBSAVE STA PORTB LDX #$10 LDA # MSPEC STA ICBAL+1,X LDA #3 JSR GOCIO BMI CLOSE LDA # RAMROM STA ICBAL+1,X LDA #48 STA ICBLL,X LDA #0 BEQ BPUT WRITE TXA CLC ADC #'0 CMP #'9+1 BCC ISHEX ADC #6 ISHEX STA BANKID LDX #$10 JSR CLOSE LDA # FSPEC STA ICBAL+1,X LDA #8 STA ICAX1,X LDA #0 STA ICAX1+1,X LDA #3 JSR GOCIO BMI CLOSE LDA # <$6000 STA ICBAL,X address STA ICBLL,X length LDA # >$6000 STA ICBAL+1,X address LDA # >$2000 BPUT STA ICBLL+1,X length LDA #11 bput JSR GOCIO CLOSE LDA #12 GOCIO STA ICCOM,X JMP CIOV ; ; Copy cartridge bank to $4000 ; BCOPY SEI STA $D500,X LDA # >$A000 STA LOOP4+2 LDA # >$4000 STA LOOP4+5 LDX #32 LDY #0 LOOP4 LDA $A000,Y STA $4000,Y INY BNE LOOP4 INC LOOP4+2 INC LOOP4+5 DEX BNE LOOP4 LDX CBSAVE STA $D500,X RTS ; FSPEC .BYTE "D1:CARIMAGE.CB" BANKID .BYTE "0",155 MSPEC .BYTE "D1:CARIMAGE.MAP",155 .OPT NO LIST .END