Core: Add stubs for loading/saving subsystem extra state

This commit is contained in:
Vicki Pfau 2024-09-01 00:55:29 -07:00
parent c06a376b2e
commit 3a6657bd88
5 changed files with 35 additions and 0 deletions

View File

@ -109,6 +109,8 @@ struct mCore {
size_t (*stateSize)(struct mCore*);
bool (*loadState)(struct mCore*, const void* state);
bool (*saveState)(struct mCore*, void* state);
bool (*loadExtraState)(struct mCore*, const struct mStateExtdata*);
bool (*saveExtraState)(struct mCore*, struct mStateExtdata*);
void (*setKeys)(struct mCore*, uint32_t keys);
void (*addKeys)(struct mCore*, uint32_t keys);

View File

@ -17,6 +17,8 @@ enum mStateExtdataTag {
EXTDATA_CHEATS = 3,
EXTDATA_RTC = 4,
EXTDATA_SCREENSHOT_DIMENSIONS = 5,
EXTDATA_SUBSYSTEM_START = 0x40,
EXTDATA_SUBSYSTEM_MAX = 0x7F,
EXTDATA_META_TIME = 0x101,
EXTDATA_META_CREATOR = 0x102,
EXTDATA_MAX

View File

@ -371,6 +371,7 @@ bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags) {
mStateExtdataInit(&extdata);
size_t stateSize = core->stateSize(core);
core->saveExtraState(core, &extdata);
if (flags & SAVESTATE_METADATA) {
uint64_t* creationUsec = malloc(sizeof(*creationUsec));
if (creationUsec) {
@ -528,6 +529,8 @@ bool mCoreLoadStateNamed(struct mCore* core, struct VFile* vf, int flags) {
bool success = core->loadState(core, state);
mappedMemoryFree(state, core->stateSize(core));
core->loadExtraState(core, &extdata);
unsigned width, height;
core->currentVideoSize(core, &width, &height);

View File

@ -743,6 +743,18 @@ static bool _GBCoreSaveState(struct mCore* core, void* state) {
return true;
}
static bool _GBCoreLoadExtraState(struct mCore* core, const struct mStateExtdata* extdata) {
UNUSED(core);
UNUSED(extdata);
return true;
}
static bool _GBCoreSaveExtraState(struct mCore* core, struct mStateExtdata* extdata) {
UNUSED(core);
UNUSED(extdata);
return true;
}
static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) {
struct GBCore* gbcore = (struct GBCore*) core;
gbcore->keys = keys;
@ -1321,6 +1333,8 @@ struct mCore* GBCoreCreate(void) {
core->stateSize = _GBCoreStateSize;
core->loadState = _GBCoreLoadState;
core->saveState = _GBCoreSaveState;
core->loadExtraState = _GBCoreLoadExtraState;
core->saveExtraState = _GBCoreSaveExtraState;
core->setKeys = _GBCoreSetKeys;
core->addKeys = _GBCoreAddKeys;
core->clearKeys = _GBCoreClearKeys;

View File

@ -832,6 +832,18 @@ static bool _GBACoreSaveState(struct mCore* core, void* state) {
return true;
}
static bool _GBACoreLoadExtraState(struct mCore* core, const struct mStateExtdata* extdata) {
UNUSED(core);
UNUSED(extdata);
return true;
}
static bool _GBACoreSaveExtraState(struct mCore* core, struct mStateExtdata* extdata) {
UNUSED(core);
UNUSED(extdata);
return true;
}
static void _GBACoreSetKeys(struct mCore* core, uint32_t keys) {
struct GBA* gba = core->board;
gba->keysActive = keys;
@ -1539,6 +1551,8 @@ struct mCore* GBACoreCreate(void) {
core->stateSize = _GBACoreStateSize;
core->loadState = _GBACoreLoadState;
core->saveState = _GBACoreSaveState;
core->loadExtraState = _GBACoreLoadExtraState;
core->saveExtraState = _GBACoreSaveExtraState;
core->setKeys = _GBACoreSetKeys;
core->addKeys = _GBACoreAddKeys;
core->clearKeys = _GBACoreClearKeys;