Re: writing to cart port (not IO space) on 64

From: Daniel Kahlin <ml-tlr_at_kahlin.net>
Date: Fri, 24 Feb 2017 08:04:13 +0100 (CET)
Message-ID: <Pine.LNX.4.62.1702240803550.12262@yxa.extundo.com>
On Thu, 23 Feb 2017, Jim Brain wrote:

> I know ROML and ROMH are only active on reads, except in Ultimax mode.
>
> My question is:
>
> Can anyone help with a small function that would take an address, a data
> value, a flag for the ROM area to write, and handle the heavy lifting 
of:
>
> * switching to Ultimax mode
> * doing the write
> * switching out of Ultimax mode

You cannot switch to Ultimax mode purely by software.  The cartridge needs
to provide some way to fiddle with EXROM & GAME.

Trivial example for Action Replay/Retro Replay:

MODE_BITS       equ     %00100011       ; RAM + Ultimax
BANK0_BITS      equ     %00000000
BANK1_BITS      equ     %00001000
BANK2_BITS      equ     %00010000
BANK3_BITS      equ     %00011000
BANK4_BITS      equ     %10000000
BANK5_BITS      equ     %10001000
BANK6_BITS      equ     %10010000
BANK7_BITS      equ     %10011000

; Acc = data, Y = bank (0-7)
write byte:
         sei

; optional to avoid visible glitches, wait until border area
         ldx     #$30
lp:
         cpx     $d012
         bcc     lp

; perform write
         ldx     bank_bits_tab,y
         stx     $de00           ; enable ultimax (in RAM $0000-$0fff)
         sta     $1234           ; <---- poke address here
         ldx     #%00000000      ; (this is for returning to ROM,
                                 ; change to what you need.)
         stx     $de00           ; restore normal operation
         rts

bank_bits_tab:
         dc.b    BANK0_BITS | MODE_BITS
         dc.b    BANK1_BITS | MODE_BITS
         dc.b    BANK2_BITS | MODE_BITS
         dc.b    BANK3_BITS | MODE_BITS
         dc.b    BANK4_BITS | MODE_BITS
         dc.b    BANK5_BITS | MODE_BITS
         dc.b    BANK6_BITS | MODE_BITS
         dc.b    BANK7_BITS | MODE_BITS

/Daniel

       Message was sent through the cbm-hackers mailing list
Received on 2017-02-24 08:00:02

Archive generated by hypermail 2.2.0.