Unmask savedata if reseting while a movie is not recording or replaying
Jeffrey Pfau jeffrey@endrift.com
Mon, 04 Aug 2014 22:24:43 -0700
3 files changed,
14 insertions(+),
1 deletions(-)
M
src/gba/gba-savedata.c
→
src/gba/gba-savedata.c
@@ -18,6 +18,7 @@ savedata->data = 0;
savedata->command = EEPROM_COMMAND_NULL; savedata->flashState = FLASH_STATE_RAW; savedata->vf = vf; + savedata->realVf = vf; } void GBASavedataDeinit(struct GBASavedata* savedata) {@@ -57,12 +58,18 @@ case SAVEDATA_NONE:
break; } } + savedata->data = 0; savedata->type = SAVEDATA_NONE; } void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf) { GBASavedataDeinit(savedata); - GBASavedataInit(savedata, vf); + savedata->vf = vf; +} + +void GBASavedataUnmask(struct GBASavedata* savedata) { + GBASavedataDeinit(savedata); + savedata->vf = savedata->realVf; } void GBASavedataInitFlash(struct GBASavedata* savedata) {
M
src/gba/gba-savedata.h
→
src/gba/gba-savedata.h
@@ -57,6 +57,7 @@ enum SavedataType type;
uint8_t* data; enum SavedataCommand command; struct VFile* vf; + struct VFile* realVf; int readBitsRemaining; int readAddress;@@ -71,7 +72,9 @@ };
void GBASavedataInit(struct GBASavedata* savedata, struct VFile* vf); void GBASavedataDeinit(struct GBASavedata* savedata); + void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf); +void GBASavedataUnmask(struct GBASavedata* savedata); void GBASavedataInitFlash(struct GBASavedata* savedata); void GBASavedataInitEEPROM(struct GBASavedata* savedata);
M
src/gba/gba.c
→
src/gba/gba.c
@@ -187,6 +187,9 @@ ARMSetPrivilegeMode(cpu, MODE_SYSTEM);
cpu->gprs[ARM_SP] = SP_BASE_SYSTEM; struct GBA* gba = (struct GBA*) cpu->master; + if (!GBARRIsPlaying(gba->rr) && !GBARRIsRecording(gba->rr)) { + GBASavedataUnmask(&gba->memory.savedata); + } GBAMemoryReset(gba); GBAVideoReset(&gba->video); GBAAudioReset(&gba->audio);