all repos — mgba @ 76d486cc655cd2f0943c336cfaa8f930a0687b15

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