;Willams cart 64K Bank Copy / Run routine ;written by Nir Dary ; ;i.e SpeedKing game from Mastertronics ;Loads to memory $5480 -> $9840, Run address $9800 DOSINI = $0C ;** DOSVEC = $0A TMPFROM = $CA ;Tmp Source addrss TMPTO = $CC ;Tmp Destination address TMPEND = $CE ;Tmp Last source address to copy TMPTABLE = $D0 ;Table address BASE = $0600 RUNGAME = TABLE Org $0600 ; (This Data will be located at $A000) TABLE .BYTE $00,$0C ; Game Start Addrss $1300 .BYTE $01,$00,$A0,$00,$0C,$00,$C0 ; Bank 01, A000 -> 5000 move 8K bytes .BYTE $02,$00,$A0,$00,$2C,$00,$C0 ; Bank 02, A000 -> 7000 move 8K bytes .BYTE $03,$00,$A0,$00,$4C,$00,$C0 ; etc .BYTE $04,$00,$A0,$00,$6C,$00,$C0 .BYTE $05,$00,$A0,$00,$8C,$00,$C0 .BYTE $06,$00,$A0,$00,$AC,$00,$B4 .BYTE $FF,$00,$00,$00,$00,$00,$00,$00 ; $FF ends the copy routine START STX $03E9 STX $03EA DEX STX $D301 LDA #$01 STA $09 STA $42 STA $03F8 LDA #TABLE STA TMPTABLE+1 INC TMPTABLE ; Skip first 2 bytes of table (games run address) INC TMPTABLE ; ** routine to copy more then 1 page ($A000->$0600) ** LDX #$2 ; # of pages to move LDA #$00 STA TMPFROM STA TMPTO LDA #$A0 STA TMPFROM+1 LDA #>BASE STA TMPTO+1 L11 LDY #0 L22 STA $D500 LDA (TMPFROM),Y STA $D508 STA (TMPTO),Y INY BNE L22 DEX BEQ DONE INC TMPFROM+1 ; next page of RAM INC TMPTO+1 JMP L11 DONE JMP COPY ; ie. jmp 0600 region to move code out of cartridge COPY LDA #$00 STA $D40E SEI LDA #$FE STA $D301 L33 LDY #$00 ;Load Bank# from table into X register LDA (TMPTABLE),Y ;and deted if End of Table then exit to run game CMP #$FF BEQ EXITCOPY TAX INC TMPTABLE LDA (TMPTABLE),Y ; Load Source Address from table STA TMPFROM INC TMPTABLE LDA (TMPTABLE),Y STA TMPFROM+1 INC TMPTABLE LDA (TMPTABLE),Y ;Load Destination Address from table STA TMPTO INC TMPTABLE LDA (TMPTABLE),Y STA TMPTO+1 INC TMPTABLE LDA (TMPTABLE),Y ;Load End address of copy sequace STA TMPEND INC TMPTABLE LDA (TMPTABLE),Y STA TMPEND+1 INC TMPTABLE ;Start of Copy Routine MAINLOOP STA $D500,X ;enter Williams cart desired bank LDA (TMPFROM),Y STA $D508 ;Turn cartrige off STA (TMPTO),Y INC TMPFROM BNE L1 INC TMPFROM+1 L1 INC TMPTO BNE L2 INC TMPTO+1 L2 LDA TMPFROM+1 ; Copy unitl address end addres in table CMP TMPEND+1 BNE MAINLOOP LDA TMPFROM CMP TMPEND BNE MAINLOOP BEQ L33 ; Do next Bank? EXITCOPY LDA #$22 STA $D400 ;DMA control LDA #$FF STA $D301 ;RAM under ROM off, ROM on LDA #$C0 ;Some games need 40???** STA $D40E ;NMI interrupts allowed, see Mapping Atari CLI LDA #EXITCART ;** STA DOSINI+1 STA DOSVEC+1 LDA #$C0 ;C000 high byte STA $2E4 ;system size, sometimes not important, sometimes is! STA $2E6 ;** STA $6A ;dl list ends here and goes down in memory apprx0300h bytes. LDA #$00 ;cart interlock, could be LDA d013 STA $03FA ;off STA $42 ;critic OK for long interrupts LDA #$00 STA $244 ; COLDST LDA #$01 STA $08 ; WARMST RTS ; EXITCART JMP (RUNGAME) ; Org $BFFA .WORD $0000 .BYTE $00 .BYTE $00 .WORD START+$9A00