Memory map: Difference between revisions
Rainwarrior (talk | contribs) (ROM header placement) |
Rainwarrior (talk | contribs) (explain where exhirom header is) |
||
Line 57: | Line 57: | ||
A23 --> A22 (inverted) | A23 --> A22 (inverted) | ||
</pre> | </pre> | ||
The [[ROM header]] resides at the end of the first 32k bank past 4MB at $40FFC0 in the ROM, mapped to $00FFC0 in memory. |
Revision as of 03:58, 21 May 2022
Overall
The SNES natively provides access to RAM and I/O at specific locations. The cartridge is free to provide whatever it wants in the remaining space, and there are specific address ranges that are conventionally used to add access to additional hardware such as extra RAM or a coprocessor. Different address ranges are accessed at different speeds, and the speed of the ROM at banks $80-$FF may be changed with register $420D.
The first 8KB of RAM is mirrored into many banks for convenient access, and banks $7E-$7F provide continuous access to the entire 128KB in one continuous address range.
A ROM header is always present in the memory map at $00FFC0, though LoROM and HiROM will place these at a different location within the ROM itself.
LoROM
The LoROM mapping mode uses 32KB banks. The first 15 address pins are connected normally, but the 16th address pin on the SNES cartridge port is not connected to anything.
The benefit of LoROM is that it is simpler to understand, and is closer to what NES developers are used to. LoROM can go up to 4 megabytes, but past the 2 megabyte mark the RAM and I/O are no longer mirrored into the banks. For a LoROM game over 2 megabytes it's recommended to put code toward the beginning of the ROM, and data toward the end.
The ROM header resides at the end of the first 32k bank at $007FC0 in the ROM, mapped to $00FFC0 in memory.
Connections:
A0-A14 --> A0-A14 A15 (Not connected) A16 --> A15 A17 --> A16 A18 --> A17 A19 --> A18 A20 --> A19 A21 --> A20 A22 --> A21 A23 (Not connected)
HiROM
The HiROM mapping mode uses 64KB banks. It is created by connecting the SNES's address pins to the ROM's address pins 1-to-1, without skipping any pins. This allows access to a linear view of the entire ROM at $C0-$FF. This simplifies programming for data that can cross bank boundaries. Additionally it helps fit more data into the ROM, because data that cannot cross bank boundaries has fewer bank boundaries to avoid.
HiROM can be viewed as a superset of LoROM because it still provides access to the last 32KB of every bank in the LoROM area. Therefore a HiROM game can decide to put code in those areas and be programmed as if it were a LoROM game, while still having the benefits of 64KB data banks.
The ROM header resides at the end of the first 64k bank at $00FFC0 in the ROM, mapped to $00FFC0 in memory.
Connections:
A0-A21 --> A0-A21 A22 (Not connected) A23 (Not connected)
ExHiROM
ExHiROM is a map meant for exceeding the 4 megabyte limit HiROM normally has. Banks $80-$FF point to the first 4 megabytes of the ROM file as normal, but banks $00-$7D can point up to an additional 4 megabytes (minus 64 kilobytes due to the RAM banks).
Connections:
A0-A21 --> A0-21 A22 (Not connected) A23 --> A22 (inverted)
The ROM header resides at the end of the first 32k bank past 4MB at $40FFC0 in the ROM, mapped to $00FFC0 in memory.