本文整理汇总了C++中MovieData类的典型用法代码示例。如果您正苦于以下问题:C++ MovieData类的具体用法?C++ MovieData怎么用?C++ MovieData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MovieData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FCEUI_MakeBackupMovie
void FCEUI_MakeBackupMovie(bool dispMessage)
{
//This function generates backup movie files
string currentFn; //Current movie fillename
string backupFn; //Target backup filename
string tempFn; //temp used in back filename creation
stringstream stream;
int x; //Temp variable for string manip
bool exist = false; //Used to test if filename exists
bool overflow = false; //Used for special situation when backup numbering exceeds limit
currentFn = curMovieFilename; //Get current moviefilename
backupFn = curMovieFilename; //Make backup filename the same as current moviefilename
x = backupFn.find_last_of("."); //Find file extension
backupFn = backupFn.substr(0,x); //Remove extension
tempFn = backupFn; //Store the filename at this point
for (unsigned int backNum=0;backNum<999;backNum++) //999 = arbituary limit to backup files
{
stream.str(""); //Clear stream
if (backNum > 99)
stream << "-" << backNum; //assign backNum to stream
else if (backNum <= 99 && backNum >= 10)
stream << "-0" << backNum; //Make it 010, etc if two digits
else
stream << "-00" << backNum; //Make it 001, etc if single digit
backupFn.append(stream.str()); //add number to bak filename
backupFn.append(".bak"); //add extension
exist = CheckFileExists(backupFn.c_str()); //Check if file exists
if (!exist)
break; //Yeah yeah, I should use a do loop or something
else
{
backupFn = tempFn; //Before we loop again, reset the filename
if (backNum == 999) //If 999 exists, we have overflowed, let's handle that
{
backupFn.append("-001.bak"); //We are going to simply overwrite 001.bak
overflow = true; //Flag that we have exceeded limit
break; //Just in case
}
}
}
MovieData md = currMovieData; //Get current movie data
EMUFILE* outf = new EMUFILE_FILE(backupFn.c_str(),"wb"); //FCEUD_UTF8_fstream(backupFn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
//TODO, decide if fstream successfully opened the file and print error message if it doesn't
if (dispMessage) //If we should inform the user
{
// if (overflow)
// FCEUI_DispMessage("Backup overflow, overwriting %s",backupFn.c_str()); //Inform user of overflow
// else
// FCEUI_DispMessage("%s created",backupFn.c_str()); //Inform user of backup filename
}
}
示例2: CheckTimelines
bool CheckTimelines(MovieData& stateMovie, MovieData& currMovie, int& errorFr)
{
bool isInTimeline = true;
int length;
//First check, make sure we are checking is for a post-movie savestate, we just want to adjust the length for now, we will handle this situation later in another function
if (currFrameCounter <= stateMovie.getNumRecords())
length = currFrameCounter; //Note: currFrameCounter corresponds to the framecounter in the savestate
else if (currFrameCounter > currMovie.getNumRecords()) //Now that we know the length of the records of the savestate we plan to load, let's match the length against the movie
length = currMovie.getNumRecords(); //If length < currMovie records then this is a "future" event from the current movie, againt we will handle this situation later, we just want to find the right number of frames to compare
else
length = stateMovie.getNumRecords();
for (int x = 0; x < length; x++)
{
if (!stateMovie.records[x].Compare(currMovie.records[x]))
{
isInTimeline = false;
errorFr = x;
break;
}
}
return isInTimeline;
}
示例3: FCEUI_CreateMovieFile
void FCEUI_CreateMovieFile(std::string fn)
{
MovieData md = currMovieData; //Get current movie data
EMUFILE* outf = FCEUD_UTF8_fstream(fn, "wb"); //open/create file
md.dump(outf,false); //dump movie data
delete outf; //clean up, delete file object
}
示例4: FCEUI_SaveMovie
//begin recording a new movie
//TODO - BUG - the record-from-another-savestate doesnt work.
static void FCEUI_SaveMovie(const char *fname, std::wstring author)
{
//if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE))
// return;
assert(fname);
FCEUI_StopMovie();
openRecordingMovie(fname);
currFrameCounter = 0;
//LagCounterReset();
currMovieData = MovieData();
currMovieData.guid.newGuid();
if(author != L"") currMovieData.comments.push_back(L"author " + author);
//currMovieData.romChecksum = GameInfo->MD5;
//currMovieData.romFilename = FileBase;
//todo ?
//poweron(true);
//else
// MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION);
//we are going to go ahead and dump the header. from now on we will only be appending frames
currMovieData.dump(osRecordingMovie, false);
movieMode = MOVIEMODE_RECORD;
movie_readonly = false;
currRerecordCount = 0;
//FCEU_DispMessage("Movie recording started.");
}
示例5: FCEUMOV_WriteState
int FCEUMOV_WriteState(EMUFILE* os)
{
//we are supposed to dump the movie data into the savestate
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_FINISHED)
return currMovieData.dump(os, true);
else return 0;
}
示例6: FCEUMOV_WriteState
static int FCEUMOV_WriteState(std::ostream* os)
{
//we are supposed to dump the movie data into the savestate
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
return currMovieData.dump(os, true);
else return 0;
}
示例7: mov_savestate
void mov_savestate(std::ostream *os)//std::ostream* os
{
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
{
write32lemov(kMOVI,os);
currMovieData.dump(os, true);
}
else
{
write32lemov(kNOMO,os);
}
}
示例8: mov_savestate
void mov_savestate(EMUFILE* fp)
{
//we are supposed to dump the movie data into the savestate
//if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
// return currMovieData.dump(os, true);
//else return 0;
if(movieMode != MOVIEMODE_INACTIVE)
{
write32le(kMOVI,fp);
currMovieData.dump(fp, true);
}
else
{
write32le(kNOMO,fp);
}
}
示例9: SaveMovie
//begin recording a new movie
//TODO - BUG - the record-from-another-savestate doesnt work.
void SaveMovie(const char *fname, std::string author, int controllers)
{
assert(fname);
StopMovie();
openRecordingMovie(fname);
currFrameCounter = 0;
//LagCounterReset();
currMovieData = MovieData();
// currMovieData.guid.newGuid();
if(author != "") currMovieData.comments.push_back("author " + author);
//currMovieData.romChecksum = GameInfo->MD5;
// currMovieData.romFilename = cdip->gamename;//GetRomName();
// extern bool _HACK_DONT_STOPMOVIE;
// _HACK_DONT_STOPMOVIE = true;
pcejin.lagFrameCounter = 0;
pcejin.isLagFrame = false;
PCE_Power();
// _HACK_DONT_STOPMOVIE = false;
currMovieData.ports = controllers;
//todo ?
//poweron(true);
//else
// MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION);
//we are going to go ahead and dump the header. from now on we will only be appending frames
currMovieData.dump(osRecordingMovie, false);
movieMode = MOVIEMODE_RECORD;
movie_readonly = false;
currRerecordCount = 0;
ClearPCESRAM();
LagFrameCounter=0;
DisplayMessage("Movie recording started.");
}
示例10: FCEUI_SaveMovie
//begin recording a new movie
//TODO - BUG - the record-from-another-savestate doesnt work.
void FCEUI_SaveMovie(const char *fname, EMOVIE_FLAG flags, std::wstring author)
{
if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE))
return;
assert(fname);
FCEUI_StopMovie();
openRecordingMovie(fname);
currFrameCounter = 0;
LagCounterReset();
FCEUMOV_CreateCleanMovie();
#ifndef _GLIBCXX_USE_WCHAR_T
if(author != "") currMovieData.comments.push_back("author " + author);
#else
if(author != L"") currMovieData.comments.push_back(L"author " + author);
#endif
if(flags & MOVIE_FLAG_FROM_POWERON)
{
movieFromPoweron = true;
poweron(true);
}
else
{
movieFromPoweron = false;
MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION);
}
FCEUMOV_ClearCommands();
//we are going to go ahead and dump the header. from now on we will only be appending frames
currMovieData.dump(osRecordingMovie, false);
movieMode = MOVIEMODE_RECORD;
movie_readonly = false;
FCEU_DispMessage("Movie recording started.",0);
}
示例11: mov_loadstate
bool mov_loadstate(EMUFILE* fp, int size)
{
load_successful = false;
u32 cookie;
if(read32le(&cookie,fp) != 1) return false;
if(cookie == kNOMO)
{
if(movieMode == MOVIEMODE_RECORD || movieMode == MOVIEMODE_PLAY)
FinishPlayback();
return true;
}
else if(cookie != kMOVI)
return false;
size -= 4;
if (!movie_readonly && autoMovieBackup && freshMovie) //If auto-backup is on, movie has not been altered this session and the movie is in read+write mode
{
FCEUI_MakeBackupMovie(false); //Backup the movie before the contents get altered, but do not display messages
}
//a little rule: cant load states in read+write mode with a movie from an archive.
//so we are going to switch it to readonly mode in that case
// if(!movie_readonly
// //*&& FCEU_isFileInArchive(curMovieFilename)*/
// ) {
// FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only.");
// movie_readonly = true;
// }
MovieData tempMovieData = MovieData();
//int curr = fp->ftell();
if(!LoadFM2(tempMovieData, fp, size, false)) {
// is->seekg((uint32)curr+size);
/* extern bool FCEU_state_loading_old_format;
if(FCEU_state_loading_old_format) {
if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) {
FCEUI_StopMovie();
FCEU_PrintError("You have tried to use an old savestate while playing a movie. This is unsupported (since the old savestate has old-format movie data in it which can't be converted on the fly)");
}
}*/
return false;
}
//----------------
//complex TAS logic for loadstate
//fully conforms to the savestate logic documented in the Laws of TAS
//http://tasvideos.org/LawsOfTAS/OnSavestates.html
//----------------
/*
Playback or Recording + Read-only
* Check that GUID of movie and savestate-movie must match or else error
o on error: a message informing that the savestate doesn't belong to this movie. This is a GUID mismatch error. Give user a choice to load it anyway.
+ failstate: if use declines, loadstate attempt canceled, movie can resume as if not attempted if user has backup savstates enabled else stop movie
* Check that movie and savestate-movie are in same timeline. If not then this is a wrong timeline error.
o on error: a message informing that the savestate doesn't belong to this movie
+ failstate: loadstate attempt canceled, movie can resume as if not attempted if user has backup savestates enabled else stop movie
* Check that savestate-movie is not greater than movie. If not then this is a future event error and is not allowed in read-only
o on error: message informing that the savestate is from a frame after the last frame of the movie
+ failstate - loadstate attempt cancelled, movie can resume if user has backup savesattes enabled, else stop movie
* Check that savestate framcount <= savestate movie length. If not this is a post-movie savestate
o on post-movie: See post-movie event section.
* All error checks have passed, state will be loaded
* Movie contained in the savestate will be discarded
* Movie is now in Playback mode
Playback, Recording + Read+write
* Check that GUID of movie and savestate-movie must match or else error
o on error: a message informing that the savestate doesn't belong to this movie. This is a GUID mismatch error. Give user a choice to load it anyway.
+ failstate: if use declines, loadstate attempt canceled, movie can resume as if not attempted (stop movie if resume fails)canceled, movie can resume if backup savestates enabled else stopmovie
* Check that savestate framcount <= savestate movie length. If not this is a post-movie savestate
o on post-movie: See post-movie event section.
* savestate passed all error checks and will now be loaded in its entirety and replace movie (note: there will be no truncation yet)
* current framecount will be set to savestate framecount
* on the next frame of input, movie will be truncated to framecount
o (note: savestate-movie can be a future event of the movie timeline, or a completely new timeline and it is still allowed)
* Rerecord count of movie will be incremented
* Movie is now in record mode
Post-movie savestate event
* Whan a savestate is loaded and is determined that the savestate-movie length is less than the savestate framecount then it is a post-movie savestate. These occur when a savestate was made during Movie Finished mode.
* If read+write, the entire savestate movie will be loaded and replace current movie.
* If read-only, the savestate movie will be discarded
* Mode will be switched to Move Finished
* Savestate will be loaded
* Current framecount changes to savestate framecount
* User will have control of input as if Movie inactive mode
*/
if(movieMode != MOVIEMODE_INACTIVE)
{
//handle moviefile mismatch
if(tempMovieData.guid != currMovieData.guid)
//.........这里部分代码省略.........
示例12: FCEUMOV_ReadState
static bool FCEUMOV_ReadState(std::istream* is, uint32 size)
{
load_successful = false;
//a little rule: cant load states in read+write mode with a movie from an archive.
//so we are going to switch it to readonly mode in that case
if(!movie_readonly
//*&& FCEU_isFileInArchive(curMovieFilename)*/
) {
FCEU_PrintError("Cannot loadstate in Read+Write with movie from archive. Movie is now Read-Only.");
movie_readonly = true;
}
MovieData tempMovieData = MovieData();
std::ios::pos_type curr = is->tellg();
if(!LoadFM2(tempMovieData, is, size, false)) {
/*is->seekg((uint32)curr+size);
extern bool FCEU_state_loading_old_format;
if(FCEU_state_loading_old_format) {
if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD) {
FCEUI_StopMovie();
FCEU_PrintError("You have tried to use an old savestate while playing a movie. This is unsupported (since the old savestate has old-format movie data in it which can't be converted on the fly)");
}
}*/
return false;
}
//complex TAS logic for when a savestate is loaded:
//----------------
//if we are playing or recording and toggled read-only:
// then, the movie we are playing must match the guid of the one stored in the savestate or else error.
// the savestate is assumed to be in the same timeline as the current movie.
// if the current movie is not long enough to get to the savestate's frame#, then it is an error.
// the movie contained in the savestate will be discarded.
// the emulator will be put into play mode.
//if we are playing or recording and toggled read+write
// then, the movie we are playing must match the guid of the one stored in the savestate or else error.
// the movie contained in the savestate will be loaded into memory
// the frames in the movie after the savestate frame will be discarded
// the in-memory movie will have its rerecord count incremented
// the in-memory movie will be dumped to disk as fcm.
// the emulator will be put into record mode.
//if we are doing neither:
// then, we must discard this movie and just load the savestate
if(movieMode == MOVIEMODE_PLAY || movieMode == MOVIEMODE_RECORD)
{
//handle moviefile mismatch
if(tempMovieData.guid != currMovieData.guid)
{
//mbg 8/18/08 - this code can be used to turn the error message into an OK/CANCEL
#ifdef WIN32
//std::string msg = "There is a mismatch between savestate's movie and current movie.\ncurrent: " + currMovieData.guid.toString() + "\nsavestate: " + tempMovieData.guid.toString() + "\n\nThis means that you have loaded a savestate belonging to a different movie than the one you are playing now.\n\nContinue loading this savestate anyway?";
//extern HWND pwindow;
//int result = MessageBox(pwindow,msg.c_str(),"Error loading savestate",MB_OKCANCEL);
//if(result == IDCANCEL)
// return false;
#else
FCEU_PrintError("Mismatch between savestate's movie and current movie.\ncurrent: %s\nsavestate: %s\n",currMovieData.guid.toString().c_str(),tempMovieData.guid.toString().c_str());
return false;
#endif
}
closeRecordingMovie();
if(movie_readonly)
{
//if the frame counter is longer than our current movie, then error
if(currFrameCounter > (int)currMovieData.records.size())
{
FCEU_PrintError("Savestate is from a frame (%d) after the final frame in the movie (%d). This is not permitted.", currFrameCounter, currMovieData.records.size()-1);
return false;
}
movieMode = MOVIEMODE_PLAY;
}
else
{
//truncate before we copy, just to save some time
tempMovieData.truncateAt(currFrameCounter);
currMovieData = tempMovieData;
#ifdef _S9XLUA_H
if(!FCEU_LuaRerecordCountSkip())
currRerecordCount++;
#endif
currMovieData.rerecordCount = currRerecordCount;
openRecordingMovie(curMovieFilename);
currMovieData.dump(osRecordingMovie, false);
movieMode = MOVIEMODE_RECORD;
}
}
load_successful = true;
//// Maximus: Show the last input combination entered from the
//// movie within the state
//.........这里部分代码省略.........
示例13: FCEUI_SaveMovie
//begin recording a new movie
//TODO - BUG - the record-from-another-savestate doesnt work.
void FCEUI_SaveMovie(const char *fname, std::wstring author, int flag, std::string sramfname, const DateTime &rtcstart)
{
//if(!FCEU_IsValidUI(FCEUI_RECORDMOVIE))
// return;
assert(fname);
FCEUI_StopMovie();
openRecordingMovie(fname);
currFrameCounter = 0;
//LagCounterReset();
currMovieData = MovieData();
currMovieData.guid.newGuid();
if(author != L"") currMovieData.comments.push_back(L"author " + author);
currMovieData.romChecksum = gameInfo.crc;
currMovieData.romSerial = gameInfo.ROMserial;
currMovieData.romFilename = path.GetRomName();
currMovieData.rtcStart = rtcstart;
// reset firmware (some games can write to it)
if (CommonSettings.UseExtFirmware == false)
{
NDS_CreateDummyFirmware(&CommonSettings.InternalFirmConf);
}
NDS_Reset();
//todo ?
//poweron(true);
//else
// MovieData::dumpSavestateTo(&currMovieData.savestate,Z_BEST_COMPRESSION);
if(flag == 1)
EMUFILE::readAllBytes(&currMovieData.sram, sramfname);
//we are going to go ahead and dump the header. from now on we will only be appending frames
currMovieData.dump(osRecordingMovie, false);
currFrameCounter=0;
lagframecounter=0;
LagFrameFlag=0;
lastLag=0;
TotalLagFrames=0;
movieMode = MOVIEMODE_RECORD;
movie_readonly = false;
currRerecordCount = 0;
MMU_new.backupDevice.movie_mode();
if(currMovieData.sram.size() != 0)
{
bool success = MovieData::loadSramFrom(&currMovieData.sram);
if(!success) return;
}
driver->USR_InfoMessage("Movie recording started.");
}
示例14: LoadFM2
//yuck... another custom text parser.
bool LoadFM2(MovieData& movieData, EMUFILE* fp, int size, bool stopAfterHeader)
{
//TODO - start with something different. like 'desmume movie version 1"
int curr = fp->ftell();
//movie must start with "version 1"
char buf[9];
curr = fp->ftell();
fp->fread(buf,9);
fp->fseek(curr, SEEK_SET);
// if(fp->fail()) return false;
if(memcmp(buf,"version 1",9))
return false;
std::string key,value;
enum {
NEWLINE, KEY, SEPARATOR, VALUE, RECORD, COMMENT
} state = NEWLINE;
bool bail = false;
for(;;)
{
bool iswhitespace, isrecchar, isnewline;
int c;
if(size--<=0) goto bail;
c = fp->fgetc();
if(c == -1)
goto bail;
iswhitespace = (c==' '||c=='\t');
isrecchar = (c=='|');
isnewline = (c==10||c==13);
if(isrecchar && movieData.binaryFlag && !stopAfterHeader)
{
LoadFM2_binarychunk(movieData, fp, size);
return true;
}
switch(state)
{
case NEWLINE:
if(isnewline) goto done;
if(iswhitespace) goto done;
if(isrecchar)
goto dorecord;
//must be a key
key = "";
value = "";
goto dokey;
break;
case RECORD:
{
dorecord:
if (stopAfterHeader) return true;
int currcount = movieData.records.size();
movieData.records.resize(currcount+1);
int preparse = fp->ftell();
movieData.records[currcount].parse(&movieData, fp);
int postparse = fp->ftell();
size -= (postparse-preparse);
state = NEWLINE;
break;
}
case KEY:
dokey: //dookie
state = KEY;
if(iswhitespace) goto doseparator;
if(isnewline) goto commit;
key += c;
break;
case SEPARATOR:
doseparator:
state = SEPARATOR;
if(isnewline) goto commit;
if(!iswhitespace) goto dovalue;
break;
case VALUE:
dovalue:
state = VALUE;
if(isnewline) goto commit;
value += c;
break;
case COMMENT:
default:
break;
}
goto done;
bail:
bail = true;
if(state == VALUE) goto commit;
goto done;
commit:
movieData.installValue(key,value);
state = NEWLINE;
done: ;
if(bail) break;
}
return true;
}
示例15: main
//.........这里部分代码省略.........
g_config->getOption("SDL.InputCfg", &s);
if(s.size() != 0)
{
InitVideo(GameInfo);
InputCfg(s);
}
// set the FAMICOM PAD 2 Mic thing
{
int t;
g_config->getOption("SDL.Input.FamicomPad2.EnableMic", &t);
if(t)
replaceP2StartWithMicrophone = t;
}
// update the input devices
UpdateInput(g_config);
// check for a .fcm file to convert to .fm2
g_config->getOption ("SDL.FCMConvert", &s);
g_config->setOption ("SDL.FCMConvert", "");
if (!s.empty())
{
int okcount = 0;
std::string infname = s.c_str();
// produce output filename
std::string outname;
size_t dot = infname.find_last_of (".");
if (dot == std::string::npos)
outname = infname + ".fm2";
else
outname = infname.substr(0,dot) + ".fm2";
MovieData md;
EFCM_CONVERTRESULT result = convert_fcm (md, infname);
if (result == FCM_CONVERTRESULT_SUCCESS) {
okcount++;
// *outf = new EMUFILE;
EMUFILE_FILE* outf = FCEUD_UTF8_fstream (outname, "wb");
md.dump (outf,false);
delete outf;
FCEUD_Message ("Your file has been converted to FM2.\n");
}
else {
FCEUD_Message ("Something went wrong while converting your file...\n");
}
DriverKill();
SDL_Quit();
return 0;
}
// If x/y res set to 0, store current display res in SDL.LastX/YRes
int yres, xres;
g_config->getOption("SDL.XResolution", &xres);
g_config->getOption("SDL.YResolution", &yres);
#if SDL_VERSION_ATLEAST(2, 0, 0)
// TODO _ SDL 2.0
#else
const SDL_VideoInfo* vid_info = SDL_GetVideoInfo();
if(xres == 0)
{
if(vid_info != NULL)
{
g_config->setOption("SDL.LastXRes", vid_info->current_w);