Page 1 of 1

Subroutines in LoRom/Mode 20, Address Decoding

Posted: Thu Jan 11, 2018 12:01 pm
by melanokardios
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.

Re: Subroutines in LoRom/Mode 20, Address Decoding

Posted: Thu Jan 11, 2018 12:21 pm
by lidnariq
With ld65, you really have to structure your LoROM application as a series of 32 KiB slices. Look at tepples's lorom template

Re: Subroutines in LoRom/Mode 20, Address Decoding

Posted: Thu Jan 11, 2018 12:24 pm
by melanokardios
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!