GBA Savedata: Improve save write edge cases

This commit is contained in:
Vicki Pfau 2024-11-01 02:06:04 -07:00
parent f89184d51f
commit 645d1cf344
2 changed files with 5 additions and 11 deletions

View File

@ -802,14 +802,7 @@ uint32_t GBALoad8(struct ARMCore* cpu, uint32_t address, int* cycleCounter) {
mLOG(GBA_MEM, STUB, "Unimplemented memory Store32: 0x%08X", address); mLOG(GBA_MEM, STUB, "Unimplemented memory Store32: 0x%08X", address);
#define STORE_SRAM \ #define STORE_SRAM \
if (address & 0x3) { \ GBAStore8(cpu, address, value >> (8 * (address & 3)), cycleCounter);
mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store32: 0x%08X", address); \
} else { \
GBAStore8(cpu, address, value, cycleCounter); \
GBAStore8(cpu, address | 1, value, cycleCounter); \
GBAStore8(cpu, address | 2, value, cycleCounter); \
GBAStore8(cpu, address | 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);
@ -989,10 +982,9 @@ void GBAStore16(struct ARMCore* cpu, uint32_t address, int16_t value, int* cycle
case GBA_REGION_SRAM_MIRROR: case GBA_REGION_SRAM_MIRROR:
if (address & 1) { if (address & 1) {
mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store16: 0x%08X", address); mLOG(GBA_MEM, GAME_ERROR, "Unaligned SRAM Store16: 0x%08X", address);
break; value >>= 8;
} }
GBAStore8(cpu, address, value, cycleCounter); 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);

View File

@ -376,7 +376,9 @@ uint8_t GBASavedataReadFlash(struct GBASavedata* savedata, uint16_t address) {
} }
} }
if (mTimingIsScheduled(savedata->timing, &savedata->dust) && (address >> 12) == savedata->settling) { if (mTimingIsScheduled(savedata->timing, &savedata->dust) && (address >> 12) == savedata->settling) {
return 0x5F; // This should read /Q7 ("data# polling") and Q6 flipping ("toggle bit") every read,
// but just data# polling is sufficient for games to figure it out
return savedata->currentBank[address] ^ 0x80;
} }
return savedata->currentBank[address]; return savedata->currentBank[address];
} }