all repos — mgba @ 6c805acab6673dfdb19b5ff18661008d16be8c82

mGBA Game Boy Advance Emulator

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_RTC = 4,
19	EXTDATA_META_TIME = 0x101,
20	EXTDATA_MAX
21};
22
23#define SAVESTATE_SCREENSHOT 1
24#define SAVESTATE_SAVEDATA   2
25#define SAVESTATE_CHEATS     4
26#define SAVESTATE_RTC        8
27#define SAVESTATE_METADATA   16
28
29struct mStateExtdataItem {
30	int32_t size;
31	void* data;
32	void (*clean)(void*);
33};
34
35struct mStateExtdata {
36	struct mStateExtdataItem data[EXTDATA_MAX];
37};
38
39bool mStateExtdataInit(struct mStateExtdata*);
40void mStateExtdataDeinit(struct mStateExtdata*);
41void mStateExtdataPut(struct mStateExtdata*, enum mStateExtdataTag, struct mStateExtdataItem*);
42bool mStateExtdataGet(struct mStateExtdata*, enum mStateExtdataTag, struct mStateExtdataItem*);
43
44struct VFile;
45bool mStateExtdataSerialize(struct mStateExtdata* extdata, struct VFile* vf);
46bool mStateExtdataDeserialize(struct mStateExtdata* extdata, struct VFile* vf);
47
48struct mCore;
49bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags);
50bool mCoreLoadStateNamed(struct mCore* core, struct VFile* vf, int flags);
51void* mCoreExtractState(struct mCore* core, struct VFile* vf, struct mStateExtdata* extdata);
52
53CXX_GUARD_END
54
55#endif