From f8fff828e3d9e0c27e0852eae6895db00d4ad83c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Mon, 4 Aug 2014 01:11:46 -0700 Subject: [PATCH] Start working on ability to bundle save data with movies --- src/gba/gba-rr.c | 12 ++++++++++++ src/gba/gba-rr.h | 1 + src/gba/gba-savedata.c | 5 +++++ src/gba/gba-savedata.h | 1 + src/platform/sdl/sdl-events.c | 9 +++++++-- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/gba/gba-rr.c b/src/gba/gba-rr.c index 3e8cd6b3d..bc52423d6 100644 --- a/src/gba/gba-rr.c +++ b/src/gba/gba-rr.c @@ -41,6 +41,18 @@ void GBARRContextDestroy(struct GBA* gba) { 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; diff --git a/src/gba/gba-rr.h b/src/gba/gba-rr.h index 0fe96caff..c8533c55d 100644 --- a/src/gba/gba-rr.h +++ b/src/gba/gba-rr.h @@ -77,6 +77,7 @@ struct GBARRContext { void GBARRContextCreate(struct GBA*); void GBARRContextDestroy(struct GBA*); +void GBARRAlterSavedata(struct GBA*); bool GBARRInitStream(struct GBARRContext*, struct VDir*); bool GBARRReinitStream(struct GBARRContext*, enum GBARRInitFrom); diff --git a/src/gba/gba-savedata.c b/src/gba/gba-savedata.c index e3332b517..beb42a384 100644 --- a/src/gba/gba-savedata.c +++ b/src/gba/gba-savedata.c @@ -60,6 +60,11 @@ void GBASavedataDeinit(struct GBASavedata* savedata) { 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; diff --git a/src/gba/gba-savedata.h b/src/gba/gba-savedata.h index a9969c850..0c5f07323 100644 --- a/src/gba/gba-savedata.h +++ b/src/gba/gba-savedata.h @@ -71,6 +71,7 @@ struct GBASavedata { 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); diff --git a/src/platform/sdl/sdl-events.c b/src/platform/sdl/sdl-events.c index d13e82493..130effdf3 100644 --- a/src/platform/sdl/sdl-events.c +++ b/src/platform/sdl/sdl-events.c @@ -128,9 +128,10 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents 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 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents 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;