[codex] Fix MMC3 sprite-fetch IRQ timing#109
Merged
Merged
Conversation
Kautenja
marked this pull request as ready for review
June 10, 2026 16:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nes_pyto9.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_testsPYTHONPATH=/Users/christiankauten/Documents/Projects/gym-nes/nes-py /Users/christiankauten/Documents/Projects/gym-nes/gym-super-mario-bros/.venv/bin/python -m unittest discoverPYTHONPATH=/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 discovernes_pyversion9.0.1.