Subroutines in LoRom/Mode 20, Address Decoding

Discussion of hardware and software development for Super NES and Super Famicom.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
melanokardios
Posts: 17
Joined: Wed Apr 26, 2017 2:26 pm

Subroutines in LoRom/Mode 20, Address Decoding

Post by melanokardios » Thu Jan 11, 2018 12:01 pm

I'm confused about how the PC is loaded if I do a JML or JSL. If I understand the mapping correctly, it means that

Code: Select all

SNES Address    ROM Address
$00:8000        $00:0000
$01:8000        $00:8000
$02:8000        $01:0000
.
.
.
And so on. How do absolute long jumps then work? Let's say I tell my assembler to place my reset routine at ROM $00:0000 and my drawing at ROM $01:0000. So If I write

Code: Select all

Reset:
    ; some code
    jsl DrawRoutine
    ; more code
This will become

Code: Select all

jsl $010000
But loading $010000 into the PC of the SNES will point me to the RAM mirror in SNES $01:0000 - which is wrong. How do I adjust this?

I work with cc65, so I guess it would me possibly to write a memory config for the linker that would adjust the addresses of the subroutines accordingly, but that seems somehow too convoluted to me. So again the question, how do I jump between pages/bankes? Assuming I do not want to use the SNES banks $0C or higher.

lidnariq
Posts: 8786
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Subroutines in LoRom/Mode 20, Address Decoding

Post by lidnariq » Thu Jan 11, 2018 12:21 pm

With ld65, you really have to structure your LoROM application as a series of 32 KiB slices. Look at tepples's lorom template

melanokardios
Posts: 17
Joined: Wed Apr 26, 2017 2:26 pm

Re: Subroutines in LoRom/Mode 20, Address Decoding

Post by melanokardios » Thu Jan 11, 2018 12:24 pm

lidnariq wrote:With ld65, you really have to structure your LoROM application as a series of 32 KiB slices. Look at tepples's lorom template
Very helpful, thanks!

Post Reply