From 3f122dcf14d2f0df4e747be2e24c9460a69f7334 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 29 Jul 2013 01:30:06 -0700 Subject: [PATCH] Fix 8-bit I/O writes --- src/gba/gba-io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gba/gba-io.c b/src/gba/gba-io.c index fd71587d7..59fdbfd90 100644 --- a/src/gba/gba-io.c +++ b/src/gba/gba-io.c @@ -130,9 +130,9 @@ void GBAIOWrite8(struct GBA* gba, uint32_t address, uint8_t value) { } return; } - value <<= 8 * (address & 1); - value |= (gba->memory.io[(address & (SIZE_IO - 1)) >> 1]) & ~(0xFF << (8 * (address & 1))); - GBAIOWrite(gba, address, value); + uint16_t value16 = value << (8 * (address & 1)); + value16 |= (gba->memory.io[(address & (SIZE_IO - 1)) >> 1]) & ~(0xFF << (8 * (address & 1))); + GBAIOWrite(gba, address & 0xFFFFFFFE, value16); } void GBAIOWrite32(struct GBA* gba, uint32_t address, uint32_t value) {