void GREENZONE::update() { // keep collecting savestates, this code must be executed at the end of every frame if (taseditorConfig.enableGreenzoning) { collectCurrentState(); } else { // just update Greenzone upper limit if (greenzoneSize <= currFrameCounter) greenzoneSize = currFrameCounter + 1; } // run cleaning from time to time if (clock() > nextCleaningTime) runGreenzoneCleaning(); // also log lag frames if (currFrameCounter > 0) { // lagFlag indicates that lag was in previous frame int old_lagFlag = lagLog.getLagInfoAtFrame(currFrameCounter - 1); // Auto-adjust Input according to lag if (taseditorConfig.autoAdjustInputAccordingToLag && old_lagFlag != LAGGED_UNKNOWN) { if ((old_lagFlag == LAGGED_YES) && !lagFlag) { // there's no more lag on previous frame - shift Input up 1 or more frames adjustUp(); } else if ((old_lagFlag == LAGGED_NO) && lagFlag) { // there's new lag on previous frame - shift Input down 1 frame adjustDown(); } } else { if (lagFlag && (old_lagFlag != LAGGED_YES)) { lagLog.setLagInfo(currFrameCounter - 1, true); // keep current snapshot laglog in touch history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, true); } else if (!lagFlag && old_lagFlag != LAGGED_NO) { lagLog.setLagInfo(currFrameCounter - 1, false); // keep current snapshot laglog in touch history.getCurrentSnapshot().laglog.setLagInfo(currFrameCounter - 1, false); } } } }
void createNewProject() { if (!askToSaveProject()) return; static struct NewProjectParameters params; if (DialogBoxParam(fceu_hInstance, MAKEINTRESOURCE(IDD_TASEDITOR_NEWPROJECT), taseditorWindow.hwndTASEditor, newProjectProc, (LPARAM)¶ms) > 0) { FCEUMOV_CreateCleanMovie(); // apply selected options setInputType(currMovieData, params.inputType); applyMovieInputConfig(); if (params.copyCurrentInput) // copy Input from current snapshot (from history) history.getCurrentSnapshot().inputlog.toMovie(currMovieData); if (!params.copyCurrentMarkers) markersManager.reset(); if (params.authorName != L"") currMovieData.comments.push_back(L"author " + params.authorName); // reset Taseditor project.init(); // new project has blank name greenzone.reset(); if (params.copyCurrentInput) // copy LagLog from current snapshot (from history) greenzone.lagLog = history.getCurrentSnapshot().laglog; playback.reset(); playback.restartPlaybackFromZeroGround(); bookmarks.reset(); branches.reset(); history.reset(); pianoRoll.reset(); selection.reset(); editor.reset(); splicer.reset(); recorder.reset(); popupDisplay.reset(); taseditorWindow.redraw(); taseditorWindow.updateCaption(); } }
void importInputData() { const char filter[] = "FCEUX Movie Files (*.fm2), TAS Editor Projects (*.fm3)\0*.fm2;*.fm3\0All Files (*.*)\0*.*\0\0"; OPENFILENAME ofn; memset(&ofn, 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = taseditorWindow.hwndTASEditor; ofn.hInstance = fceu_hInstance; ofn.lpstrTitle = "Import"; ofn.lpstrFilter = filter; char nameo[2048] = {0}; ofn.lpstrFile = nameo; ofn.nMaxFile = 2048; ofn.Flags = OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_FILEMUSTEXIST; string initdir = FCEU_GetPath(FCEUMKF_MOVIE); ofn.lpstrInitialDir = initdir.c_str(); if (GetOpenFileName(&ofn)) { EMUFILE_FILE ifs(nameo, "rb"); // Load Input to temporary moviedata MovieData md; if (LoadFM2(md, &ifs, ifs.size(), false)) { // loaded successfully, now register Input changes char drv[512], dir[512], name[1024], ext[512]; splitpath(nameo, drv, dir, name, ext); strcat(name, ext); int result = history.registerImport(md, name); if (result >= 0) { greenzone.invalidateAndUpdatePlayback(result); greenzone.lagLog.invalidateFromFrame(result); // keep current snapshot laglog in touch history.getCurrentSnapshot().laglog.invalidateFromFrame(result); } else { MessageBox(taseditorWindow.hwndTASEditor, "Imported movie has the same Input.\nNo changes were made.", "TAS Editor", MB_OK); } } else { FCEUD_PrintError("Error loading movie data!"); } } }