Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ghost opened this issue Jul 20, 2022 · 1 comment
Open

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

ghost opened this issue Jul 20, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 20, 2022

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
Copy link
Owner

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:

  • "None" is used for NROM or any mapper limiting PRG ROM to 32KB.
  • "DirectMirror" copies the content of one PRG bank (based on mapper) to cover an entire 32KB LoROM bank.
  • "Cascade" does the same as the above but instead puts banks in sequential order within the LoROM bank, this is because some MMC3 games have code crossing into $a000. The JIT recompiler doesn't support code naturally crossing over to another bank.
  • "SramRange" (to be worked on) will cache PRG ROM in SRAM at $6000-$7fff. This method allows for more PRG banks and also supports MMC5 mapping RAM to where ROM is expected. It will allow for maxed out MMC3. It also comes at a cost of performance and memory limitation for recompiling code JIT.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant