512KB ROM - Nestopia/FCEUX won't run it

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
512KB ROM - Nestopia/FCEUX won't run it
by on (#65470)
My current project is using 128KB SXROM + MMC1 configuration but I've tried to increase the ROM size to 512KB. However, neither of the two emulators I tried will run it now - it loads fine but no run.

I can create a 256KB version which works fine but anything bigger doesn't work.

Is there a limitation to ROM size in this configuration? Is there anything special I have to do/set in the iNES header?

by on (#65471)
OK, I read some more and found that MMC1 is limited to 256KB ROM unless using the SUROM/SOROM/SXROM, in which case you need to employ bit 4 of the MMC1 CHR Bank register.

http://wiki.nesdev.com/w/index.php/SXROM

I'm not entirely surely how this should be approached, I tried setting that bit when I write the CHR Bank register but it doesn't seem to make any difference.

by on (#65479)
MMC1 starts up in a random bank. If you use the "Barbie stub" in each bank to reset the mapper to a fixed bank (as seen here), that still won't reset the CHR bit. You need to have some of your init code in both bank 15 and bank 31, or the CPU will start executing data after your code sets the bank.

Have you tried tracing it in FCEUX's debugger?

by on (#65491)
Hmmm. I'm struggling a bit with setting all that up in my ca65 config.

by on (#65494)
The view from FCEUX's debuger:

Image

by on (#65500)
Look at the status bar: "Offset 0x04000F"

iNES offset 0x04000F is PRG ROM offset 0x03FFFF. Under 16 KiB banks, the bank number is floor(0x03FFFF / 16384) = 15. Your MMC1 powered on in bank 15, where your ROM has nothing but $FF bytes. The NES did JMP ($FFFC), as it always does on reset, and read the address $FFFF out of $FFFC and $FFFD. Then it jumped to $FFFF, which also had a $FF byte, which is an unofficial instruction.

by on (#65504)
Got it! :D

Jesus, that was some messing about.

It was fairly easy to get the reset working but what caught me out for a while was that it seemed to be jumping to empty banks when I was switching PRG bank in the code.

Until I realised that because I was running with the second "bank" of PRG ROM banks ($10-$1F), that I had to move my code to those banks too.

by on (#65505)
Remember: you need the 16-byte stub in all 32 banks, and you need code to set the initial PRG bank in both bank 15 and bank 31.

SUROM looks like it's designed for gluing two 256 KiB games together, even though it was only used for single games (and only two of them at that). Do more "ordinary" MMC1 games use the fixed bank at $C000, or do they use 32 KiB banks?

by on (#65506)
Oh noes.

After all that, the experiment didn't actually work.

Bunnyboy thought that using a 512KB ROM would make PowerPak use a 32KB NVRAM file properly. But it doesn't :(