From 4db61f400be9e49fb754c0473768143010cd2c20 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 6 Oct 2015 21:25:45 -0700 Subject: [PATCH] GBA Memory: Fix bad Load8 on big endian --- CHANGES | 1 + src/gba/memory.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 374ab5165..f18dffa86 100644 --- a/CHANGES +++ b/CHANGES @@ -17,6 +17,7 @@ Bugfixes: - GBA Video: Fix OBJ semitransparency improperly interacting with other blending ops - GBA: Fix autodetect problems with some bad dumps of Super Mario Advance 2 - GBA Memory: Fix bad BIOS Load16 on big endian + - GBA Memory: Fix bad Load8 on big endian 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 db048188c..af0d6a634 100644 --- a/src/gba/memory.c +++ b/src/gba/memory.c @@ -535,12 +535,12 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { value = ((uint8_t*) memory->bios)[address]; } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load8: 0x%08X", address); - value = ((uint8_t*) &memory->biosPrefetch)[address & 3]; + value = (memory->biosPrefetch >> ((address & 3) * 8)) & 0xFF; } } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address); LOAD_BAD; - value = ((uint8_t*) &value)[address & 3]; + value = (value >> ((address & 3) * 8)) & 0xFF; } break; case REGION_WORKING_RAM: @@ -602,7 +602,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) { default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address); LOAD_BAD; - value = ((uint8_t*) &value)[address & 3]; + value = (value >> ((address & 3) * 8)) & 0xFF; break; }