GBA Memory: Misaligned SRAM writes are ignored

This commit is contained in:
Vicki Pfau 2020-01-23 18:25:29 -08:00
parent 541715008b
commit 8b9cd78d0f
2 changed files with 14 additions and 8 deletions

View File

@ -1,4 +1,6 @@
0.9.0: (Future) 0.9.0: (Future)
Emulation fixes:
- GBA Memory: Misaligned SRAM writes are ignored
Other fixes: Other fixes:
- Qt: Only dynamically reset video scale if a game is running - Qt: Only dynamically reset video scale if a game is running
- Qt: Fix race condition with proxied video events - Qt: Fix race condition with proxied video events

View File

@ -772,12 +772,12 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
#define STORE_SRAM \ #define STORE_SRAM \
if (address & 0x3) { \ if (address & 0x3) { \
mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \ mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \
value = 0; \ } else { \
} \ GBAStore8(cpu, address, value, cycleCounter); \
GBAStore8(cpu, address & ~0x3, value, cycleCounter); \ GBAStore8(cpu, address | 1, value, cycleCounter); \
GBAStore8(cpu, (address & ~0x3) | 1, value, cycleCounter); \ GBAStore8(cpu, address | 2, value, cycleCounter); \
GBAStore8(cpu, (address & ~0x3) | 2, value, cycleCounter); \ GBAStore8(cpu, address | 3, value, cycleCounter); \
GBAStore8(cpu, (address & ~0x3) | 3, value, cycleCounter); }
#define STORE_BAD \ #define STORE_BAD \
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store32: 0x%08X", address); mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store32: 0x%08X", address);
@ -923,8 +923,12 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
break; break;
case REGION_CART_SRAM: case REGION_CART_SRAM:
case REGION_CART_SRAM_MIRROR: case REGION_CART_SRAM_MIRROR:
GBAStore8(cpu, (address & ~0x1), value, cycleCounter); if (address & 1) {
GBAStore8(cpu, (address & ~0x1) | 1, value, cycleCounter); mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store16: 0x%08X", address);
break;
}
GBAStore8(cpu, address, value, cycleCounter);
GBAStore8(cpu, address | 1, value, cycleCounter);
break; break;
default: default:
mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store16: 0x%08X", address); mLOG(GBA_MEM, GAME_ERROR, "Bad memory Store16: 0x%08X", address);