all repos — mgba @ f69d9db9d46322a71761c7f98da21a3da8c5dbe4

mGBA Game Boy Advance Emulator

src/gba/rr/mgm.h (view raw)

 1/* Copyright (c) 2013-2015 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 RR_MGM_H
 7#define RR_MGM_H
 8
 9#include "util/common.h"
10
11#include "gba/supervisor/rr.h"
12
13struct GBA;
14struct VDir;
15struct VFile;
16
17enum GBAMGMTag {
18	// Playback tags
19	TAG_INVALID = 0x00,
20	TAG_INPUT = 0x01,
21	TAG_FRAME = 0x02,
22	TAG_LAG = 0x03,
23
24	// Stream chunking tags
25	TAG_BEGIN = 0x10,
26	TAG_END = 0x11,
27	TAG_PREVIOUSLY = 0x12,
28	TAG_NEXT_TIME = 0x13,
29	TAG_MAX_STREAM = 0x14,
30
31	// Recording information tags
32	TAG_FRAME_COUNT = 0x20,
33	TAG_LAG_COUNT = 0x21,
34	TAG_RR_COUNT = 0x22,
35	TAG_INIT = 0x24,
36	TAG_INIT_EX_NIHILO = 0x24 | INIT_EX_NIHILO,
37	TAG_INIT_FROM_SAVEGAME = 0x24 | INIT_FROM_SAVEGAME,
38	TAG_INIT_FROM_SAVESTATE = 0x24 | INIT_FROM_SAVESTATE,
39	TAG_INIT_FROM_BOTH = 0x24 | INIT_FROM_BOTH,
40
41	// User metadata tags
42	TAG_AUTHOR = 0x30,
43	TAG_COMMENT = 0x31,
44
45	TAG_EOF = INT_MAX
46};
47
48struct GBAMGMContext {
49	struct GBARRContext d;
50
51	// Playback state
52	bool isPlaying;
53	bool autorecord;
54
55	// Recording state
56	bool isRecording;
57	bool inputThisFrame;
58
59	// Metadata
60	uint32_t streamId;
61
62	uint32_t maxStreamId;
63	off_t maxStreamIdOffset;
64	off_t initFromOffset;
65	off_t rrCountOffset;
66
67	// Streaming state
68	struct VDir* streamDir;
69	struct VFile* metadataFile;
70	struct VFile* movieStream;
71	uint16_t currentInput;
72	enum GBAMGMTag peekedTag;
73	uint32_t nextTime;
74	uint32_t previously;
75};
76
77void GBAMGMContextCreate(struct GBAMGMContext*);
78
79bool GBAMGMSetStream(struct GBAMGMContext* mgm, struct VDir* stream);
80bool GBAMGMCreateStream(struct GBAMGMContext* mgm, enum GBARRInitFrom initFrom);
81
82#endif