all repos — mgba @ e732448aa4d7edb24095dd4c4ae2ad434c9effa2

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 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	struct VFile* savedata;
 69
 70	// Streaming state
 71	struct VDir* streamDir;
 72	struct VFile* metadataFile;
 73	struct VFile* movieStream;
 74	uint16_t currentInput;
 75	enum GBARRTag peekedTag;
 76	uint32_t nextTime;
 77	uint32_t previously;
 78};
 79
 80void GBARRContextCreate(struct GBA*);
 81void GBARRContextDestroy(struct GBA*);
 82void GBARRSaveState(struct GBA*);
 83void GBARRLoadState(struct GBA*);
 84
 85bool GBARRInitStream(struct GBARRContext*, struct VDir*);
 86bool GBARRReinitStream(struct GBARRContext*, enum GBARRInitFrom);
 87bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId);
 88bool GBARRIncrementStream(struct GBARRContext*, bool recursive);
 89bool GBARRFinishSegment(struct GBARRContext*);
 90bool GBARRSkipSegment(struct GBARRContext*);
 91
 92bool GBARRStartPlaying(struct GBARRContext*, bool autorecord);
 93void GBARRStopPlaying(struct GBARRContext*);
 94bool GBARRStartRecording(struct GBARRContext*);
 95void GBARRStopRecording(struct GBARRContext*);
 96
 97bool GBARRIsPlaying(struct GBARRContext*);
 98bool GBARRIsRecording(struct GBARRContext*);
 99
100void GBARRNextFrame(struct GBARRContext*);
101void GBARRLogInput(struct GBARRContext*, uint16_t input);
102uint16_t GBARRQueryInput(struct GBARRContext*);
103
104#endif