all repos — mgba @ 51ad9d37e1cbba22d81d9bcddfe9ad8d7c6de1c2

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 "util/common.h"
  5
  6struct GBA;
  7struct VDir;
  8struct VFile;
  9
 10enum GBARRInitFrom {
 11	INIT_EX_NIHILO = 0,
 12	INIT_FROM_SAVEGAME = 1,
 13	INIT_FROM_SAVESTATE = 2,
 14	INIT_FROM_BOTH = 3,
 15};
 16
 17enum GBARRTag {
 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 GBARRContext {
 49	// Playback state
 50	bool isPlaying;
 51	bool autorecord;
 52
 53	// Recording state
 54	bool isRecording;
 55	bool inputThisFrame;
 56
 57	// Metadata
 58	uint32_t frames;
 59	uint32_t lagFrames;
 60	uint32_t streamId;
 61
 62	uint32_t maxStreamId;
 63	off_t maxStreamIdOffset;
 64
 65	enum GBARRInitFrom initFrom;
 66	off_t initFromOffset;
 67
 68	uint32_t rrCount;
 69	off_t rrCountOffset;
 70
 71	struct VFile* savedata;
 72
 73	// Streaming state
 74	struct VDir* streamDir;
 75	struct VFile* metadataFile;
 76	struct VFile* movieStream;
 77	uint16_t currentInput;
 78	enum GBARRTag peekedTag;
 79	uint32_t nextTime;
 80	uint32_t previously;
 81};
 82
 83void GBARRContextCreate(struct GBA*);
 84void GBARRContextDestroy(struct GBA*);
 85void GBARRSaveState(struct GBA*);
 86void GBARRLoadState(struct GBA*);
 87
 88bool GBARRInitStream(struct GBARRContext*, struct VDir*);
 89bool GBARRReinitStream(struct GBARRContext*, enum GBARRInitFrom);
 90bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId);
 91bool GBARRIncrementStream(struct GBARRContext*, bool recursive);
 92bool GBARRFinishSegment(struct GBARRContext*);
 93bool GBARRSkipSegment(struct GBARRContext*);
 94bool GBARRMarkRerecord(struct GBARRContext*);
 95
 96bool GBARRStartPlaying(struct GBARRContext*, bool autorecord);
 97void GBARRStopPlaying(struct GBARRContext*);
 98bool GBARRStartRecording(struct GBARRContext*);
 99void GBARRStopRecording(struct GBARRContext*);
100
101bool GBARRIsPlaying(struct GBARRContext*);
102bool GBARRIsRecording(struct GBARRContext*);
103
104void GBARRNextFrame(struct GBARRContext*);
105void GBARRLogInput(struct GBARRContext*, uint16_t input);
106uint16_t GBARRQueryInput(struct GBARRContext*);
107
108#endif