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