fceux/src/movie.h

156 lines
3.1 KiB
C
Raw Normal View History

#ifndef __MOVIE_H_
#define __MOVIE_H_
2008-05-28 07:41:49 +00:00
#include <vector>
#include <map>
#include <string>
#include <ostream>
2008-05-28 07:41:49 +00:00
void FCEUMOV_AddJoy(uint8 *, int SkipFlush);
void FCEUMOV_AddCommand(int cmd);
void FCEU_DrawMovies(uint8 *);
enum EMOVIEMODE
{
MOVIEMODE_INACTIVE = 1,
MOVIEMODE_RECORD = 2,
MOVIEMODE_PLAY = 4,
MOVIEMODE_TASEDIT = 8
};
EMOVIEMODE FCEUMOV_Mode();
bool FCEUMOV_Mode(EMOVIEMODE modemask);
bool FCEUMOV_Mode(int modemask);
bool FCEUMOV_ShouldPause(void);
int FCEUMOV_GetFrame(void);
int FCEUMOV_WriteState(FILE* st);
int FCEUMOV_WriteState(std::ostream* os);
2008-05-26 00:03:20 +00:00
bool FCEUMOV_ReadState(FILE* st, uint32 size);
void FCEUMOV_PreLoad();
bool FCEUMOV_PostLoad();
void FCEUMOV_EnterTasEdit();
void FCEUMOV_ExitTasEdit();
2008-05-28 07:41:49 +00:00
class MovieRecord
{
public:
ValueArray<uint8,4> joysticks;
void toggleBit(int joy, int bit)
{
joysticks[joy] ^= mask(bit);
}
void setBit(int joy, int bit)
{
joysticks[joy] |= mask(bit);
}
void clearBit(int joy, int bit)
{
joysticks[joy] &= ~mask(bit);
}
void setBitValue(int joy, int bit, bool val)
{
if(val) setBit(joy,bit);
else clearBit(joy,bit);
}
bool checkBit(int joy, int bit)
{
return (joysticks[joy] & mask(bit))!=0;
2008-05-28 07:41:49 +00:00
}
void clear() {
*(uint32*)&joysticks = 0;
}
//a waste of memory in lots of cases.. maybe make it a pointer later?
2008-06-03 05:01:07 +00:00
std::vector<char> savestate;
2008-05-28 07:41:49 +00:00
void dump(FILE* fp, int index);
void dump(std::ostream* os, int index);
2008-05-28 07:41:49 +00:00
static const char mnemonics[8];
private:
int mask(int bit) { return 1<<bit; }
2008-05-28 07:41:49 +00:00
};
class MovieData
{
public:
MovieData();
int version;
int emuVersion;
2008-05-28 07:41:49 +00:00
//todo - somehow force mutual exclusion for poweron and reset (with an error in the parser)
bool palFlag;
bool poweronFlag;
bool resetFlag;
MD5DATA romChecksum;
std::string romFilename;
2008-06-03 05:01:07 +00:00
std::vector<char> savestate;
2008-05-28 07:41:49 +00:00
std::vector<MovieRecord> records;
//this is the RERECORD COUNT. please rename variable.
2008-05-28 07:41:49 +00:00
int recordCount;
FCEU_Guid guid;
//----TasEdit stuff---
int greenZoneCount;
//----
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);
2008-05-29 01:09:38 +00:00
void installDictionary(TDictionary& dictionary);
2008-05-28 07:41:49 +00:00
void dump(FILE *fp);
void dump(std::ostream* os);
2008-05-28 07:41:49 +00:00
int dumpLen();
void clearRecordRange(int start, int len);
2008-06-03 05:01:07 +00:00
static bool loadSavestateFrom(std::vector<char>* buf);
static void dumpSavestateTo(std::vector<char>* buf, int compressionLevel);
2008-05-28 07:41:49 +00:00
void TryDumpIncremental();
};
extern MovieData currMovieData;
extern int currFrameCounter;
//---------
#endif //__MOVIE_H_