SNES LoROM mapping

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
User avatar
dougeff
Posts: 2652
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

SNES LoROM mapping

Post by dougeff » Sat Apr 07, 2018 5:38 am

I seem to be slightly confused. Just want some input.

So, normally, on a 65816 machine, you would complete access to the full 65kB space. Like if you wantes to load from the RAM at $012345 you would do LDA $012345.

The SNES is mapped. On the SNES, if you wanted the 1st bytes of a ROM you wouldn't access it at $000000, but at $008000, since RAM is at $000000.

So, in LoROM, the ROM chip is divided into $8000 chucks.

So, if you wanted the next chuck of ROM (bytes $8000-ffff of the ROM), would you set the bank byte to $01?

So for example, if you wanted to jump to that bank, would you...

JMP $018000

or if you wanted to read from the $8001th byte on the ROM, would you

LDA $018001

because it looks like you are trying to load the $18001th byte.
Last edited by dougeff on Sat Apr 07, 2018 5:59 am, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
nicklausw
Posts: 371
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: SNES LoROM mapping

Post by nicklausw » Sat Apr 07, 2018 5:49 am

You can jump to a long address; some assemblers make you use jml rather than jmp though, or jsl rather than jsr.

You can also load from a long address, but yes, in that example setting data bank to $01 would be an option.

Code: Select all

lda $018000 (okay, or...)
lda #$01; pha; plb; lda $8000 (same thing).
Always be careful moving the data bank around, because it will miserably screw up reading any hardware registers from bank $00.

User avatar
dougeff
Posts: 2652
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: SNES LoROM mapping

Post by dougeff » Sat Apr 07, 2018 7:54 am

My question is about the mapping.

Am I understanding it correctly?

LDA $018000 will load A from the byte located at $8000 in the ROM?

LDA $028000 from the $10000 th byte in the ROM?

So logically, the upper address bits are shifted...

00AAAAAA 1BBBBBBB BBBBBBBB
to
000AAAAA ABBBBBBB BBBBBBBB

right?

Edit, changed to As and Bs for clarity.
nesdoug.com -- blog/tutorial on programming for the NES

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

Re: SNES LoROM mapping

Post by lidnariq » Sat Apr 07, 2018 10:06 am

That is the "LoROM" = "mode $20" memory map, yes. Byte offset 0 in the ROM is available to the CPU at address $008000. Byte offset 0x8000 is available at $018000.

In contrast, the "HiROM" = "mode $21" memory map, byte offset 0x8000 is available to the CPU at address $008000, but byte offset 0 has to be accessed via some mirror because the CPU can't access ROM at $000000. Often $C00000 is used, to allow higher-speed bus timings.

Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: SNES LoROM mapping

Post by Optiroc » Sat Apr 07, 2018 12:07 pm

What you’re saying is absolutely true for the mapping scheme commonly known as LoROM.

The SNES memory map can seem very confusing. What made it finally “click” with me was the realization that the SNES asserts the /ROMSEL pin on the cartridge connector for these address ranges:

Code: Select all

00-3F:8000-FFFF
40-7D:0000-FFFF
80-BF:8000-FFFF
C0-FF:0000-FFFF
In essence the SNES expects the cartridge to put something on the bus for these address ranges, while internal MMIO and RAM may have priority in other ranges. The peculiarities of all mapping schemes made a lot more sense then.

That said, any ranges not actually used by system MMIO or RAM are also usable on external buses, but I don’t think any official cartridges or peripherals do that.

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

Re: SNES LoROM mapping

Post by lidnariq » Sat Apr 07, 2018 12:57 pm

Optiroc wrote:That said, any ranges not actually used by system MMIO or RAM are also usable on external buses, but I don’t think any official cartridges or peripherals do that.
HiROM games with RAM do...

Optiroc
Posts: 129
Joined: Thu Feb 07, 2013 1:15 am
Location: Sweden

Re: SNES LoROM mapping

Post by Optiroc » Sat Apr 07, 2018 1:24 pm

lidnariq wrote:
Optiroc wrote:That said, any ranges not actually used by system MMIO or RAM are also usable on external buses, but I don’t think any official cartridges or peripherals do that.
HiROM games with RAM do...
Ah, of course. :oops: Actually, most expansion chip MMIO fall in these ranges, doesn’t it?

Still, the point stands, I think: /ROMSEL and /WRAMSEL behavior does explain why ROM is mapped the way it is.

Post Reply