Skip to content

Commit

Permalink
NES: DMAs interrupted during a write shouldn't start after the write
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Sep 28, 2024
1 parent de20208 commit efdf18d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Core/NES/NesCpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,17 @@ void NesCpu::StartDmcTransfer()

void NesCpu::StopDmcTransfer()
{
if(_needHalt && _dmcDmaRunning) {
_abortDmcDma = true;
_needDummyRead = false;
if(_dmcDmaRunning) {
if(_needHalt) {
//If interrupted before the halt cycle starts, cancel DMA completely
//This can happen when a write prevents the DMA from starting after being queued
_dmcDmaRunning = false;
_needDummyRead = false;
_needHalt = false;
} else {
//Abort DMA if possible (this only appears to be possible if done within the first cycle of DMA)
_abortDmcDma = true;
}
}
}

Expand Down

0 comments on commit efdf18d

Please sign in to comment.