From dd91b689a2ca12c096b886204c9c7ef17435b64d Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Tue, 29 Dec 2015 00:03:42 -0500 Subject: [PATCH] GBA Hardware: Fix GPIO on big endian --- CHANGES | 1 + src/gba/hardware.c | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index b628db551..a4ac89a9b 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,7 @@ Bugfixes: - ARM7: Fix sign of unaligned LDRSH - GBA: Fix warnings when creating and loading savestates - GBA Memory: Fix DMAs triggering two cycles early + - GBA Hardware: Fix GPIO on big endian Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper diff --git a/src/gba/hardware.c b/src/gba/hardware.c index 31d069e8a..a0e648d2e 100644 --- a/src/gba/hardware.c +++ b/src/gba/hardware.c @@ -87,9 +87,11 @@ void GBAHardwareGPIOWrite(struct GBACartridgeHardware* hw, uint32_t address, uin GBALog(hw->p, GBA_LOG_WARN, "Invalid GPIO address"); } if (hw->readWrite) { - uint16_t old = hw->gpioBase[0]; + uint16_t old; + LOAD_16(old, 0, hw->gpioBase); old &= ~hw->direction; - hw->gpioBase[0] = old | hw->pinState; + old |= hw->pinState; + STORE_16(old, 0, hw->gpioBase); } else { hw->gpioBase[0] = 0; } @@ -129,10 +131,11 @@ void _readPins(struct GBACartridgeHardware* hw) { void _outputPins(struct GBACartridgeHardware* hw, unsigned pins) { if (hw->readWrite) { - uint16_t old = hw->gpioBase[0]; + uint16_t old; + LOAD_16(old, 0, hw->gpioBase); old &= hw->direction; hw->pinState = old | (pins & ~hw->direction & 0xF); - hw->gpioBase[0] = hw->pinState; + STORE_16(hw->pinState, 0, hw->gpioBase); } }