mirror of https://github.com/mgba-emu/mgba.git
Core: Switch video log state load/store to use mCore*State functions
This commit is contained in:
parent
84dd69ff86
commit
c06a376b2e
|
@ -511,9 +511,13 @@ struct mVideoLogContext* mVideoLogContextCreate(struct mCore* core) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (core) {
|
if (core) {
|
||||||
context->initialStateSize = core->stateSize(core);
|
struct VFile* vf = VFileMemChunk(NULL, core->stateSize(core));
|
||||||
|
mCoreSaveStateNamed(core, vf, 0);
|
||||||
|
context->initialStateSize = vf->size(vf);
|
||||||
context->initialState = anonymousMemoryMap(context->initialStateSize);
|
context->initialState = anonymousMemoryMap(context->initialStateSize);
|
||||||
core->saveState(core, context->initialState);
|
vf->seek(vf, 0, SEEK_SET);
|
||||||
|
vf->write(vf, context->initialState, context->initialStateSize);
|
||||||
|
vf->close(vf);
|
||||||
core->startVideoLog(core, context);
|
core->startVideoLog(core, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -763,15 +767,15 @@ void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* contex
|
||||||
void mVideoLogContextRewind(struct mVideoLogContext* context, struct mCore* core) {
|
void mVideoLogContextRewind(struct mVideoLogContext* context, struct mCore* core) {
|
||||||
_readHeader(context);
|
_readHeader(context);
|
||||||
if (core) {
|
if (core) {
|
||||||
size_t size = core->stateSize(core);
|
struct VFile* vf;
|
||||||
if (size <= context->initialStateSize) {
|
if (context->initialStateSize < core->stateSize(core)) {
|
||||||
core->loadState(core, context->initialState);
|
vf = VFileMemChunk(NULL, core->stateSize(core));
|
||||||
|
vf->write(vf, context->initialState, context->initialStateSize);
|
||||||
} else {
|
} else {
|
||||||
void* extendedState = anonymousMemoryMap(size);
|
vf = VFileFromConstMemory(context->initialState, context->initialStateSize);
|
||||||
memcpy(extendedState, context->initialState, context->initialStateSize);
|
|
||||||
core->loadState(core, extendedState);
|
|
||||||
mappedMemoryFree(extendedState, size);
|
|
||||||
}
|
}
|
||||||
|
mCoreLoadStateNamed(core, vf, 0);
|
||||||
|
vf->close(vf);
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t pointer = context->backing->seek(context->backing, 0, SEEK_CUR);
|
off_t pointer = context->backing->seek(context->backing, 0, SEEK_CUR);
|
||||||
|
|
Loading…
Reference in New Issue