Rotate 16-bit without using AND

This commit is contained in:
Jeffrey Pfau 2013-10-26 16:40:31 -07:00
parent 0155d9c028
commit 72ef1643c7
1 changed files with 2 additions and 2 deletions

View File

@ -194,7 +194,7 @@ uint16_t GBALoadU16(struct ARMMemory* memory, uint32_t address, int* cycleCounte
int16_t GBALoad16(struct ARMMemory* memory, uint32_t address, int* cycleCounter) {
struct GBAMemory* gbaMemory = (struct GBAMemory*) memory;
int16_t value = 0;
uint16_t value = 0;
int wait = 0;
switch (address & ~OFFSET_MASK) {
@ -260,7 +260,7 @@ int16_t GBALoad16(struct ARMMemory* memory, uint32_t address, int* cycleCounter)
}
// 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);
return (value >> rotate) | (value << (16 - rotate));
}
uint8_t GBALoadU8(struct ARMMemory* memory, uint32_t address, int* cycleCounter) {