HDMA: Added missing condition for indirect HDMA glitch

Fixes Touge Densetsu color corruption in bike configuration screen
This commit is contained in:
Sour 2020-06-10 18:06:02 -04:00
parent 8d43594d7c
commit 01dd319c9a
2 changed files with 12 additions and 1 deletions

View file

@ -271,7 +271,7 @@ bool DmaController::ProcessHdmaChannels()
//"b. If Addressing Mode is Indirect, read two bytes from Address into Indirect Address(and increment Address by two bytes)."
if(ch.HdmaIndirectAddressing) {
if(ch.HdmaLineCounterAndRepeat == 0) {
if(ch.HdmaLineCounterAndRepeat == 0 && IsLastActiveHdmaChannel(i)) {
//"One oddity: if $43xA is 0 and this is the last active HDMA channel for this scanline, only load one byte for Address,
//and use the $00 for the low byte.So Address ends up incremented one less than otherwise expected, and one less CPU Cycle is used."
uint8_t msb = _memoryManager->ReadDma((ch.SrcBank << 16) | ch.HdmaTableAddress++, true);
@ -310,6 +310,16 @@ bool DmaController::ProcessHdmaChannels()
return true;
}
bool DmaController::IsLastActiveHdmaChannel(uint8_t channel)
{
for(int i = channel + 1; i < 8; i++) {
if((_hdmaChannels & (1 << i)) && !_channel[i].HdmaFinished) {
return false;
}
}
return true;
}
void DmaController::UpdateNeedToProcessFlag()
{
//Slightly faster execution time by doing this rather than processing all 4 flags on each cycle

View file

@ -30,6 +30,7 @@ private:
void RunHdmaTransfer(DmaChannelConfig &channel);
bool ProcessHdmaChannels();
bool IsLastActiveHdmaChannel(uint8_t channel);
bool InitHdmaChannels();
void SyncStartDma();