all repos — mgba @ 93633ea60524ac2983e747e13656b896544299cf

mGBA Game Boy Advance Emulator

GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301, fixes mgba.io/i/1320)
Vicki Pfau vi@endrift.com
Fri, 24 Jan 2020 18:06:23 -0800
commit

93633ea60524ac2983e747e13656b896544299cf

parent

38613e1c78bbf840fb78abfe9f6d71a6a549d712

M CHANGESCHANGES

@@ -2,6 +2,7 @@ 0.9.0: (Future)

Emulation fixes: - ARM: Fix ALU reading PC after shifting - ARM: Fix STR storing PC after address calculation + - GBA DMA: Linger last DMA on bus (fixes mgba.io/i/301 and mgba.io/i/1320) - GBA Memory: Misaligned SRAM writes are ignored - GBA Serialize: Fix serializing DMA transfer register Other fixes:
M include/mgba/internal/gba/gba.hinclude/mgba/internal/gba/gba.h

@@ -109,6 +109,7 @@ uint32_t lastJump;

bool haltPending; bool cpuBlocked; bool earlyExit; + uint32_t dmaPC; int idleDetectionStep; int idleDetectionFailures; int32_t cachedRegisters[16];
M include/mgba/internal/gba/serialize.hinclude/mgba/internal/gba/serialize.h

@@ -300,8 +300,9 @@ uint32_t gbpNextEvent;

} hw; uint32_t dmaTransferRegister; + uint32_t dmaBlockPC; - uint32_t reservedHardware[5]; + uint32_t reservedHardware[4]; struct { uint8_t type;
M src/gba/dma.csrc/gba/dma.c

@@ -219,6 +219,7 @@ }

} if (memory->activeDMA >= 0) { + gba->dmaPC = gba->cpu->gprs[ARM_PC]; mTimingDeschedule(&gba->timing, &memory->dmaEvent); mTimingSchedule(&gba->timing, &memory->dmaEvent, memory->dma[memory->activeDMA].when - currentTime); } else {
M src/gba/gba.csrc/gba/gba.c

@@ -203,6 +203,7 @@ }

gba->cpuBlocked = false; gba->earlyExit = false; + gba->dmaPC = 0; if (gba->yankedRomSize) { gba->memory.romSize = gba->yankedRomSize; gba->memory.romMask = toPow2(gba->memory.romSize) - 1;
M src/gba/io.csrc/gba/io.c

@@ -951,6 +951,7 @@ STORE_32(gba->memory.dma[i].when, 0, &state->dma[i].when);

} STORE_32(gba->memory.dmaTransferRegister, 0, &state->dmaTransferRegister); + STORE_32(gba->dmaPC, 0, &state->dmaBlockPC); GBAHardwareSerialize(&gba->memory.hw, state); }

@@ -995,6 +996,7 @@ }

GBAAudioWriteSOUNDCNT_X(&gba->audio, gba->memory.io[REG_SOUNDCNT_X >> 1]); LOAD_32(gba->memory.dmaTransferRegister, 0, &state->dmaTransferRegister); + LOAD_32(gba->dmaPC, 0, &state->dmaBlockPC); GBADMAUpdate(gba); GBAHardwareDeserialize(&gba->memory.hw, state);
M src/gba/memory.csrc/gba/memory.c

@@ -337,7 +337,7 @@ cpu->memory.activeNonseqCycles16 = memory->waitstatesNonseq16[memory->activeRegion];

} #define LOAD_BAD \ - if (gba->performingDMA) { \ + if (gba->performingDMA || cpu->gprs[ARM_PC] - gba->dmaPC == (gba->cpu->executionMode == MODE_THUMB ? WORD_SIZE_THUMB : WORD_SIZE_ARM)) { \ value = gba->bus; \ } else { \ value = cpu->prefetch[1]; \