MMC1: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
(→‎Registers: incompletely decoded)
(→‎Variants: explaination of the variants previously on the board specific pages comes here.)
Line 118: Line 118:


== Variants ==
== Variants ==
The [[SUROM]], [[SOROM]], and [[SXROM]] boards are extensions of [[SNROM]], which has CHR RAM and PRG RAM.
Because CHR RAM doesn't need bankswitching, these boards use the CHR bank select lines to switch different things:
*SUROM uses the upper CHR bank select line coming out of the mapper to control the upper address line of its 512KB PRG ROM.
*SOROM uses a similar method, using the second-highest CHR bank select line to choose between two 8KB PRG RAM chips.
*SXROM is a combination of SOROM and SUROM, addressing both 512KB of PRG ROM and 32KB of PRG RAM.


In these scenarios, however, both CHR bank registers must be set to the same value (or the CHR bank size must be set to 8KB), or the PRG ROM/RAM will be bankswitched as the PPU renders, causing disastrous results.
Because the higher CHR lines aren't used when the MMC1 mapper is used with a 8KB CHR RAM, those lines are sometimes put to other uses depending on the board :
 
=== SNROM ===
 
==== CHR bank 0 (internal, $A000-$BFFF) ====
4bit0
-----
ExxxC
|  |
|  +- Select 4 KB CHR RAM bank at PPU $0000 (ignored in 8 KB mode)
+----- PRG RAM disable (0: enable, 1: open bus)
 
==== CHR bank 1 (internal, $C000-$DFFF) ====
4bit0
-----
ExxxC
|  |
|  +- Select 4 KB CHR RAM bank at PPU $1000 (ignored in 8 KB mode)
+----- PRG RAM disable (0: enable, 1: open bus) (ignored in 8 KB mode)
 
Both the <code>E</code> bit and the <code>R</code> bit (in standard MMC1 registers) should be clear in order for the PRG RAM to be writable or readable. This bit is more "reliable" on authentic hardware as it is implemented even in older boards with older MMC1's, while the <code>R</code> bit was only introduced later.
But because the <code>E</code> bit wasn't absolutely confirmed by the homebrew community until October 2010,[http://nesdev.parodius.com/bbs/viewtopic.php?t=7045] emulators tend not to implement it.
 
=== SOROM, SUROM and SXROM ===
 
==== CHR bank 0 (internal, $A000-$BFFF) ====
4bit0
-----
PSSxC
||| |
||| +- Select 4 KB CHR RAM bank at PPU $0000 (ignored in 8 KB mode)
|++--- Select 8 KB PRG RAM bank
+----- Select 256 KB PRG ROM bank
 
==== CHR bank 1 (internal, $C000-$DFFF) ====
4bit0
-----
PSSxC
||| |
||| +- Select 4 KB CHR RAM bank at PPU $1000 (ignored in 8 KB mode)
|++--- Select 8 KB PRG RAM bank (ignored in 8 KB mode)
+----- Select 256 KB PRG ROM bank (ignored in 8 KB mode)
 
The SOROM board only implement the upper <code>S</code> bit, while the SUROM board only implements the <code>P</code> bit.
 
The 256 KB PRG bank selection applies to all the PRG area, ''including the supposedly "fixed" bank''.
 
