From b8b7ec0b12cdfa3aab1da32e06e8868e76ed9dbb Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 25 Oct 2015 14:18:07 -0700 Subject: [PATCH] GBA Memory: Fix DMAs from BIOS while not in BIOS DMAs appear to have special protections against reading from the BIOS, causing BIOS reads to be entirely zero. This behavior needs confirmation on hardware, but seems to make sense. --- CHANGES | 1 + src/gba/memory.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 0fae58d42..0c1b86dcb 100644 --- a/CHANGES +++ b/CHANGES @@ -6,6 +6,7 @@ Features: Bugfixes: - Util: Fix PowerPC PNG read/write pixel order - Qt: Use safer isLoaded check in GameController + - GBA Memory: Fix DMAs from BIOS while not in BIOS Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/gba/memory.c b/src/gba/memory.c index a0dbaec2f..393ac3b79 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -330,7 +330,12 @@ static void GBASetActiveRegion(struct ARMCore* cpu, uint32_t address) { LOAD_32(value, address, memory->bios); \ } else { \ GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load32: 0x%08X", address); \ - value = memory->biosPrefetch; \ + if (memory->activeDMA) { \ + /* TODO: Test on hardware */ \ + value = 0; \ + } else { \ + value = memory->biosPrefetch; \ + } \ } \ } else { \ GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load32: 0x%08X", address); \ @@ -446,7 +451,11 @@ uint32_t GBALoad16(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { LOAD_16(value, address, memory->bios); } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load16: 0x%08X", address); - value = (memory->biosPrefetch >> ((address & 2) * 8)) & 0xFFFF; + if (memory->activeDMA) { + value = 0; + } else { + value = (memory->biosPrefetch >> ((address & 2) * 8)) & 0xFFFF; + } } } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address);