forked from braindx/vbjin-ovr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
movie.h
224 lines (177 loc) · 4.66 KB
/
movie.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#ifndef _MOVIE_H
#define _MOVIE_H
#include <vector>
#include <map>
#include <string>
#include <ostream>
#include <istream>
#include "prefix.h"
//#include "../../core.h"
//#include "utils/guid.h"
//#include "utils/md5.h"
typedef struct
{
int movie_version; // version of the movie format in the file
uint32 num_frames;
uint32 rerecord_count;
bool poweron;
uint32 emu_version_used;
// MD5DATA md5_of_rom_used;
std::string name_of_rom_used;
std::vector<std::wstring> comments;
std::vector<std::string> subtitles;
} MOVIE_INFO;
enum EMOVIEMODE
{
MOVIEMODE_INACTIVE = 1,
MOVIEMODE_RECORD = 2,
MOVIEMODE_PLAY = 4,
};
enum EMOVIECMD
{
MOVIECMD_RESET = 1,
MOVIECMD_POWER = 2,
};
//RLDUTSBAYXWEG
class MovieData;
class MovieRecord
{
public:
uint16 pad[5];
union {
struct {
uint8 x, y;
uint8 touch;
};
uint32 padding;
} touch;
//misc commands like reset, etc.
//small now to save space; we might need to support more commands later.
//the disk format will support up to 64bit if necessary
uint8 commands;
bool command_reset() { return (commands&MOVIECMD_RESET)!=0; }
bool command_power() { return (commands&MOVIECMD_POWER)!=0; }
/*
void toggleBit(int bit)
{
pad ^= mask(bit);
}
void setBit(int bit)
{
pad |= mask(bit);
}
void clearBit(int bit)
{
pad &= ~mask(bit);
}
void setBitValue(int bit, bool val)
{
if(val) setBit(bit);
else clearBit(bit);
}
bool checkBit(int bit)
{
return (pad & mask(bit))!=0;
}
*/
void clear();
//a waste of memory in lots of cases.. maybe make it a pointer later?
//std::vector<char> savestate;
void parse(MovieData* md, std::istream* is);
bool parseBinary(MovieData* md, std::istream* is);
void dump(MovieData* md, std::ostream* os, int index);
void dumpBinary(MovieData* md, std::ostream *os, int index);
void parsePad(std::istream* is, uint16& pad);
void dumpPad(std::ostream* os, uint16 pad);
static const char mnemonics[14];
private:
int mask(int bit) { return 1<<bit; }
};
class MovieData
{
public:
MovieData();
int version;
int emuVersion;
int pcecd;
//todo - somehow force mutual exclusion for poweron and reset (with an error in the parser)
// MD5DATA romChecksum;
std::string romFilename;
std::vector<char> savestate;
std::vector<MovieRecord> records;
std::vector<std::string> comments;
int rerecordCount;
// Desmume_Guid guid;
//was the frame data stored in binary?
bool binaryFlag;
int ports; //number of recorded ports
int getNumRecords() { return records.size(); }
class TDictionary : public std::map<std::string,std::string>
{
public:
bool containsKey(std::string key)
{
return find(key) != end();
}
void tryInstallBool(std::string key, bool& val)
{
if(containsKey(key))
val = atoi(operator [](key).c_str())!=0;
}
void tryInstallString(std::string key, std::string& val)
{
if(containsKey(key))
val = operator [](key);
}
void tryInstallInt(std::string key, int& val)
{
if(containsKey(key))
val = atoi(operator [](key).c_str());
}
};
void truncateAt(int frame);
void installValue(std::string& key, std::string& val);
int dump(std::ostream *os, bool binary);
void clearRecordRange(int start, int len);
void insertEmpty(int at, int frames);
static bool loadSavestateFrom(std::vector<char>* buf);
static void dumpSavestateTo(std::vector<char>* buf, int compressionLevel);
//void TryDumpIncremental();
private:
void installInt(std::string& val, int& var)
{
var = atoi(val.c_str());
}
void installBool(std::string& val, bool& var)
{
var = atoi(val.c_str())!=0;
}
};
extern int currFrameCounter;
extern EMOVIEMODE movieMode; //adelikat: main needs this for frame counter display
extern MovieData currMovieData; //adelikat: main needs this for frame counter display
void ResetFrameCount();
bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount);
void FCEUI_SaveMovie(const char *fname, std::string author, int controllers);
void FCEUI_LoadMovie(const char *fname, bool _read_only, bool tasedit, int _pauseframe);
void FCEUI_StopMovie();
void NDS_setTouchFromMovie(void);
//void mov_savestate(std::ostream* os);
//bool mov_loadstate(std::istream* is, int size);
void LoadFM2_binarychunk(MovieData& movieData, std::istream* fp, int size);
extern bool movie_readonly;
void FCEUI_MakeBackupMovie(bool dispMessage);
void ToggleReadOnly();
//#endif
//C stuff
int MovieIsActive();
void HardResetGame();
void MakeMovieStateName(const char *filename);
void PauseOrUnpause(void);
void MakeMovieStateName(const char *filename);
char* GetMovieLengthStr();
void FCEUMOV_AddInputState();
void SaveStateMovie(std::string filename);
void LoadStateMovie(char* filename);
void FCEUI_MoviePlayFromBeginning(void);
#endif