Skip to content

Support MMC3 mapper for CHR bank switching (crypto sample) #306

@jonathanpeppers

Description

@jonathanpeppers

Problem

The crypto sample title screen shows "CRYPTO" correctly but the menu text below ("1 Player", "2 Players", "Credits", "2016") is garbled. The text tiles display maze graphics instead of letter glyphs.

Root Cause

The reference crypto.nes ROM uses MMC3 (mapper 4) with mid-frame CHR bank switching. During the text area scanlines, MMC3 swaps a 2KB CHR page containing font tiles into pattern table 1. Our transpiler only supports NROM (mapper 0) which has a fixed 8KB CHR ROM -- no bank switching is possible.

The font glyphs exist in the second 8KB of the reference ROM's 16KB CHR (pages 9-11 at $2400-$2FFF), but since NROM can only address 8KB of CHR, those tiles are inaccessible. The tile indices used by the nametable for text ($04-$42) show maze/decoration graphics from the first 8KB instead of the font glyphs from the second 8KB.

What's Needed

Support for MMC3 (mapper 4) in the transpiler, specifically:

  1. CHR bank switching -- bank_bg()/bank_spr() should dynamically remap 1KB or 2KB CHR pages at runtime via MMC3 registers ($8000-$8001)
  2. Scanline IRQ -- MMC3 can trigger an IRQ at a specific scanline to swap CHR banks mid-frame (used by crypto to show fonts in the text area and maze tiles elsewhere)
  3. 16KB+ CHR ROM support -- the ROM header should declare mapper 4 and support more than 8KB of CHR data

Current State

The crypto sample transpiles and runs on NROM with the correct maze graphics, sprites, palette, and game logic. Only the menu text is affected by this limitation. The game is playable (press Start to begin).

Context

The crypto sample (PR #211) is a 2,270-line C# port of the 8bitworkshop dungeon crawler. The reference ROM (purchased from itch.io) uses MMC3 for CHR bank switching.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions