all repos — mgba @ f8fff828e3d9e0c27e0852eae6895db00d4ad83c

mGBA Game Boy Advance Emulator

Start working on ability to bundle save data with movies
Jeffrey Pfau jeffrey@endrift.com
Mon, 04 Aug 2014 01:11:46 -0700
commit

f8fff828e3d9e0c27e0852eae6895db00d4ad83c

parent

220d836f13a99f81166217b8a498863c2e31d709

M src/gba/gba-rr.csrc/gba/gba-rr.c

@@ -41,6 +41,18 @@ free(gba->rr);

gba->rr = 0; } +void GBARRAlterSavedata(struct GBA* gba) { + if (!gba || !gba->rr) { + return; + } + + if (gba->rr->initFrom & INIT_FROM_SAVEGAME) { + // TOOD + } else { + GBASavedataMask(&gba->memory.savedata, 0); + } +} + bool GBARRInitStream(struct GBARRContext* rr, struct VDir* stream) { if (rr->movieStream && !rr->movieStream->close(rr->movieStream)) { return false;
M src/gba/gba-rr.hsrc/gba/gba-rr.h

@@ -77,6 +77,7 @@ };

void GBARRContextCreate(struct GBA*); void GBARRContextDestroy(struct GBA*); +void GBARRAlterSavedata(struct GBA*); bool GBARRInitStream(struct GBARRContext*, struct VDir*); bool GBARRReinitStream(struct GBARRContext*, enum GBARRInitFrom);
M src/gba/gba-savedata.csrc/gba/gba-savedata.c

@@ -60,6 +60,11 @@ }

savedata->type = SAVEDATA_NONE; } +void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf) { + GBASavedataDeinit(savedata); + GBASavedataInit(savedata, vf); +} + void GBASavedataInitFlash(struct GBASavedata* savedata) { if (savedata->type == SAVEDATA_NONE) { savedata->type = SAVEDATA_FLASH512;
M src/gba/gba-savedata.hsrc/gba/gba-savedata.h

@@ -71,6 +71,7 @@ };

void GBASavedataInit(struct GBASavedata* savedata, struct VFile* vf); void GBASavedataDeinit(struct GBASavedata* savedata); +void GBASavedataMask(struct GBASavedata* savedata, struct VFile* vf); void GBASavedataInitFlash(struct GBASavedata* savedata); void GBASavedataInitEEPROM(struct GBASavedata* savedata);
M src/platform/sdl/sdl-events.csrc/platform/sdl/sdl-events.c

@@ -128,9 +128,10 @@ GBAThreadInterrupt(context);

GBARRContextCreate(context->gba); if (!GBARRIsRecording(context->gba->rr)) { GBARRInitStream(context->gba->rr, context->stateDir); - GBARRReinitStream(context->gba->rr, INIT_FROM_SAVEGAME); + GBARRReinitStream(context->gba->rr, INIT_EX_NIHILO); GBARRStopPlaying(context->gba->rr); GBARRStartRecording(context->gba->rr); + GBARRAlterSavedata(context->gba); } GBAThreadContinue(context); }

@@ -142,7 +143,11 @@ GBAThreadInterrupt(context);

GBARRContextCreate(context->gba); GBARRInitStream(context->gba->rr, context->stateDir); GBARRStopRecording(context->gba->rr); - GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT); + GBARRStartPlaying(context->gba->rr, false); + if (context->gba->rr->initFrom & INIT_FROM_SAVESTATE) { + // TODO + } + GBARRAlterSavedata(context->gba); GBAThreadContinue(context); } break;