2006-07-29 05:46:15 +00:00
|
|
|
#ifndef __MOVIE_H_
|
|
|
|
#define __MOVIE_H_
|
|
|
|
|
2008-05-28 07:41:49 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2008-06-02 14:02:02 +00:00
|
|
|
#include <ostream>
|
2008-05-28 07:41:49 +00:00
|
|
|
|
2008-06-06 08:23:12 +00:00
|
|
|
#include "input/zapper.h"
|
2008-06-17 06:55:07 +00:00
|
|
|
#include "utils/guid.h"
|
2008-06-06 08:23:12 +00:00
|
|
|
|
2008-06-08 10:22:33 +00:00
|
|
|
void FCEUMOV_AddInputState();
|
2006-07-29 05:46:15 +00:00
|
|
|
void FCEUMOV_AddCommand(int cmd);
|
|
|
|
void FCEU_DrawMovies(uint8 *);
|
2008-06-05 06:49:11 +00:00
|
|
|
|
|
|
|
enum EMOVIEMODE
|
|
|
|
{
|
|
|
|
MOVIEMODE_INACTIVE = 1,
|
|
|
|
MOVIEMODE_RECORD = 2,
|
|
|
|
MOVIEMODE_PLAY = 4,
|
|
|
|
MOVIEMODE_TASEDIT = 8
|
|
|
|
};
|
|
|
|
|
2008-06-12 05:07:30 +00:00
|
|
|
enum EMOVIECMD
|
|
|
|
{
|
|
|
|
MOVIECMD_RESET = 1,
|
|
|
|
};
|
|
|
|
|
2008-06-05 06:49:11 +00:00
|
|
|
EMOVIEMODE FCEUMOV_Mode();
|
|
|
|
bool FCEUMOV_Mode(EMOVIEMODE modemask);
|
|
|
|
bool FCEUMOV_Mode(int modemask);
|
|
|
|
|
2008-05-23 09:58:38 +00:00
|
|
|
bool FCEUMOV_ShouldPause(void);
|
2006-07-29 05:46:15 +00:00
|
|
|
int FCEUMOV_GetFrame(void);
|
|
|
|
|
2008-06-02 14:02:02 +00:00
|
|
|
int FCEUMOV_WriteState(std::ostream* os);
|
2008-06-17 06:55:07 +00:00
|
|
|
bool FCEUMOV_ReadState(std::istream* is, uint32 size);
|
2008-06-05 06:49:11 +00:00
|
|
|
void FCEUMOV_PreLoad();
|
|
|
|
bool FCEUMOV_PostLoad();
|
|
|
|
|
|
|
|
void FCEUMOV_EnterTasEdit();
|
|
|
|
void FCEUMOV_ExitTasEdit();
|
2006-07-29 05:46:15 +00:00
|
|
|
|
2008-06-09 08:15:20 +00:00
|
|
|
class MovieData;
|
2008-05-28 07:41:49 +00:00
|
|
|
class MovieRecord
|
|
|
|
{
|
2008-06-09 08:15:20 +00:00
|
|
|
|
2008-05-28 07:41:49 +00:00
|
|
|
public:
|
|
|
|
ValueArray<uint8,4> joysticks;
|
2008-06-06 08:23:12 +00:00
|
|
|
|
|
|
|
struct {
|
2008-06-19 03:26:37 +00:00
|
|
|
uint8 x,y,b,bogo;
|
2008-06-06 08:23:12 +00:00
|
|
|
} zappers[2];
|
2008-05-28 07:41:49 +00:00
|
|
|
|
2008-06-12 05:07:30 +00:00
|
|
|
//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; }
|
|
|
|
|
2008-05-28 07:41:49 +00:00
|
|
|
void toggleBit(int joy, int bit)
|
|
|
|
{
|
2008-05-30 05:11:35 +00:00
|
|
|
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
|
|
|
|
2008-06-09 08:15:20 +00:00
|
|
|
void parse(MovieData* md, std::istream* is);
|
|
|
|
void dump(MovieData* md, std::ostream* os, int index);
|
|
|
|
void parseJoy(std::istream* is, uint8& joystate);
|
|
|
|
void dumpJoy(std::ostream* os, uint8 joystate);
|
|
|
|
|
2008-05-28 07:41:49 +00:00
|
|
|
static const char mnemonics[8];
|
2008-05-30 05:11:35 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int mask(int bit) { return 1<<bit; }
|
2008-05-28 07:41:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MovieData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MovieData();
|
|
|
|
|
|
|
|
|
|
|
|
int version;
|
2008-06-06 01:21:51 +00:00
|
|
|
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;
|
2008-05-30 05:11:35 +00:00
|
|
|
//this is the RERECORD COUNT. please rename variable.
|
2008-05-28 07:41:49 +00:00
|
|
|
int recordCount;
|
|
|
|
FCEU_Guid guid;
|
2008-06-09 08:15:20 +00:00
|
|
|
|
|
|
|
//which ports are defined for the movie
|
|
|
|
int ports[3];
|
|
|
|
//whether fourscore is enabled
|
|
|
|
bool fourscore;
|
2008-05-28 07:41:49 +00:00
|
|
|
|
|
|
|
//----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-06-09 08:15:20 +00:00
|
|
|
void installValue(std::string& key, std::string& val);
|
2008-06-17 07:55:27 +00:00
|
|
|
int dump(std::ostream* os);
|
2008-05-28 07:41:49 +00:00
|
|
|
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();
|
2008-06-09 08:15:20 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2008-05-28 07:41:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern MovieData currMovieData;
|
|
|
|
extern int currFrameCounter;
|
|
|
|
//---------
|
|
|
|
|
|
|
|
#endif //__MOVIE_H_
|