Repository navigation
Conversation
DirectREU drives the bus through the same DMA_* state SetUpDMA leaves for a host DMA job. The C64 keeps running after a job is set up and before its transfer starts (WriteC64Mem's and ReadC64Mem's safe-start window, and the whole wait for a locked WriteC64Spans slice's sample store), so a program that starts an REU transfer then moves the job's bytes to the REU's C64 address and length instead of the host's. DirectREU now puts the job state back before it returns.
It was refused whenever REU emulation was set up, because an REU transfer between slices overwrote the job's DMA state. The previous commit closes that, so the refusal only cost the slicing: with Special IO set to an REU, a host streaming to an NMI sample player fell back to whole WriteC64Mem halts, which drop NMIs and make the audio stutter. A paused C64 is still refused, since the first slice would resume it.
An immediate REU transfer cleared fBusSnoop whoever held it, so the sample store watch a locked WriteC64Spans job runs on was dropped by the first transfer the C64 started, and every later slice waited out its gap and started unlocked. It now clears the slot only when its own FF00 check holds it. The job-state test set up a write job and ran a C64-to-REU... transfer that also left DMA_RnW false, so dropping the DMA_RnW restore passed; the job is now a read.
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 changed and why
With Special IO set to an REU,
WriteC64Spanswas refused at its token ("REU emulation is running") for as long as the handler was installed. A host streaming to an NMI sample player then fell back to wholeWriteC64Memhalts, which drop NMIs: the audio stutters, and it plays cleanly as soon as the REU is turned off.The refusal guarded a real race.
DirectREU()runs fromisrPHI2when the C64 starts a transfer, and it drives the bus through the sameDMA_*stateSetUpDMAleaves for a host job. The C64 keeps running between a job's setup and its transfer: the safe-start window of everyPerformDMA(WriteC64MemandReadC64Memincluded, which were never refused), and the whole wait for a locked slice's sample store. A transfer started there moved the host's bytes to the REU's address and length.DirectREU()now saves the job'sDMA_RnW,DMA_FixC64Addr,DMA_Length,DMA_CountandDMA_StartAddr, and restores them before it returns.fBusSnoopwhen another owner holds it. It used to drop the sample store watch a locked job runs on.WriteC64SpansCommandrefuses only a paused C64 now.docs/ControlComms.mdsays so, and notes that earlier firmware also refused while REU emulation was set up.What to look at
The save in
DirectREU()runs before its PHI2-falling wait on the IO2 write cycle, next to theDMA_*setup that was already there. It is five loads.How it was verified
npm test: 355 of 355 pass.reu_trpage_harnesstests drive an REU transfer through the IO2 handler. The job-state test fails if any one of the five restores is removed (tried one at a time). The bus-snoop test fails with the old unconditional clear.