Sachen MMC2

From Tauwasser's Wiki
Jump to: navigation, search

Sachen's MMC2 can be used to address up to 32 Mbit of ROM. It contains provisions for SRAM access.

Pinout

Theory of Operation

Sachen's MMC2 mappers are used for multi-game N-in-1 cartridges. Individual game ROMs can be remapped so their address space logically starts at ROM bank 0x00 although the individual ROMs might be stored starting at another bank. To avoid copyright infringement the game headers are scrambled and the mapper unscrambles them when the header region is read. The mapper also includes a mechanism to switch out the Nintendo logo with a custom logo while still passing the Game Boy Bootstrap logo check. All of these features are also used by various games as a copy-protection mechanism, e.g. ROM mapping, unscrambling and the logo in VRAM are checked to determine if the game is run from an original Sachen cartridge.

Sachen added a detection method for Game Boy Color to successfully perform the logo switch, since the Game Boy Color changed the way the logo is checked.

Modes of Operation

Sachen MMC2 has three modes of operation locked DMG, locked CGB and unlocked. It defaults to locked DMG after reset.

This is used to display the Sachen logo instead of the Nintendo logo for the DMG and CGB bootstrap ROMs. Because the DMG bootstrap copies the logo first and checks after displaying it, while the CGB bootstrap checks first and only afterwards uses the actual logo, Sachen devised a mechanism to detect a CGB using the fact that the CGB bootstrap writes to WRAM, while the DMG bootstrap doesn't.

While in locked DMG and unlocked modes, RA7 will follow A7. While in locked CGB mode, the mapper will keep RA7 set.

The unlock sequence is 0x30 transitions of A15 from low to high to go from locked DMG mode to locked CGB mode. Starting on the last transition, RA7 will remain set. Going from locked CGB mode to unlocked mode requires another 0x30 transitions of A15 from low to high. Starting on the last transition, RA7 will follow A7 again. The MMC2 mapper will skip directly from locked DMG mode to locked CGB on a rising edge of CS. The A15 transition counter is reset when changing from locked DMG to locked CGB mode.

Other functionality seems to be unaffected by the lock register: switching banks and remapping work while locked.

The only way to lock the mapper after unlocking is to reset it.

Multi Memory Remap

Base ROM Bank and ROM Bank Mask Register are used for remapping 0x0000-0x7FFF to be based on a new base ROM bank.

The mapping function is:
(rb & ~mask) | (mask & rb_base)

Header Scramble

Sachen chose to scramble the header of their games. When A8 is high, while A15..A9 are low, the mapper will perform the following map:

RA0 <= A6
RA1 <= A4
RA4 <= A1
RA6 <= A0

When A8 is low or A15..A9 are not low, RAn lines will track their respective An line.

Memory Map

  • 0x0000-0x3FFF: Mapped ROM bank #0
  • 0x4000-0x7FFF: Mapped Switchable ROM bank
  • 0x8000-0xFFFF: Unmapped

Mapped here means adjusted for absolute Base ROM bank.

The RAn pins depend solely on A14, thus they will alias the 0x0000-0x7FFF region to 0x8000-0xFFFF. ROM is still only enabled when A15 is low, so no output is produced.

Registers

Write-Accessible Registers:

  • 0x0000-0x1FFF: Base ROM bank register
  • 0x2000-0x3FFF: ROM bank register
  • 0x4000-0x5FFF: ROM bank mask register

ROM Bank Register

The ROM bank register is zero-adjusted, i.e. if 0x00 is written, 0x01 will be stored. Zero-adjustment is done on all 8 input bits D7..D0. This means, that ROM Bank 0x00 can only be mapped to 0x4000-0x7FFF when the attached ROM is smaller than 32 Mbit and thus aliases 0x80 to 0x00.

D7 D6 D5 D4 D3 D2 D1 D0    0x01 @ reset
\_____________________/
      \___/      \-------- ROM Bank
        |
        \----------------- Map Enable

ROM Bank bits switch the bank mapped to 0x4000-0x7FFF. Map Enable bits are used to enable write access to the #Base ROM Bank Register and #ROM bank mask register. 0b11 means these registers can be written, other values will not grant write access.

The width of this register is based off the fact that there are eight high address lines on the SA8MBT6-2 w/o BAT PCB.

Base ROM Bank Register

This register stores the base ROM bank.

D7 D6 D5 D4 D3 D2 D1 D0    0x00 @ reset
\_____________________/
                 \-------- Base ROM Bank

This register is writable without limitation when Map Enable in the #ROM Bank Register is 0b11. Changes to this register take immediate effect.

ROM bank mask register

This register stores the ROM bank mask.

D7 D6 D5 D4 D3 D2 D1 D0    0x00 @ reset
\_____________________/
                 \-------- ROM Bank Mask

This register is writable without limitation when Map Enable in the #ROM Bank Register is 0b11. Changes to this register take immediate effect.

Behavior