mirror of https://github.com/mgba-emu/mgba.git
GBA Savedata: Improve save write edge cases
This commit is contained in:
parent
f89184d51f
commit
645d1cf344
|
@ -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);
|
||||||
|
|
|
@ -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];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue