{{Infobox iNES mapper
|name=MMC5
|name2=ExROM
|company=Nintendo, Koei, others
|mapper=5
|nescartdbgames=15
|complexity=ASIC
|boards=EKROM, ELROM,
ETROM, EWROM
|pinout=MMC5 pinout
|prgmax=1024K
|prgpage=8K, 16K, or 32K
|wrammax=128K
|wrampage=8K ($6000-$DFFF),
16K (only $8000-$BFFF
at PRG mode 1/2)
|chrmax=1024K
|chrpage=1K, 2K, 4K, or 8K
|mirroring=arbitrary, up to 3 source
nametables (plus fill mode)
|busconflicts=No
|irq=Yes
|audio=[[MMC5_audio|Yes]]
}}
{{nesdbbox
|ines|5|iNES 005
|unif_wild|-E%ROM|ExROM
|unif_wild|EKROM|EKROM
|unif_wild|ELROM|ELROM
|unif_wild|ETROM|ETROM
|unif_wild|EWROM|EWROM
}}
[[Category:Nintendo licensed mappers]][[Category:Mappers using $4020-$5FFF]][[Category:Mappers with large PRG RAM]][[Category:Mappers with scanline IRQs]][[Category:Mappers with single-screen mirroring]][[Category:Mappers with cycle IRQs]][[Category:Mappers triggering on reads]]
The '''Nintendo MMC5''' is a [[mapper]] [[:Category:ASIC mappers|ASIC]] used in Nintendo's [[ExROM]] Game Pak boards. All MMC5 boards are assigned to '''mapper 5'''.
Example games:
* ''Castlevania 3''
* ''Just Breed''
* ''Uncharted Waters''
* ''Romance of the Three Kingdoms II''
* ''Laser Invasion''
* ''Metal Slader Glory''
* ''Uchuu Keibitai SDF''
* ''Shin 4 Nin Uchi Mahjong - Yakuman Tengoku''
* ''Bandit Kings of Ancient China''
* ''SimCity'' (Prototype)
The first game to use this chip (''Nobunaga's Ambition II'') was released in February 1990. The [http://bootgod.dyndns.org:7777/profile.php?id=3169 date codes on components on early released cartridges] show that manufacturing had started at the end of 1989.
A later '''[[#MMC5A|MMC5A]]''' revision was introduced with a few extra features, but all released games do not rely on these features and are compatible with the original MMC5.
== Overview ==
The MMC5 is the most elaborate mapper ASIC Nintendo made for the NES and Famicom.
It supports a kitchen sink of features, including:
* 4 PRG ROM switching modes
* 4 CHR ROM switching modes
* Up to 128KB of WRAM, mappable not only at $6000-$7FFF but also within $8000-$DFFF
** Supports either one chip (up to 128KB) or two chips (up to 32KB each)
* An 8 bit by 8 bit multiplier with a 16 bit result for performing quick calculations
* Scanline detection with counter and configurable IRQ
* Frame detection with status bit
* The ability to use different CHR banks for background and 8x16 sprites (allowing 256 unique 8x16 sprite tiles, independent of the background).
* 1024 bytes of on-chip memory, which can be used for 4 different purposes:
** An extra general-use nametable
** Attribute and tile index expansion - address 16384 background tiles at once, and allow each individual 8x8 tile to have its own palette setting
** Vertical split-screen
** Extra RAM for storing program variables
* Three extra sound channels
** Two pulse channels, identical to those in the NES APU (except lacking pitch sweeps).
** An 8-bit RAW PCM channel
* A 'fill mode' nametable, which can be instantly set to contain a specific tile in a specific color (useful for screen transitions)
* System reset detection
** Triggered by a positive or negative gap in M2 of at least 11.2 usec.
** Also triggered and latched by absence of AVcc.
** After reapplying AVcc, another gap in M2 is sometimes necessary to clear the latch.
** This feature resets some, but not all, states of the MMC5.
** The PRG RAM +CE pin is a direct reflection of system reset detection state.
** Reduces the need to hold the Reset Button while turning off the power in games with battery save."Why Your Game Paks Never Forget". ''Nintendo Power'' #20 (March 1991), pp. 28-31.
== Banks ==
The MMC5 provides 4 distinct banking modes for both PRG ROM and CHR ROM.
=== PRG mode 0 ===
* CPU $6000-$7FFF: 8 KB switchable PRG RAM bank
* CPU $8000-$FFFF: 32 KB switchable PRG ROM bank
=== PRG mode 1 ===
* CPU $6000-$7FFF: 8 KB switchable PRG RAM bank
* CPU $8000-$BFFF: 16 KB switchable PRG ROM/RAM bank
* CPU $C000-$FFFF: 16 KB switchable PRG ROM bank
=== PRG mode 2 ===
* CPU $6000-$7FFF: 8 KB switchable PRG RAM bank
* CPU $8000-$BFFF: 16 KB switchable PRG ROM/RAM bank
* CPU $C000-$DFFF: 8 KB switchable PRG ROM/RAM bank
* CPU $E000-$FFFF: 8 KB switchable PRG ROM bank
=== PRG mode 3 ===
* CPU $6000-$7FFF: 8 KB switchable PRG RAM bank
* CPU $8000-$9FFF: 8 KB switchable PRG ROM/RAM bank
* CPU $A000-$BFFF: 8 KB switchable PRG ROM/RAM bank
* CPU $C000-$DFFF: 8 KB switchable PRG ROM/RAM bank
* CPU $E000-$FFFF: 8 KB switchable PRG ROM bank
=== CHR mode 0 ===
* PPU $0000-$1FFF: 8 KB switchable CHR bank
=== CHR mode 1 ===
* PPU $0000-$0FFF: 4 KB switchable CHR bank
* PPU $1000-$1FFF: 4 KB switchable CHR bank
=== CHR mode 2 ===
* PPU $0000-$07FF: 2 KB switchable CHR bank
* PPU $0800-$0FFF: 2 KB switchable CHR bank
* PPU $1000-$17FF: 2 KB switchable CHR bank
* PPU $1800-$1FFF: 2 KB switchable CHR bank
=== CHR mode 3 ===
* PPU $0000-$03FF: 1 KB switchable CHR bank
* PPU $0400-$07FF: 1 KB switchable CHR bank
* PPU $0800-$0BFF: 1 KB switchable CHR bank
* PPU $0C00-$0FFF: 1 KB switchable CHR bank
* PPU $1000-$13FF: 1 KB switchable CHR bank
* PPU $1400-$17FF: 1 KB switchable CHR bank
* PPU $1800-$1BFF: 1 KB switchable CHR bank
* PPU $1C00-$1FFF: 1 KB switchable CHR bank
== Registers ==
=== Sound ($5000-$5015) ===
For details on sound operation, see [[MMC5 audio]]
=== NES internal state monitoring ===
All of these registers overlay various registers that are already used inside the NES, and are fully decoded. A game could write to a mirror of a PPU register to get the MMC5 out of sync, for example, writing to mirrors of $2000 to make 8x16 sprites use the same banks with the nametable like other mappers (which is useful for [[mapper hack|mapper hacks]]).
==== 8x16 mode enable ($2000 = [[PPUCTRL]]) ====
*Write only
*Reset detection not used
7 bit 0
---- ----
xxZx xxxx
|
+------- Sprite size (0: 8x8 pixels; 1: 8x16 pixels)
Only when Z is set and at least one E bit is set does the MMC5 [[#CHR_Bankswitching_.28.245120-.245130.29|draw 8x16 sprites from eight independent banks]].[https://forums.nesdev.org/viewtopic.php?p=229375#p229375 krzysiobal's RE notes]
==== PPU Data Substitution Enable ($2001 = [[PPUMASK]]) ====
*Write only
*Reset detection not used
7 bit 0
---------
xxxE Exxx
| |
+-+---- 1,2,3: Substitutions enabled; 0: substitutions disabled
The MMC5 listens to writes to PPUMASK ($2001). When it sees that both E bits are cleared, it disables its ability to make substitutions on the PPU data bus. This includes disabling:
* Independent bank 8x16 sprite mode
* Extended attribute mode
* Vertical split mode
The MMC5 only listens to the fully decoded address $2001, so this can be tested by using the PPU’s mirrors of this register. For example, writing to register $2009 will be heard by the PPU but not the MMC5. It is not clear if that could have a practical use beyond test purposes.
When the MMC5 sees $00 written to $2001, and then the PPU’s rendering gets enabled via a mirror of $2001, the MMC5 still counts scanlines and can generate scanline interrupts even though it thinks $2001 is still disabled. The transition from disabled to enabled resets the scanline counter.
Driving pin 92 low similarly disables substitutions. Because no scanline interrupts occur with pin 92 held low, it seems to hold the scanline counter in reset.
==== Scanline Counter Reset ($2002 = [[PPUSTATUS]], read only) ====
*MMC5 stores the value read from the PPU
*Reset detection not used
7 bit 0
---------
Exxx xxxx
|
+--------- 1: trigger scanline counter reset; 0: no effect
==== Unknown ($2005 = [[PPUSCROLL]]) ====
*Write only
*Reset detection is used
7 bit 0
---------
xxxx x000 Reset Value
---- ----
xxxx xYYY
|||
+++- CHR A2,A1,A0
The letterless MMC5 captures the low 3 bits of the second write to PPUSCROLL into a 3-bit counter. The value of the counter is output onto CHR A2,A1,A0 at certain times. It is not known how or when the counter does that. Tests using a mirror of PPUSCROLL on MMC5A were expected to cause rolled tiles, but that result was observed not to be true. It should be retested more carefully to confirm.
Second write tracking is resynced each time register $2002 is read, in the same way that the PPU clears its ‘w’ address latch.
==== Unknown ($2006 = [[PPUADDR]], MMC5A only) ====
Power analysis has detected that the MMC5A monitors writes here, and it has been confirmed by analyzing the MMC5A die. Though none of the values written to $2006 are stored or used, it implements its own 2nd write tracking. The 2nd write tracking resyncs each time $2002 is read, similar to the MMC5 and 5A’s $2005 write tracking. When the 2nd write has been reached, it appears to wait until the next h-blank, then reload the 3-bit counter from the stored $2005 fine vertical scroll value.
The purpose of this is not yet known.
==== Scanline Counter Reset ($4014 = [[OAMDMA]]) ====
Writes to OAMDMA trigger a reset of the scanline counter. The value written is not captured by the MMC5.
=== Configuration ===
==== PRG mode ($5100) ====
*Write only
*Reset detection is used
7 bit 0
---- ----
xxxx xx11 Reset Value
---- ----
xxxx xxPP
||
++- Select PRG banking mode
* 0 - One 32KB bank
* 1 - Two 16KB banks
* 2 - One 16KB bank ($8000-$BFFF) and two 8KB banks ($C000-$DFFF and $E000-$FFFF)
* 3 - Four 8KB banks
''Castlevania III'' uses mode 2, which is similar to [[VRC6]] PRG banking. All other games use mode 3. The Koei games never write to this register, apparently relying on the MMC5 defaulting to mode 3 at power on.
==== CHR mode ($5101) ====
*Write only
*Reset detection not used
7 bit 0
---- ----
xxxx xxCC
||
++- Select CHR banking mode
* 0 - 8KB CHR pages
* 1 - 4KB CHR pages
* 2 - 2KB CHR pages
* 3 - 1KB CHR pages
CHR mode always applies to sprite pattern fetches. However, CHR mode only applies to background pattern fetches during normal rendering. When extended attributes or vertical split are being rendered, the CHR bank size for background pattern fetches is fixed to 4kB.
CHR mode affects the mapping of the bits when writing to the 10-bit CHR bank registers $5120-512B.
''Metal Slader Glory'' uses 4KB CHR pages. All other games use 1KB pages.
==== PRG RAM Protect 1 ($5102) ====
*Write only
*Reset detection is used
7 bit 0
---- ----
xxxx xx01 Reset Value
---- ----
xxxx xxWW
||
++- RAM protect 1
In order to enable writing to PRG RAM, this must be set to binary '10' (e.g. $02).
==== PRG RAM Protect 2 ($5103) ====
*Write only
*Reset detection is used
7 bit 0
---- ----
xxxx xx10 Reset Value
---- ----
xxxx xxWW
||
++- RAM protect 2
In order to enable writing to PRG RAM, this must be set to binary '01' (e.g. $01).
==== Internal extended RAM mode ($5104) ====
*Write only
*Reset detection is used
*MMC5 additionally keeps track whether this register has ever been written since reset, purpose unknown.
7 bit 0
---- ----
xxxx xx11 Reset Value
---- ----
xxxx xxXX
||
++- Specify extended RAM usage
{| class=wikitable
! $5104 !! CPU Access ($5C00-$5FFF)
during blanking !! CPU Access ($5C00-$5FFF)
during rendering !! PPUDATA Access ($2000-$2FFF){{sup|(1)}}
during blanking !! Available as
Nametable !! Enable Extended
Attribute Mode
|-
! %00
| {{no}}{{sup|(3)}} ||