Skip to content

[codex] Fix MMC3 sprite-fetch IRQ timing#109

Merged
Kautenja merged 2 commits into
masterfrom
codex/smb3-mmc3-status-bar
Jun 10, 2026
Merged

[codex] Fix MMC3 sprite-fetch IRQ timing#109
Kautenja merged 2 commits into
masterfrom
codex/smb3-mmc3-status-bar

Conversation

@Kautenja

@Kautenja Kautenja commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add a mapper capability for PPU sprite-fetch address observations and enable it for MMC3.
  • Emit mapper-visible dummy sprite fetches so MMC3 A12 scanline IRQ timing stays aligned even when no sprite pixels are drawn.
  • Keep visible sprite rendering from emitting duplicate sprite-fetch address observations, which stabilizes SMB3 status-bar split baselines while sprites move.
  • Document the fix, add native PPU/MMC3 regression coverage, and bump nes_py to 9.0.1.

Root Cause

The renderer only fetched sprite pattern data when it needed sprite pixels for composition. MMC3 titles also depend on the PPU sprite-fetch phase to produce A12 transitions for scanline IRQ timing. Without those mapper-visible fetches, split-screen effects such as the Super Mario Bros. 3 status bar could select the wrong CHR bank and render garbled HUD tiles.

After adding the sprite-fetch phase, visible sprite composition still performed mapper-visible CHR reads while drawing pixels. Those extra A12 observations depended on sprite positions, so SMB3's split IRQ could drift vertically during gameplay. Sprite drawing now reads pattern bytes without producing another mapper-visible sprite-fetch address event when the mapper already requested the dedicated sprite-fetch phase.

Validation

  • build/nes-emu-debug/nes_emu_tests
  • PYTHONPATH=/Users/christiankauten/Documents/Projects/gym-nes/nes-py /Users/christiankauten/Documents/Projects/gym-nes/gym-super-mario-bros/.venv/bin/python -m unittest discover
  • PYTHONPATH=/Users/christiankauten/Documents/Projects/gym-nes/gym-super-mario-bros:/Users/christiankauten/Documents/Projects/gym-nes/nes-py /Users/christiankauten/Documents/Projects/gym-nes/gym-super-mario-bros/.venv/bin/python -m unittest discover
  • Verified editable package metadata reports nes_py version 9.0.1.

@Kautenja
Kautenja marked this pull request as ready for review June 10, 2026 16:55
@Kautenja
Kautenja merged commit 301da52 into master Jun 10, 2026
11 checks passed
@Kautenja
Kautenja deleted the codex/smb3-mmc3-status-bar branch June 10, 2026 16:55
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

Successfully merging this pull request may close these issues.

1 participant