Myself086 / Project-Nested

MIT License
493 stars 17 forks source link

MMC3 (iNES mapper 4) 1024k prg support #63

Open ghost opened 2 years ago

ghost commented 2 years ago

https://www.nesdev.org/wiki/MMC3 From the article: Some romhacks attempt to increase the available PRG-ROM size beyond the MMC3's hard 512k limit (e.g. Translation of Final Fantasy III). Full 8-bit banking registers could theoretically support up to 2048K PRG-ROM, but very few emulators implement this extension.)

This is not used officially in any games as mentioned, however certain romhacks like Mega Man IV Minus Infinity (there is a MMC3 version alongside a MMC5 one), and a few translations utilize this. It would be neat if Project Nested supported them, I tried opening them on the V1.5 release, but they just cause an exception on the tool, after downloading the code locally and changing Injector.cs in the source code, specifically the "Mapper specific settings" part (case 4:) to be WriteBanks(0x4000, 0x2000, PrgBankMirrorMode.DirectMirror, new byte[] { 0, 1, 0xfe, 0xff }); They seem to open, however the "Save Snes" button doesn't work, Just throws the error "Emulation has stopped with an unknown exception". No setting i've changed seems to fix that either. Are there any extra changes required for this to work? Will there be support for this in the future? It should be supported from what I see.

Myself086 commented 2 years ago

TL;DR: Possible in the short term if enough banks are unused. 8-bit bank possible in the long term.

The way I map NES banks is by having banks the size of the mapper be mirrored to a full 32KB within each LoROM banks on the SNES. There are 128 LoROM banks and I use some of them for the emulator. MMC3 PRG banks are 0x2000 in size, each one must be present in each possible range for the mapper. Meaning that each PRG bank on a NES game will take a full LoROM bank on SNES.

512KB of PRG ROM on MMC3 will use 64 LoROM banks out of the ~120 available. If you double the PRG ROM, 8 banks can't fit. If you lower the number of PRG banks to a non power of 2, the game won't convert correctly because part of the code assumes only using powers of 2 for PRG and CHR banks.

PrgBankMirrorMode decides how the PRG banks are mirrored within the LoROM banks. There are 4 options in the enum, one of which isn't supported yet:

The code for emulating MMC3 bank switching already supports full 8-bit banks but the way PRG banks are emulated limits the number of banks to about 120.