How to bank switch a 6MB SNES ROM so data past 3FFFFF is accessible?

Started by Messianic, November 19, 2020, 12:26:55 PM

Previous topic - Next topic


Literally what the topic says.

I recently made a secondary base ROM of a hack I am almost done with and expanded it to 48mbit (6MB) from where it was at 32mbit (4MB) in order to have space because the compiler used apparently places sprites in the ROM very stupidly and I needed more space.

Long story short, the title screen is messed up in this transition and I don't think data at 480000 is being referenced. I also don't know if this would even work on real hardware (not that I am a repro-enthusiast, just wondering in theory), therefore I am wondering what bytes need to be altered and how in the earlier parts of the ROM for proper bank switching with this ExHiROM.

Thank you for any help.


ExHiROM doesn't do bank switching.  The extra space is just mapped into 40:000-5F:FFFF.  If using an emulator, it may want the lower nibble of the ROM Type in the internal header set to 5 to recognize it (and maybe the size byte set to 0xD).  And once you have that set up, at a minimum you'll want to copy the 00:8000-00:FFFF section of the ROM to 40:8000-40:FFFF. 

If you haven't expanded it yet Lunar Expand can do all that for you with the first 48 Mbit ExHiROM option.  I'm assuming your original ROM was HiROM, of course.

But the thing to watch out for with this kind of expansion is that despite being HiROM some games use a few places in the 00:8000-3F:FFFF area, and that gets remapped to the 40:8000+ area in ExHiROM.  If it's only using it for interrupts you'll likely be fine with just copying the bit I mentioned above, but if not you may need to make copies for a few more 32 KB chunks (so 01:8000-01:FFFF to 41:8000-41:FFFF, 02:8000-02:FFFF to 42:8000-42:FFFF, etc).  In the absolute worst case you'd have to waste half the new space doing that, but that'd be pretty unusual... around 6 copies is more typical for games that need it.  You may need to experiment a bit to see what your game wants.

Or you could manually track down and correct the references in the game's ASM instead of copying those extra chunks, but that's more work.

Quote from: Messianic on November 19, 2020, 12:26:55 PM
I also don't know if this would even work on real hardware (not that I am a repro-enthusiast, just wondering in theory).

Yes, as long as your cart is set up for it.  It's the same map used in Tales of Phantasia.


Thank you for the response.

This is for my "Mother 2 Deluxe" hack of Earthbound for the SNES. I recently expanded it to 6MB and then started noticing issues, like the Title screen words disappearing, and now I have a bigger issue of a cutscene completely not working and freezing the game, making gameplay impossible beyond that point in the game.

All the bytes for those particular cutscenes are exactly the same as they should be in the hex editor, so I don't know why this one cutscene is screwing up while the rest are fine it worked when the ROM was 4MB. I have no idea what t do and do not understand what has changed when I made this ROM 6MB.

I even copied each 32kb section until I got each of ones copied in the 5th MB, so 40:8000-40:FFFF all the way to 4F:8000-4F:FFFF, and I still have broken title screen and cutscene.

Any clues on how the mapping works in order to rack down where the references went wrong?


I just tried expanding Earthbound to 6 MB ExHiROM with Lunar Expand with the first option, and the title screen was fine.  You can try doing the same with a fresh ROM to see if it's just a problem with your emulator.  If it works fine, it'd likely mean you messed up the expansion for your hack somehow.  Make sure you actually changed the ROM type and size in the internal header (at 0xFFD5 and 0xFFD7 PC with no copier header, and copy the changes to the same 32KB section at 40:8000).

For the actual map when you change from HiROM to ExHiROM, 00:8000 - 3F:FFFF on the SNES (32 KB banks) changes from pointing at 00:8000 - 3F:FFFF in the ROM file to 40:8000-7F:FFFF, assuming no 0x200 byte copier header (effectively every second 32KB section from the ROM can be accessed here).  The mirrored area at 80:8000-BF:FFFF SNES also changes to match.

The other change is that 40:0000-7D:FFFF on the SNES (64KB banks) goes from pointing at 00:0000 - 3D:FFFF in the ROM file to 40:0000-7D:FFFF.  Which shouldn't be an issue, as normally HiROM games don't use that area...  they typically access the original ROM at C0:0000-FF:FFFF SNES instead, and that area remains unchanged for ExHiROM.


Hello, I'm sorry for my first post to be pedantic but this caught my eye.

When you expand a 4MB ROM to 6MB, just mirroring the upper 32KB of each bank isn't enough to be completely safe.

That will fill in 00:8000-1F:FFFF, but now 20:8000-3F:FFFF will mirror the first 2MB of the expansion. But in the original 4MB ROM, 20:8000-3F:FFFF would be the contents of the second 2MB of the original ROM.

To be completely safe, you must expand an ExHiROM game to 8MB, not 6MB, and then mirror the upper 32KB of all 4MB. This gives you a total of 2MB additional space in the lower 32KB of each bank. If your HiROM game was only 3MB, then you likely only have to do this for the first 3MB to fill out 00:8000-2F:FFFF. Same goes for 2MB and 1MB HiROMs.

As FuSoYa said, this will still leave the lower 32KB banks at 40:0000-7F:7FFF different than the original configuration, but SNES HiROM games almost never use this range. And even if you mirrored the ROM exactly, 7E:0000-7F:FFFF will be different because WRAM overlaps the address bus there, but the game won't try to access ROM there anyway originally, so that doesn't actually matter.

And also as FuSoYa said, you could go through the entire game's code and fix up any accesses to banks 00-7D. You'd need to modify an emulator to log these accesses for you and then play through the game, because I don't think it's reasonable to try and find them all yourself with a disassembly.

TL;DR: my advice to Messianic is to expand Earthbound to 8MB and mirror all 32KB upper banks. As a simple and fast test, just take the 4MB Earthbound ROM, change the mapping byte (only needed for some emulators), and then copy and paste the 4MB a second time.