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
52 // Streaming state
53 struct VDir* streamDir;
54 struct VFile* movieStream;
55 uint16_t currentInput;
56 enum GBARRTag peekedTag;
57 uint32_t nextTime;
58 uint32_t previously;
59};
60
61void GBARRContextCreate(struct GBA*);
62void GBARRContextDestroy(struct GBA*);
63
64bool GBARRSetStream(struct GBARRContext*, struct VDir*);
65bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId);
66bool GBARRIncrementStream(struct GBARRContext*);
67
68bool GBARRStartPlaying(struct GBARRContext*, bool autorecord);
69void GBARRStopPlaying(struct GBARRContext*);
70bool GBARRStartRecording(struct GBARRContext*);
71void GBARRStopRecording(struct GBARRContext*);
72
73bool GBARRIsPlaying(struct GBARRContext*);
74bool GBARRIsRecording(struct GBARRContext*);
75
76void GBARRNextFrame(struct GBARRContext*);
77void GBARRLogInput(struct GBARRContext*, uint16_t input);
78uint16_t GBARRQueryInput(struct GBARRContext*);
79
80#endif