all repos — mgba @ f8341f2d205f12e53c643919ade3b269e6a4159b

mGBA Game Boy Advance Emulator

Rotate 16-bit unaligned loads
Jeffrey Pfau jeffrey@endrift.com
Fri, 27 Sep 2013 02:07:44 -0700
commit

f8341f2d205f12e53c643919ade3b269e6a4159b

parent

f6e1e6e6d52115d2e9e305d421e4ae1eec0d775d

1 files changed, 3 insertions(+), 1 deletions(-)

jump to
M src/gba/gba-memory.csrc/gba/gba-memory.c

@@ -231,7 +231,9 @@

if (cycleCounter) { *cycleCounter += 2 + wait; } - return value; + // Unaligned 16-bit loads are "unpredictable", but the GBA rotates them, so we have to, too. + int rotate = (address & 1) << 3; + return (value >> rotate) | ((value << rotate) & 0xFF00); } uint8_t GBALoadU8(struct ARMMemory* memory, uint32_t address, int* cycleCounter) {