Read the sprite enable bit at the display decision, time the sprite events per model, take the VIC bank from CIA 2's port pins - #332
Merged
highbyte merged 1 commit intoSep 16, 2026
Conversation
…vents per model, take the VIC bank from CIA 2's port pins, add the SpriteEnable sample The display decision in cycle 58 asks for the sprite's enable bit as it stands in that cycle, not only for DMA and Y (the VIC-II article's rule 4 omits it): a sprite switched on for the two compares and off again before cycle 58 is fetched but not shown. The compares and the decision are one cycle later on the 6567R8's 65-cycle line (56, 57 and 59), so the sprite event cycles now follow sprite 0's pointer cycle per model. A DMA the second compare starts leaves sprite 0's first data byte to the CPU (its fetch is two cycles on, one short of what BA needs), so that byte reads $FF. The display is cleared when the cycle-58 decision finds the DMA off, not in cycle 16 when the DMA ends, so a sprite whose Y is rewritten to its last line restarts there. A sprite 3-7 shown on the line its DMA starts carries what its fetch slot read while the DMA was off: $FF, the idle byte, $FF. The VIC bank follows the levels on CIA 2 port A's pins: a bit the direction register makes an input floats high through its pull-up, so a program that selects the bank through $DD02 gets the bank the pins carry, not the bytes written. The snapshot restore derives the bank the same way. The SpriteEnable sample shows the enable timing, the $FF byte and the restart on both models.
|
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
$DD02got bank 3 from us instead of bank 0. The snapshot restore derives the bank the same way.Verification
VICE harness, 274 tests on both models: banking and spriteenable 1 and 2 on PAL and NTSC go from DIFF to MATCH, spriteenable 4 and the three spritebug tests improve, nothing gets worse. 194 tests match.
Games A/B against the integration branch: identical for Commando (two snapshots, D64 PAL and NTSC) and Giana Sisters (D64 PAL and NTSC).
Demo A/B: eleven demos identical; Chars Sucks, which selects its bank through
$DD02, now shows its sprite logo and scroller (its ghost-byte shading remains a follow-up).The sample's write cycles were verified with a register trace on both models (line 212 index 54/55, line 208 index 55-56/56-57, line 233 index 55-56/56-57) and the run dumps (sprite 0's first byte $FF, sprite 1 clean, sprite 2 never displayed, sprite 1 restarted with row 0).
Whole solution builds; full test suite passes (the two wall-clock timing tests pass when rerun alone).
Timing (For Your Sprites Only, 600 frames, three repeats, two alternating rounds, MacBook Air M1): no measurable change against the integration branch in any renderer configuration. Sequencer with per-line sprites 1297-1322 vs 1310-1332 us/frame, the other four configurations likewise within the round-to-round noise.