all repos — mgba @ fabdfc86f3c944d3d61ee728d002f1c014694aaa

mGBA Game Boy Advance Emulator

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

 1#ifndef GBA_RR_H
 2#define GBA_RR_H
 3
 4#include "common.h"
 5
 6struct GBA;
 7struct VDir;
 8struct VFile;
 9
10enum GBARRTag {
11	// Playback tags
12	TAG_INVALID = 0x00,
13	TAG_INPUT = 0x01,
14	TAG_FRAME = 0x02,
15	TAG_LAG = 0x03,
16
17	// Stream chunking tags
18	TAG_BEGIN = 0x10,
19	TAG_END = 0x11,
20	TAG_PREVIOUSLY = 0x12,
21	TAG_NEXT_TIME = 0x13,
22	TAG_MAX_STREAM = 0x14,
23
24	// Recording information tags
25	TAG_FRAME_COUNT = 0x20,
26	TAG_LAG_COUNT = 0x21,
27	TAG_RR_COUNT = 0x22,
28	TAG_INIT_TYPE = 0x23,
29
30	// User metadata tags
31	TAG_AUTHOR = 0x30,
32	TAG_COMMENT = 0x31,
33
34	TAG_EOF = INT_MAX
35};
36
37struct GBARRContext {
38	// Playback state
39	bool isPlaying;
40	bool autorecord;
41
42	// Recording state
43	bool isRecording;
44	bool inputThisFrame;
45
46	// Metadata
47	uint32_t frames;
48	uint32_t lagFrames;
49	uint32_t streamId;
50	uint32_t maxStreamId;
51	off_t maxStreamIdOffset;
52
53	// Streaming state
54	struct VDir* streamDir;
55	struct VFile* metadataFile;
56	struct VFile* movieStream;
57	uint16_t currentInput;
58	enum GBARRTag peekedTag;
59	uint32_t nextTime;
60	uint32_t previously;
61};
62
63void GBARRContextCreate(struct GBA*);
64void GBARRContextDestroy(struct GBA*);
65
66bool GBARRSetStream(struct GBARRContext*, struct VDir*);
67bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId);
68bool GBARRIncrementStream(struct GBARRContext*);
69bool GBARRSkipSegment(struct GBARRContext*);
70
71bool GBARRStartPlaying(struct GBARRContext*, bool autorecord);
72void GBARRStopPlaying(struct GBARRContext*);
73bool GBARRStartRecording(struct GBARRContext*);
74void GBARRStopRecording(struct GBARRContext*);
75
76bool GBARRIsPlaying(struct GBARRContext*);
77bool GBARRIsRecording(struct GBARRContext*);
78
79void GBARRNextFrame(struct GBARRContext*);
80void GBARRLogInput(struct GBARRContext*, uint16_t input);
81uint16_t GBARRQueryInput(struct GBARRContext*);
82
83#endif