DMC: Improve DMA timing after 4015 write

This commit is contained in:
Sour 2020-05-14 17:18:23 -04:00
parent c1f841b6dd
commit 650dfb35f1
2 changed files with 14 additions and 5 deletions

View file

@ -209,15 +209,24 @@ void DeltaModulationChannel::SetEnabled(bool enabled)
_needToRun = false;
} else if(_bytesRemaining == 0) {
InitSample();
_needInit = true;
//Delay a number of cycles based on odd/even cycles
//Allows behavior to match dmc_dma_start_test
if((_console->GetCpu()->GetCycleCount() & 0x01) == 0) {
_needInit = 2;
} else {
_needInit = 3;
}
}
}
bool DeltaModulationChannel::NeedToRun()
{
if(_needInit && (_console->GetCpu()->GetCycleCount() & 0x01) == 0) {
StartDmcTransfer();
_needInit = false;
if(_needInit > 0) {
_needInit--;
if(_needInit == 0) {
StartDmcTransfer();
}
}
return _needToRun;
}

View file

@ -26,7 +26,7 @@ private:
uint8_t _bitsRemaining = 0;
bool _silenceFlag = true;
bool _needToRun = false;
bool _needInit = false;
uint8_t _needInit = 0;
uint8_t _lastValue4011 = 0;