all repos — mgba @ 647872a8d90feb79deebfc13ccd0c868e99c7e2a

mGBA Game Boy Advance Emulator

GBA Memory: Implement several unimplemented memory access types
Jeffrey Pfau jeffrey@endrift.com
Fri, 06 Nov 2015 21:06:56 -0800
commit

647872a8d90feb79deebfc13ccd0c868e99c7e2a

parent

4c1977d351b3ac582b5ea608ef9119a40b3c1aa3

2 files changed, 13 insertions(+), 4 deletions(-)

jump to
M CHANGESCHANGES

@@ -35,6 +35,7 @@ - All: Improved PowerPC support

- All: Fix some undefined behavior warnings - GBA Audio: Implement missing flags on SOUNDCNT_X register - Util: Use VFile for configuration + - GBA Memory: Implement several unimplemented memory access types 0.3.1: (2015-10-24) Bugfixes:
M src/gba/memory.csrc/gba/memory.c

@@ -568,7 +568,7 @@ value = ((uint8_t*) gba->video.renderer->vram)[address & 0x00017FFF];

} break; case REGION_OAM: - GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Load8: 0x%08X", address); + value = ((uint8_t*) gba->video.oam.raw)[address & (SIZE_OAM - 1)]; break; case REGION_CART0: case REGION_CART0_EX:

@@ -661,7 +661,14 @@ wait += waitstatesRegion[address >> BASE_OFFSET]; \

GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store32: 0x%08X", address); #define STORE_SRAM \ - GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store32: 0x%08X", address); + if (address & 0x3) { \ + GBALog(gba, GBA_LOG_GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \ + value = 0; \ + } \ + GBAStore8(cpu, address & ~0x3, value, cycleCounter); \ + GBAStore8(cpu, (address & ~0x3) | 1, value, cycleCounter); \ + GBAStore8(cpu, (address & ~0x3) | 2, value, cycleCounter); \ + GBAStore8(cpu, (address & ~0x3) | 3, value, cycleCounter); #define STORE_BAD \ GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Store32: 0x%08X", address);

@@ -767,7 +774,8 @@ GBASavedataWriteEEPROM(&memory->savedata, value, 1);

break; case REGION_CART_SRAM: case REGION_CART_SRAM_MIRROR: - GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store16: 0x%08X", address); + GBAStore8(cpu, (address & ~0x1), value, cycleCounter); + GBAStore8(cpu, (address & ~0x1) | 1, value, cycleCounter); break; default: GBALog(gba, GBA_LOG_GAME_ERROR, "Bad memory Store16: 0x%08X", address);

@@ -800,7 +808,7 @@ case REGION_IO:

GBAIOWrite8(gba, address & (SIZE_IO - 1), value); break; case REGION_PALETTE_RAM: - GBALog(gba, GBA_LOG_STUB, "Unimplemented memory Store8: 0x%08X", address); + GBAStore16(cpu, address & ~1, ((uint8_t) value) | ((uint8_t) value << 8), cycleCounter); break; case REGION_VRAM: if (address >= 0x06018000) {