all repos — mgba @ d979e04606f54be7636e9db1869dab0cfcdb10c4

mGBA Game Boy Advance Emulator

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
commit

d979e04606f54be7636e9db1869dab0cfcdb10c4

parent

f8fff828e3d9e0c27e0852eae6895db00d4ad83c

3 files changed, 14 insertions(+), 1 deletions(-)

jump to
M src/gba/gba-savedata.csrc/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.hsrc/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.csrc/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);