diff --git a/desmume/src/movie.cpp b/desmume/src/movie.cpp index 0cbd1f42e..bed4beb02 100644 --- a/desmume/src/movie.cpp +++ b/desmume/src/movie.cpp @@ -671,4 +671,25 @@ bool FCEUMOV_PostLoad(void) return true; else return load_successful; -} \ No newline at end of file +} + + +bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount) +{ + //MovieData md; + //if(!LoadFM2(md, fp, INT_MAX, skipFrameCount)) + // return false; + // + //info.movie_version = md.version; + //info.poweron = md.savestate.size()==0; + //info.pal = md.palFlag; + //info.nosynchack = true; + //info.num_frames = md.records.size(); + //info.md5_of_rom_used = md.romChecksum; + //info.emu_version_used = md.emuVersion; + //info.name_of_rom_used = md.romFilename; + //info.rerecord_count = md.rerecordCount; + //info.comments = md.comments; + + return true; +} diff --git a/desmume/src/movie.h b/desmume/src/movie.h new file mode 100644 index 000000000..571193122 --- /dev/null +++ b/desmume/src/movie.h @@ -0,0 +1,183 @@ +#ifndef __MOVIE_H_ +#define __MOVIE_H_ + +#include +#include +#include +#include +#include + +#include "utils/guid.h" +#include "utils/md5.h" + +typedef struct +{ + int movie_version; // version of the movie format in the file + u32 num_frames; + u32 rerecord_count; + bool poweron; + u32 emu_version_used; + MD5DATA md5_of_rom_used; + std::string name_of_rom_used; + + std::vector comments; +} MOVIE_INFO; + +enum EMOVIEMODE +{ + MOVIEMODE_INACTIVE = 1, + MOVIEMODE_RECORD = 2, + MOVIEMODE_PLAY = 4, +}; + +enum EMOVIECMD +{ + MOVIECMD_RESET = 1, +}; + +//RLDUTSBAYXWEG + +class MovieData; +class MovieRecord +{ + +public: + u16 pad; + + union { + struct { + u8 x, y; + u8 touch; + }; + + u32 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; } + + 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 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, u16& pad); + void dumpPad(std::ostream* os, u16 pad); + + static const char mnemonics[13]; + +private: + int mask(int bit) { return 1< savestate; + std::vector records; + std::vector comments; + + int rerecordCount; + Desmume_Guid guid; + + //was the frame data stored in binary? + bool binaryFlag; + + int getNumRecords() { return records.size(); } + + class TDictionary : public std::map + { + 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* buf); + static void dumpSavestateTo(std::vector* 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; + } +}; + +bool FCEUI_MovieGetInfo(std::istream* fp, MOVIE_INFO& info, bool skipFrameCount); + +#endif