10
#include "input/zapper.h"
11
#include "utils/guid.h"
19
//an ARCHAIC flag which means the movie was recorded from a soft reset.
20
//WHY would you do this?? do not create any new movies with this flag
21
MOVIE_FLAG_FROM_RESET = (1<<1),
23
MOVIE_FLAG_PAL = (1<<2),
25
//movie was recorded from poweron. the alternative is from a savestate (or from reset)
26
MOVIE_FLAG_FROM_POWERON = (1<<3),
28
// set in newer version, used for old movie compatibility
29
//TODO - only use this flag to print a warning that the sync might be bad
30
//so that we can get rid of the sync hack code
31
MOVIE_FLAG_NOSYNCHACK = (1<<4)
36
int movie_version; // version of the movie format in the file
38
uint32 rerecord_count;
39
bool poweron, pal, nosynchack;
40
bool reset; //mbg 6/21/08 - this flag isnt used anymore.. but maybe one day we can scan it out of the first record in the movie file
41
uint32 emu_version_used; // 9813 = 0.98.13
42
MD5DATA md5_of_rom_used;
43
std::string name_of_rom_used;
45
std::vector<std::wstring> comments;
46
std::vector<std::string> subtitles;
50
void FCEUMOV_AddInputState();
51
void FCEUMOV_AddCommand(int cmd);
52
void FCEU_DrawMovies(uint8 *);
53
void FCEU_DrawLagCounter(uint8 *);
57
MOVIEMODE_INACTIVE = 1,
67
MOVIECMD_FDS_INSERT = 4,
68
MOVIECMD_FDS_SELECT = 8
71
EMOVIEMODE FCEUMOV_Mode();
72
bool FCEUMOV_Mode(EMOVIEMODE modemask);
73
bool FCEUMOV_Mode(int modemask);
74
inline bool FCEUMOV_IsPlaying() { return FCEUMOV_Mode(MOVIEMODE_PLAY); }
75
inline bool FCEUMOV_IsRecording() { return FCEUMOV_Mode(MOVIEMODE_RECORD); }
77
bool FCEUMOV_ShouldPause(void);
78
int FCEUMOV_GetFrame(void);
79
int FCEUI_GetLagCount(void);
80
bool FCEUI_GetLagged(void);
82
int FCEUMOV_WriteState(std::ostream* os);
83
bool FCEUMOV_ReadState(std::istream* is, uint32 size);
84
void FCEUMOV_PreLoad();
85
bool FCEUMOV_PostLoad();
87
void FCEUMOV_EnterTasEdit();
88
void FCEUMOV_ExitTasEdit();
95
ValueArray<uint8,4> joysticks;
102
//misc commands like reset, etc.
103
//small now to save space; we might need to support more commands later.
104
//the disk format will support up to 64bit if necessary
106
bool command_reset() { return (commands&MOVIECMD_RESET)!=0; }
107
bool command_power() { return (commands&MOVIECMD_POWER)!=0; }
108
bool command_fds_insert() { return (commands&MOVIECMD_FDS_INSERT)!=0; }
109
bool command_fds_select() { return (commands&MOVIECMD_FDS_SELECT)!=0; }
111
void toggleBit(int joy, int bit)
113
joysticks[joy] ^= mask(bit);
116
void setBit(int joy, int bit)
118
joysticks[joy] |= mask(bit);
121
void clearBit(int joy, int bit)
123
joysticks[joy] &= ~mask(bit);
126
void setBitValue(int joy, int bit, bool val)
128
if(val) setBit(joy,bit);
129
else clearBit(joy,bit);
132
bool checkBit(int joy, int bit)
134
return (joysticks[joy] & mask(bit))!=0;
139
//a waste of memory in lots of cases.. maybe make it a pointer later?
140
std::vector<char> savestate;
142
void parse(MovieData* md, std::istream* is);
143
bool parseBinary(MovieData* md, std::istream* is);
144
void dump(MovieData* md, std::ostream* os, int index);
145
void dumpBinary(MovieData* md, std::ostream* os, int index);
146
void parseJoy(std::istream* is, uint8& joystate);
147
void dumpJoy(std::ostream* os, uint8 joystate);
149
static const char mnemonics[8];
152
int mask(int bit) { return 1<<bit; }
163
//todo - somehow force mutual exclusion for poweron and reset (with an error in the parser)
166
std::string romFilename;
167
std::vector<char> savestate;
168
std::vector<MovieRecord> records;
169
std::vector<std::wstring> comments;
170
std::vector<std::string> subtitles;
171
//this is the RERECORD COUNT. please rename variable.
175
//was the frame data stored in binary?
178
//which ports are defined for the movie
180
//whether fourscore is enabled
183
//----TasEdit stuff---
187
int getNumRecords() { return records.size(); }
189
class TDictionary : public std::map<std::string,std::string>
192
bool containsKey(std::string key)
194
return find(key) != end();
197
void tryInstallBool(std::string key, bool& val)
200
val = atoi(operator [](key).c_str())!=0;
203
void tryInstallString(std::string key, std::string& val)
206
val = operator [](key);
209
void tryInstallInt(std::string key, int& val)
212
val = atoi(operator [](key).c_str());
217
void truncateAt(int frame);
218
void installValue(std::string& key, std::string& val);
219
int dump(std::ostream* os, bool binary);
220
void clearRecordRange(int start, int len);
221
void insertEmpty(int at, int frames);
223
static bool loadSavestateFrom(std::vector<char>* buf);
224
static void dumpSavestateTo(std::vector<char>* buf, int compressionLevel);
225
void TryDumpIncremental();
228
void installInt(std::string& val, int& var)
230
var = atoi(val.c_str());
233
void installBool(std::string& val, bool& var)
235
var = atoi(val.c_str())!=0;
239
extern MovieData currMovieData;
240
extern int currFrameCounter;
241
extern char curMovieFilename[512];
242
extern bool subtitlesOnAVI;
243
extern bool freshMovie;
244
extern bool movie_readonly;
245
extern bool autoMovieBackup;
246
//--------------------------------------------------
247
bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
248
void FCEUI_MakeBackupMovie(bool dispMessage);
249
void FCEUI_CreateMovieFile(std::string fn);
250
void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author);
251
bool FCEUI_LoadMovie(const char *fname, bool read_only, bool tasedit, int _stopframe);
252
void FCEUI_MoviePlayFromBeginning(void);
253
void FCEUI_StopMovie(void);
254
bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount = false);
255
char* FCEUI_MovieGetCurrentName(int addSlotNumber);
256
void FCEUI_MovieToggleReadOnly(void);
257
bool FCEUI_GetMovieToggleReadOnly();
258
void FCEUI_SetMovieToggleReadOnly(bool which);
259
int FCEUI_GetMovieLength();
260
int FCEUI_GetMovieRerecordCount();
261
std::string FCEUI_GetMovieName(void);
262
void FCEUI_MovieToggleFrameDisplay();
263
void FCEUI_ToggleInputDisplay(void);
265
void LoadSubtitles(MovieData);
266
void ProcessSubtitles(void);
267
void FCEU_DisplaySubtitles(char *format, ...);