// ------------------------------------------------------------------------------------------------- void GREENZONE::adjustUp() { int at = currFrameCounter - 1; // at = the frame above currFrameCounter // find how many consequent lag frames there are int num_frames_to_erase = 0; while (lagLog.getLagInfoAtFrame(at++) == LAGGED_YES) num_frames_to_erase++; if (num_frames_to_erase > 0) { bool markers_changed = false; // delete these frames of lag currMovieData.eraseRecords(currFrameCounter - 1, num_frames_to_erase); lagLog.eraseFrame(currFrameCounter - 1, num_frames_to_erase); if (taseditorConfig.bindMarkersToInput) { if (markersManager.eraseMarker(currFrameCounter - 1, num_frames_to_erase)) markers_changed = true; } // update movie data size, because Playback cursor must always be inside the movie // if movie length is less or equal to currFrame, pad it with empty frames if (((int)currMovieData.records.size() - 1) <= currFrameCounter) currMovieData.insertEmpty(-1, currFrameCounter - ((int)currMovieData.records.size() - 1)); // update Piano Roll (reduce it if needed) pianoRoll.updateLinesCount(); // register changes int first_input_changes = history.registerAdjustLag(currFrameCounter - 1, 0 - num_frames_to_erase); // if Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back) // also if the frame above currFrameCounter is lag frame then rewind 1 frame (invalidate Greenzone), because maybe this frame also needs lag removal if ((first_input_changes >= 0 && first_input_changes < currFrameCounter) || (lagLog.getLagInfoAtFrame(currFrameCounter - 1) != LAGGED_NO)) { // custom invalidation procedure, not retriggering LostPosition/PauseFrame invalidate(first_input_changes); bool emu_was_paused = (FCEUI_EmulationPaused() != 0); int saved_pause_frame = playback.getPauseFrame(); playback.ensurePlaybackIsInsideGreenzone(); if (saved_pause_frame >= 0) playback.startSeekingToFrame(saved_pause_frame); if (emu_was_paused) playback.pauseEmulation(); } else { // just invalidate Greenzone after currFrameCounter (this is necessary in order to force user to re-emulate everything after the point, because the lag log data after the currFrameCounter is now in unknown state and it should be collected again) invalidate(currFrameCounter); } if (markers_changed) selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; } }
// invalidate and restore playback void GREENZONE::invalidateAndUpdatePlayback(int after) { if (after >= 0) { if (after >= currMovieData.getNumRecords()) after = currMovieData.getNumRecords() - 1; // clear all savestates that became irrelevant for (int i = savestates.size() - 1; i > after; i--) clearSavestateOfFrame(i); if (greenzoneSize > after + 1 || currFrameCounter > after) { greenzoneSize = after + 1; FCEUMOV_IncrementRerecordCount(); // either set Playback cursor to be inside the Greenzone or run seeking to restore Playback cursor position if (currFrameCounter >= greenzoneSize) { if (playback.getPauseFrame() >= 0 && !FCEUI_EmulationPaused()) { // emulator was running, so continue seeking, but don't follow the Playback cursor playback.jump(playback.getPauseFrame(), false, true, false); } else { playback.setLastPosition(currFrameCounter); if (taseditorConfig.autoRestoreLastPlaybackPosition) // start seeking to the green arrow, but don't follow the Playback cursor playback.jump(playback.getLastPosition(), false, true, false); else playback.ensurePlaybackIsInsideGreenzone(); } } } } // redraw Piano Roll even if Greenzone didn't change pianoRoll.redraw(); bookmarks.redrawBookmarksList(); }
void GREENZONE::adjustDown() { int at = currFrameCounter - 1; bool markers_changed = false; // clone frame and insert lag currMovieData.cloneRegion(at, 1); lagLog.insertFrame(at, true, 1); if (taseditorConfig.bindMarkersToInput) { if (markersManager.insertEmpty(at, 1)) markers_changed = true; } // register changes int first_input_changes = history.registerAdjustLag(at, +1); // If Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back) // This should never actually happen, because we clone the frame, so the Input doesn't change // But the check should remain, in case we decide to insert blank frame instead of cloning if (first_input_changes >= 0 && first_input_changes < currFrameCounter) { // custom invalidation procedure, not retriggering LostPosition/PauseFrame invalidate(first_input_changes); bool emu_was_paused = (FCEUI_EmulationPaused() != 0); int saved_pause_frame = playback.getPauseFrame(); playback.ensurePlaybackIsInsideGreenzone(); if (saved_pause_frame >= 0) playback.startSeekingToFrame(saved_pause_frame); if (emu_was_paused) playback.pauseEmulation(); } else { // just invalidate Greenzone after currFrameCounter invalidate(currFrameCounter); } if (markers_changed) selection.mustFindCurrentMarker = playback.mustFindCurrentMarker = true; }
// this getter contains formula to decide whether to record or replay movie bool isTaseditorRecording() { if (movie_readonly || playback.getPauseFrame() >= 0 || (taseditorConfig.oldControlSchemeForBranching && !recorder.stateWasLoadedInReadWriteMode)) return false; // replay return true; // record }