In 4KB CHR bank mode, the <code>P</code>, <code>S</code> and <code>E</code> bits in both CHR bank registers must be set to the same values, or the PRG ROM and/or RAM will be bankswitched/enabled as the PPU renders, in a similar fashion as [[MMC3#Hardware|MMC3]]'s scanline counter. As there is not much of a reason to use 4 KB bankswitching with CHR RAM, it is wise for programs to just set 8 KB bankswitching mode in the [[MMC1#Control (internal, $8000-$9FFF)|Control register]].


== References ==
== References ==

Revision as of 18:01, 14 November 2010

The Nintendo MMC1 is a mapper ASIC used in Nintendo's SxROM and NES-EVENT Game Pak boards. Most common SxROM boards are assigned to iNES Mapper 001. This chip first appeared in the summer of 1987.

Overview

  • PRG ROM size: Up to 256 KB depending on board
  • PRG ROM bank size: 16 KB or 32 KB
  • PRG RAM: Up to 8 KB
  • CHR capacity: Up to 128 KB ROM or 8 KB RAM
  • CHR bank size: 8 KB or 4 KB
  • Nametable mirroring: Controlled by mapper
  • Subject to bus conflicts: No

Banks

  • CPU $6000-$7FFF: 8 KB PRG RAM bank, fixed
  • CPU $8000-$BFFF: 16 KB PRG ROM bank, either switchable or fixed to the first bank
  • CPU $C000-$FFFF: 16 KB PRG ROM bank, either fixed to the last bank or switchable
  • PPU $0000-$0FFF: 4 KB switchable CHR bank
  • PPU $1000-$1FFF: 4 KB switchable CHR bank

Through writes to the MMC1 control register, it is possible for the program to swap the fixed and switchable PRG ROM banks or to set up 32 KB PRG bankswitching (like BNROM), but most games use the default setup, which is similar to that of UxROM.

Registers

Unlike almost all other mappers, the MMC1 is configured through a serial port in order to reduce pin count. CPU $8000-$FFFF is connected to a common shift register. After every fifth write, the MMC1 copies the shift register into the internal register corresponding to the address. Only on the fifth write does the address matter, and even then, only bits 14 and 13 of the address matter because the mapper registers are incompletely decoded like the PPU registers. After the fifth address write, the shift register is reset, so a write to the shift register with hi bit on to reset it is not needed.

A program's reset code will reset the mapper first by writing a value of $80 through $FF to any address in $8000-$FFFF. To do any bankswitching, it will execute code similar to the following:

;
; Sets the switchable PRG ROM bank to the value of A.
;
setPRGBank:
  sta $E000
  lsr a
  sta $E000
  lsr a
  sta $E000
  lsr a
  sta $E000
  lsr a
  sta $E000
  rts

But because only the fifth write sets the destination register, the following equivalent (if obfuscated) subroutine changes the PRG ROM bank in the same manner:

setPRGBank:
  sta $8765
  lsr a
  sta $FACE
  lsr a
  sta $BA11
  lsr a
  sta $AD2E
  lsr a
  sta $EAD5
  rts

Load register ($8000-$FFFF)

7  bit  0
---- ----
Rxxx xxxD
|       |
|       +- Data bit to be shifted into shift register, LSB first
+--------- 1: Reset shift register and write Control with (Control OR $0C),
              locking PRG ROM at $C000-$FFFF to the last bank.

Control (internal, $8000-$9FFF)

4bit0
-----
CPPMM
|||||
|||++- Mirroring (0: one-screen, lower bank; 1: one-screen, upper bank;
|||               2: vertical; 3: horizontal)
|++--- PRG ROM bank mode (0, 1: switch 32 KB at $8000, ignoring low bit of bank number;
|                         2: fix first bank at $8000 and switch 16 KB bank at $C000;
|                         3: fix last bank at $C000 and switch 16 KB bank at $8000)
+----- CHR ROM bank mode (0: switch 8 KB at a time; 1: switch two separate 4 KB banks)

CHR bank 0 (internal, $A000-$BFFF)

4bit0
-----
CCCCC
|||||
+++++- Select 4 KB or 8 KB CHR bank at PPU $0000 (low bit ignored in 8 KB mode)

MMC1 can do CHR banking in 4KB chunks. Known carts with CHR RAM have 8 KiB, so that makes 2 banks. RAM vs ROM doesn't make any difference for address lines. For carts with 8 KiB of CHR (be it ROM or RAM), MMC1 follows the common behavior of using only the low-order bits: the bank number is in effect ANDed with 1.

CHR bank 1 (internal, $C000-$DFFF)

4bit0
-----
CCCCC
|||||
+++++- Select 4 KB CHR bank at PPU $1000 (ignored in 8 KB mode)

PRG bank (internal, $E000-$FFFF)

4bit0
-----
RPPPP
|||||
|++++- Select 16 KB PRG ROM bank (low bit ignored in 32 KB mode)
+----- PRG RAM chip enable (0: enabled; 1: disabled; ignored on MMC1A)

Hardware

At least 6 different versions of the MMC1 are known to exist: MMC1, MMC1A, MMC1B1, MMC1B2, MMC1B3, and MMC1C. The known differences are as follows:

  • MMC1A: PRG RAM is always enabled
  • MMC1B: PRG RAM is enabled by default.
  • MMC1C: PRG RAM is disabled by default.

The MMC1 most commonly exists in a 24-pin shrink-DIP package.

Boards using an MMC1 may contain a battery connected to the PRG RAM's power line to preserve the data. Boards doing so will allow extra circuitery to be used, with 2 diodes and 2 resistors. A diode is needed from both voltage sources : The battery and the NES 5V, so that one cannot supply current to the other, and there is a resistor in series with the battery so that no current is drained from the battery when 5V is present. A pull-down resistor is needed on the CE line so that the SRAM is disabled when the MMC1 isn't powered. Finally, the battery powered SRAMs have an additional larger coupling capacity to make sure voltage transitions are smooth. Very early NES-SNROM-03 and lower revisions lacks that capcity, and saves are lost much more easily on those boards.

Nintendo transitioned from the original MMC1 (manufactured by ROHM) to the MMC1A (manufactured probably by Ricoh) around the 39th week of 1988. (Based on comparison of otherwise identical SMB/DH/WCTM carts from 38th and 39th weeks of '88)

Variants

Because the higher CHR lines aren't used when the MMC1 mapper is used with a 8KB CHR RAM, those lines are sometimes put to other uses depending on the board :

SNROM

CHR bank 0 (internal, $A000-$BFFF)

4bit0
-----
ExxxC
|   |
|   +- Select 4 KB CHR RAM bank at PPU $0000 (ignored in 8 KB mode)
+----- PRG RAM disable (0: enable, 1: open bus)

CHR bank 1 (internal, $C000-$DFFF)

4bit0
-----
ExxxC
|   |
|   +- Select 4 KB CHR RAM bank at PPU $1000 (ignored in 8 KB mode)
+----- PRG RAM disable (0: enable, 1: open bus) (ignored in 8 KB mode)

Both the E bit and the R bit (in standard MMC1 registers) should be clear in order for the PRG RAM to be writable or readable. This bit is more "reliable" on authentic hardware as it is implemented even in older boards with older MMC1's, while the R bit was only introduced later. But because the E bit wasn't absolutely confirmed by the homebrew community until October 2010,[1] emulators tend not to implement it.

SOROM, SUROM and SXROM

CHR bank 0 (internal, $A000-$BFFF)

4bit0
-----
PSSxC
||| |
||| +- Select 4 KB CHR RAM bank at PPU $0000 (ignored in 8 KB mode)
|++--- Select 8 KB PRG RAM bank
+----- Select 256 KB PRG ROM bank

CHR bank 1 (internal, $C000-$DFFF)

4bit0
-----
PSSxC
||| |
||| +- Select 4 KB CHR RAM bank at PPU $1000 (ignored in 8 KB mode)
|++--- Select 8 KB PRG RAM bank (ignored in 8 KB mode)
+----- Select 256 KB PRG ROM bank (ignored in 8 KB mode)

The SOROM board only implement the upper S bit, while the SUROM board only implements the P bit.

The 256 KB PRG bank selection applies to all the PRG area, including the supposedly "fixed" bank.

In 4KB CHR bank mode, the P, S and E bits in both CHR bank registers must be set to the same values, or the PRG ROM and/or RAM will be bankswitched/enabled as the PPU renders, in a similar fashion as MMC3's scanline counter. As there is not much of a reason to use 4 KB bankswitching with CHR RAM, it is wise for programs to just set 8 KB bankswitching mode in the Control register.

References

See also