From a230f67567eaa3f7b4f59928e1e832cce6b67d71 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Tue, 10 Apr 2018 16:44:12 -0500 Subject: [PATCH] Reorder HDMA to do transfer 0-7, then update indirect address 0-7. --- dma.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/dma.cpp b/dma.cpp index e9fef3ea..d5a6e71d 100644 --- a/dma.cpp +++ b/dma.cpp @@ -1423,13 +1423,14 @@ void S9xStartHDMA (void) uint8 S9xDoHDMA (uint8 byte) { - struct SDMA *p = &DMA[0]; + struct SDMA *p; uint32 ShiftedIBank; uint16 IAddr; bool8 temp; int32 tmpch; - int d = 0; + int d; + uint8 mask; CPU.InHDMA = TRUE; CPU.InDMAorHDMA = TRUE; @@ -1440,7 +1441,7 @@ uint8 S9xDoHDMA (uint8 byte) // XXX: Not quite right... ADD_CYCLES(Timings.DMACPUSync); - for (uint8 mask = 1; mask; mask <<= 1, p++, d++) + for (mask = 1, p = &DMA[0], d = 0; mask; mask <<= 1, p++, d++) { if (byte & mask) { @@ -1755,7 +1756,16 @@ uint8 S9xDoHDMA (uint8 byte) #undef DOBYTE } + } + } + } + for (mask = 1, p = &DMA[0], d = 0; mask; mask <<= 1, p++, d++) + { + if (byte & mask) + { + if (p->DoTransfer) + { if (p->HDMAIndirectAddressing) p->IndirectAddress += HDMA_ModeByteCounts[p->TransferMode]; else @@ -1771,7 +1781,6 @@ uint8 S9xDoHDMA (uint8 byte) byte &= ~mask; PPU.HDMAEnded |= mask; p->DoTransfer = FALSE; - continue; } } else