include/mgba/core/serialize.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef M_SERIALIZE_H
7#define M_SERIALIZE_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13enum mStateExtdataTag {
14 EXTDATA_NONE = 0,
15 EXTDATA_SCREENSHOT = 1,
16 EXTDATA_SAVEDATA = 2,
17 EXTDATA_CHEATS = 3,
18 EXTDATA_MAX
19};
20
21#define SAVESTATE_SCREENSHOT 1
22#define SAVESTATE_SAVEDATA 2
23#define SAVESTATE_CHEATS 4
24
25struct mStateExtdataItem {
26 int32_t size;
27 void* data;
28 void (*clean)(void*);
29};
30
31struct mStateExtdata {
32 struct mStateExtdataItem data[EXTDATA_MAX];
33};
34
35bool mStateExtdataInit(struct mStateExtdata*);
36void mStateExtdataDeinit(struct mStateExtdata*);
37void mStateExtdataPut(struct mStateExtdata*, enum mStateExtdataTag, struct mStateExtdataItem*);
38bool mStateExtdataGet(struct mStateExtdata*, enum mStateExtdataTag, struct mStateExtdataItem*);
39
40struct VFile;
41bool mStateExtdataSerialize(struct mStateExtdata* extdata, struct VFile* vf);
42bool mStateExtdataDeserialize(struct mStateExtdata* extdata, struct VFile* vf);
43
44struct mCore;
45bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags);
46bool mCoreLoadStateNamed(struct mCore* core, struct VFile* vf, int flags);
47void* mCoreExtractState(struct mCore* core, struct VFile* vf, struct mStateExtdata* extdata);
48
49CXX_GUARD_END
50
51#endif