GB, GBA Core: Only deserialize needed parts of savestates for mVL

This commit is contained in:
Vicki Pfau 2017-04-24 12:43:12 -07:00
parent 63ed7421ce
commit 25beafcc11
2 changed files with 41 additions and 20 deletions

View File

@ -8,6 +8,7 @@
#include <mgba/core/core.h>
#include <mgba/internal/gb/cheats.h>
#include <mgba/internal/gb/extra/cli.h>
#include <mgba/internal/gb/io.h>
#include <mgba/internal/gb/gb.h>
#include <mgba/internal/gb/mbc.h>
#include <mgba/internal/gb/overrides.h>
@ -752,11 +753,6 @@ static void _GBVLPStartFrameCallback(void *context) {
GBVideoProxyRendererUnshim(&gb->video, &gbcore->proxyRenderer);
mVideoLogContextRewind(gbcore->logContext, core);
GBVideoProxyRendererShim(&gb->video, &gbcore->proxyRenderer);
// Make sure CPU loop never spins
GBHalt(gb->cpu);
gb->memory.ie = 0;
gb->memory.ime = false;
}
}
@ -796,11 +792,6 @@ static void _GBVLPReset(struct mCore* core) {
LR35902Reset(core->cpu);
mVideoLogContextRewind(gbcore->logContext, core);
GBVideoProxyRendererShim(&gb->video, &gbcore->proxyRenderer);
// Make sure CPU loop never spins
GBHalt(gb->cpu);
gb->memory.ie = 0;
gb->memory.ime = false;
}
static bool _GBVLPLoadROM(struct mCore* core, struct VFile* vf) {
@ -815,6 +806,27 @@ static bool _GBVLPLoadROM(struct mCore* core, struct VFile* vf) {
return true;
}
static bool _GBVLPLoadState(struct mCore* core, const void* buffer) {
struct GB* gb = (struct GB*) core->board;
const struct GBSerializedState* state = buffer;
gb->timing.root = NULL;
gb->model = state->model;
gb->cpu->pc = GB_BASE_HRAM;
gb->cpu->memory.setActiveRegion(gb->cpu, gb->cpu->pc);
GBVideoDeserialize(&gb->video, state);
GBIODeserialize(gb, state);
// Make sure CPU loop never spins
GBHalt(gb->cpu);
gb->memory.ie = 0;
gb->memory.ime = false;
return true;
}
static bool _returnTrue(struct VFile* vf) {
UNUSED(vf);
return true;
@ -826,6 +838,7 @@ struct mCore* GBVideoLogPlayerCreate(void) {
core->deinit = _GBVLPDeinit;
core->reset = _GBVLPReset;
core->loadROM = _GBVLPLoadROM;
core->loadState = _GBVLPLoadState;
core->isROM = _returnTrue;
return core;
}

View File

@ -772,11 +772,6 @@ static void _GBAVLPStartFrameCallback(void *context) {
GBAVideoProxyRendererUnshim(&gba->video, &gbacore->proxyRenderer);
mVideoLogContextRewind(gbacore->logContext, core);
GBAVideoProxyRendererShim(&gba->video, &gbacore->proxyRenderer);
// Make sure CPU loop never spins
GBAHalt(gba);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL);
}
}
@ -816,11 +811,6 @@ static void _GBAVLPReset(struct mCore* core) {
ARMReset(core->cpu);
mVideoLogContextRewind(gbacore->logContext, core);
GBAVideoProxyRendererShim(&gba->video, &gbacore->proxyRenderer);
// Make sure CPU loop never spins
GBAHalt(gba);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL);
}
static bool _GBAVLPLoadROM(struct mCore* core, struct VFile* vf) {
@ -835,6 +825,23 @@ static bool _GBAVLPLoadROM(struct mCore* core, struct VFile* vf) {
return true;
}
static bool _GBAVLPLoadState(struct mCore* core, const void* state) {
struct GBA* gba = (struct GBA*) core->board;
gba->timing.root = NULL;
gba->cpu->gprs[ARM_PC] = BASE_WORKING_RAM;
gba->cpu->memory.setActiveRegion(gba->cpu, gba->cpu->gprs[ARM_PC]);
// Make sure CPU loop never spins
GBAHalt(gba);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IME, 0, NULL);
gba->cpu->memory.store16(gba->cpu, BASE_IO | REG_IE, 0, NULL);
GBAVideoDeserialize(&gba->video, state);
GBAIODeserialize(gba, state);
return true;
}
static bool _returnTrue(struct VFile* vf) {
UNUSED(vf);
return true;
@ -846,6 +853,7 @@ struct mCore* GBAVideoLogPlayerCreate(void) {
core->deinit = _GBAVLPDeinit;
core->reset = _GBAVLPReset;
core->loadROM = _GBAVLPLoadROM;
core->loadState = _GBAVLPLoadState;
core->isROM = _returnTrue;
return core;
}