SNES LoROM mapping

Discussion of hardware and software development for Super NES and Super Famicom. See the SNESdev wiki for more information.

Moderator: Moderators

Forum rules
  • For making cartridges of your Super NES games, see Reproduction.
Post Reply
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

SNES LoROM mapping

Post by dougeff »

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: 376
Joined: Sat Jan 03, 2015 5:58 pm
Location: ...
Contact:

Re: SNES LoROM mapping

Post by nicklausw »

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: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: SNES LoROM mapping

Post by dougeff »

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: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: SNES LoROM mapping

Post by lidnariq »

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 »

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: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: SNES LoROM mapping

Post by lidnariq »

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 »

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