Return the VIC-II's first-phase byte for reads nothing answers - #341
Merged
highbyte merged 1 commit intoSep 18, 2026
Merged
Conversation
In the first phase of every cycle the VIC-II reads memory, and that byte stays on the data bus into the second phase unless something else drives it. A CPU read of the I/O 1 and I/O 2 areas ($DE00-$DFFF) with no cartridge answering now returns it instead of whatever was last stored there, and colour RAM reads take their high four bits from it, since the colour RAM drives only the low four. Which byte depends on the cycle: each sprite's pointer access, then the middle byte of its row if its DMA is on or an idle access if not; refresh accesses in cycles 11-15; graphics accesses in cycles 16-55 ($3FFF, or $39FF with ECM, in idle state); idle accesses ($3FFF) elsewhere. VICE's phi1timing test programs read $DEAD on every cycle of a line and now pass on PAL and NTSC. Cartridge tests that expected an unanswered I/O read to give back the stored value now expect the bus byte.
|
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.



What
In the first phase of every cycle the VIC-II reads memory, and that byte stays on the data bus into the second phase unless something else drives it. Two kinds of CPU read now see it:
$DE00-$DFFF) with no cartridge answering the address. They returned whatever had last been written there (I/O storage), which a real C64 does not have.Which byte depends on the cycle of the read:
$3FFF$3F00+ refresh counter (reset to$FFin line 0, counted down per access)$3FFF($39FFwith ECM); display state the character or bitmap data$3FFFOn the 6567R8 (NTSC, 65 cycles) the sprite accesses start a cycle later (sprite 0 in cycle 59).
How
Vic2.FirstPhaseBusByte()brings the VIC-II to the cycle of the access in progress and derives the byte from the cycle, the sprite DMA state and the display state. The cartridge slot uses it as its fallback reader for$DE00-$DFFF(writes still go to I/O storage), andColorRAMLoadtakes its high four bits from it.Five cartridge and SwiftLink unit tests expected an unanswered I/O read (a write-only register, a detached SwiftLink) to give back the stored value; they now expect the bus byte. As on hardware, a program probing for an REU by writing a register and reading it back no longer finds one that is not there.
Verification
phi1timing/phi1timingandphi1timing_ntsc, which read$DEADon every cycle of a line and compare each byte with the expected access.colorram/test(reads colour RAM, masks to the low four bits) still passes. No other result changed.Vic2FirstPhaseBusByteTests(17 cases): pointer, slot, refresh, graphics and idle accesses by cycle, ECM for idle graphics accesses only, the refresh counter, a fetching sprite's middle byte, display-state character data, and colour RAM's high bits.