GBA DMA: Fix DMA source direction bits being cleared (fixes #2410)

This commit is contained in:
Vicki Pfau 2022-01-15 20:32:50 -08:00
parent 9a85fc8a5a
commit 9b6b7c7392
2 changed files with 8 additions and 4 deletions

View File

@ -17,6 +17,7 @@ Emulation fixes:
- GB Video: Draw SGB border pieces that overlap GB graphics (fixes mgba.io/i/1339)
- GBA: Improve timing when not booting from BIOS
- GBA BIOS: Work around IRQ handling hiccup in Mario & Luigi (fixes mgba.io/i/1059)
- GBA DMA: Fix DMA source direction bits being cleared (fixes mgba.io/i/2410)
- GBA I/O: Redo internal key input, enabling edge-based key IRQs
- GBA I/O: Disable open bus behavior on invalid register 06A
- GBA Memory: Fix misaligned 32-bit I/O loads (fixes mgba.io/i/2307)

View File

@ -83,9 +83,6 @@ uint16_t GBADMAWriteCNT_HI(struct GBA* gba, int dma, uint16_t control) {
if (!wasEnabled && GBADMARegisterIsEnable(currentDma->reg)) {
currentDma->nextSource = currentDma->source;
if (currentDma->nextSource >= BASE_CART0 && currentDma->nextSource < BASE_CART_SRAM && GBADMARegisterGetSrcControl(currentDma->reg) < 3) {
currentDma->reg = GBADMARegisterClearSrcControl(currentDma->reg);
}
currentDma->nextDest = currentDma->dest;
uint32_t width = 2 << GBADMARegisterGetWidth(currentDma->reg);
@ -291,7 +288,13 @@ void GBADMAService(struct GBA* gba, int number, struct GBADMA* info) {
}
gba->bus = memory->dmaTransferRegister;
}
int sourceOffset = DMA_OFFSET[GBADMARegisterGetSrcControl(info->reg)] * width;
int sourceOffset;
if (info->nextSource >= BASE_CART0 && info->nextSource < BASE_CART_SRAM && GBADMARegisterGetSrcControl(info->reg) < 3) {
sourceOffset = width;
} else {
sourceOffset = DMA_OFFSET[GBADMARegisterGetSrcControl(info->reg)] * width;
}
int destOffset = DMA_OFFSET[GBADMARegisterGetDestControl(info->reg)] * width;
if (source) {
source += sourceOffset;