// ------------------------------------------------------------------------------------------------- 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; } }
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; }