diff --git a/src/gba/gba-savedata.c b/src/gba/gba-savedata.c index c6292bd7f..83b0cb834 100644 --- a/src/gba/gba-savedata.c +++ b/src/gba/gba-savedata.c @@ -109,6 +109,25 @@ bool GBASavedataClone(struct GBASavedata* savedata, struct VFile* out) { return true; } +void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type) { + switch (type) { + case SAVEDATA_FLASH512: + case SAVEDATA_FLASH1M: + savedata->type = type; + GBASavedataInitFlash(savedata); + break; + case SAVEDATA_EEPROM: + GBASavedataInitEEPROM(savedata); + break; + case SAVEDATA_SRAM: + GBASavedataInitSRAM(savedata); + break; + case SAVEDATA_NONE: + // TODO: Force none + break; + } +} + void GBASavedataInitFlash(struct GBASavedata* savedata) { if (savedata->type == SAVEDATA_NONE) { savedata->type = SAVEDATA_FLASH512; diff --git a/src/gba/gba-savedata.h b/src/gba/gba-savedata.h index dbb1d5a22..64972f0ba 100644 --- a/src/gba/gba-savedata.h +++ b/src/gba/gba-savedata.h @@ -83,6 +83,7 @@ void GBASavedataDeinit(struct GBASavedata* savedata); void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf); void GBASavedataUnmask(struct GBASavedata* savedata); bool GBASavedataClone(struct GBASavedata* savedata, struct VFile* out); +void GBASavedataForceType(struct GBASavedata* savedata, enum SavedataType type); void GBASavedataInitFlash(struct GBASavedata* savedata); void GBASavedataInitEEPROM(struct GBASavedata* savedata); diff --git a/src/gba/gba.c b/src/gba/gba.c index b72d7f2ba..bfafd0a86 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -706,21 +706,7 @@ void _checkOverrides(struct GBA* gba, uint32_t id) { const uint32_t* overrideId = (const uint32_t*) _overrides[i].id; if (*overrideId == id) { GBALog(gba, GBA_LOG_DEBUG, "Found override for game %s!", _overrides[i].id); - switch (_overrides[i].type) { - case SAVEDATA_FLASH512: - case SAVEDATA_FLASH1M: - gba->memory.savedata.type = _overrides[i].type; - GBASavedataInitFlash(&gba->memory.savedata); - break; - case SAVEDATA_EEPROM: - GBASavedataInitEEPROM(&gba->memory.savedata); - break; - case SAVEDATA_SRAM: - GBASavedataInitSRAM(&gba->memory.savedata); - break; - case SAVEDATA_NONE: - break; - } + GBASavedataForceType(&gba->memory.savedata, _overrides[i].type); if (_overrides[i].gpio & GPIO_RTC) { GBAGPIOInitRTC(&gba->memory.gpio);