Start working on ability to bundle save data with movies

This commit is contained in:
Jeffrey Pfau 2014-08-04 01:11:46 -07:00
parent 220d836f13
commit f8fff828e3
5 changed files with 26 additions and 2 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;