all repos — mgba @ 06bf931b773259daa73f18691610af71518aa68e

mGBA Game Boy Advance Emulator

GBA Memory: Fix alignment of open bus 8- and 16-bit loads
Jeffrey Pfau jeffrey@endrift.com
Thu, 15 Jan 2015 01:10:54 -0800
commit

06bf931b773259daa73f18691610af71518aa68e

parent

1119d773e16d4183599bf3823fd3670b3e2e341d

2 files changed, 11 insertions(+), 10 deletions(-)

jump to
M CHANGESCHANGES

@@ -57,6 +57,7 @@ - GBA Memory: Properly bounds-check VRAM accesses

- GBA Memory: Fix initial DMA state - GBA BIOS: Fix BIOS prefetch after returning from an IRQ - GBA BIOS: Fix BIOS prefetch after reset + - GBA Memory: Fix alignment of open bus 8- and 16-bit loads Misc: - Qt: Disable sync to video by default - GBA: Exit cleanly on FATAL if the port supports it
M src/gba/gba-memory.csrc/gba/gba-memory.c

@@ -297,14 +297,14 @@ if (memory->activeRegion == REGION_BIOS) {

LOAD_16(value, address, memory->bios); } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load16: 0x%08X", address); - value = memory->biosPrefetch & 0xFFFF; + LOAD_16(value, address & 2, &memory->biosPrefetch); } } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); if (cpu->cycles >= cpu->nextEvent) { - value = gba->bus & 0xFFFF; + LOAD_16(value, address & 2, &gba->bus); } else { - value = cpu->prefetch[1] & 0xFFFF; + LOAD_16(value, address & 2, &cpu->prefetch[1]); } } break;

@@ -364,9 +364,9 @@ break;

default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load16: 0x%08X", address); if (cpu->cycles >= cpu->nextEvent) { - value = gba->bus; + LOAD_16(value, address & 2, &gba->bus); } else { - value = cpu->prefetch[1]; + LOAD_16(value, address & 2, &cpu->prefetch[1]); } break; }

@@ -392,14 +392,14 @@ if (memory->activeRegion == REGION_BIOS) {

value = ((int8_t*) memory->bios)[address]; } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad BIOS Load8: 0x%08X", address); - value = memory->biosPrefetch; + value = ((uint8_t*) &memory->biosPrefetch)[address & 3]; } } else { GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address); if (cpu->cycles >= cpu->nextEvent) { - value = gba->bus; + value = ((uint8_t*) &gba->bus)[address & 3]; } else { - value = cpu->prefetch[1]; + value = ((uint8_t*) &cpu->prefetch[1])[address & 3]; } } break;

@@ -461,9 +461,9 @@ break;

default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Load8: 0x%08x", address); if (cpu->cycles >= cpu->nextEvent) { - value = gba->bus; + value = ((uint8_t*) &gba->bus)[address & 3]; } else { - value = cpu->prefetch[1]; + value = ((uint8_t*) &cpu->prefetch[1])[address & 3]; } break; }