* Taseditor: cleaned up AdjustUp and AdjustDown logic
* updated docs [[Split portion of a mixed commit.]]
This commit is contained in:
parent
35541256d7
commit
c9b850a472
|
@ -1,3 +1,4 @@
|
|||
11-Aug-2012 - AnS - new Lua function: emu.setlagflag()
|
||||
11-Aug-2012 - AnS - Debugger: deleting a breakpoint leaves selection in the Breakpoints list
|
||||
06-Aug-2012 - AnS - added "Use Custom Palette" checkbox to Palette config
|
||||
06-Aug-2012 - AnS - Debugger: special strings (NMI/IRQ/etc) can be also used in "Seek To" field and Bookmarks
|
||||
|
|
Binary file not shown.
|
@ -27,9 +27,11 @@ Greenzone - Access zone
|
|||
extern TASEDITOR_CONFIG taseditor_config;
|
||||
extern TASEDITOR_PROJECT project;
|
||||
extern PLAYBACK playback;
|
||||
extern HISTORY history;
|
||||
extern BOOKMARKS bookmarks;
|
||||
extern MARKERS_MANAGER markers_manager;
|
||||
extern PIANO_ROLL piano_roll;
|
||||
extern SPLICER splicer;
|
||||
extern SELECTION selection;
|
||||
|
||||
extern char lagFlag;
|
||||
|
||||
|
@ -57,9 +59,8 @@ void GREENZONE::reset()
|
|||
}
|
||||
void GREENZONE::update()
|
||||
{
|
||||
// keep collecting savestates, this function should be called at the end of every frame
|
||||
if (greenZoneCount <= currFrameCounter || (int)savestates.size() <= currFrameCounter || !savestates[currFrameCounter].size() || laglog.GetSize() < currFrameCounter)
|
||||
CollectCurrentState();
|
||||
// keep collecting savestates, this function must be called at the end of every frame
|
||||
CollectCurrentState();
|
||||
|
||||
// run cleaning from time to time
|
||||
if (clock() > next_cleaning_time)
|
||||
|
@ -75,10 +76,13 @@ void GREENZONE::CollectCurrentState()
|
|||
if ((int)savestates.size() < greenZoneCount)
|
||||
savestates.resize(greenZoneCount);
|
||||
|
||||
// if frame changed - log savestate
|
||||
EMUFILE_MEMORY ms(&savestates[currFrameCounter]);
|
||||
FCEUSS_SaveMS(&ms, Z_DEFAULT_COMPRESSION);
|
||||
ms.trim();
|
||||
// if frame is not saved - log savestate
|
||||
if (!savestates[currFrameCounter].size())
|
||||
{
|
||||
EMUFILE_MEMORY ms(&savestates[currFrameCounter]);
|
||||
FCEUSS_SaveMS(&ms, Z_DEFAULT_COMPRESSION);
|
||||
ms.trim();
|
||||
}
|
||||
|
||||
// also log lag frames
|
||||
if (currFrameCounter > 0)
|
||||
|
@ -91,11 +95,11 @@ void GREENZONE::CollectCurrentState()
|
|||
if (old_lagFlag && !lagFlag)
|
||||
{
|
||||
// there's no more lag on previous frame - shift Input up
|
||||
splicer.AdjustUp(currFrameCounter - 1);
|
||||
AdjustUp();
|
||||
} else if (!old_lagFlag && lagFlag)
|
||||
{
|
||||
// there's new lag on previous frame - shift Input down
|
||||
splicer.AdjustDown(currFrameCounter - 1);
|
||||
AdjustDown();
|
||||
} else
|
||||
{
|
||||
// old_lagFlag == lagFlag
|
||||
|
@ -382,6 +386,81 @@ error:
|
|||
return true;
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
void GREENZONE::AdjustUp()
|
||||
{
|
||||
int at = currFrameCounter - 1; // at = the frame above currFrameCounter
|
||||
bool markers_changed = false;
|
||||
// delete one frame of lag
|
||||
currMovieData.records.erase(currMovieData.records.begin() + at);
|
||||
laglog.EraseFrame(at);
|
||||
if (taseditor_config.bind_markers)
|
||||
{
|
||||
if (markers_manager.EraseMarker(at))
|
||||
markers_changed = true;
|
||||
}
|
||||
// check if user deleted all frames
|
||||
if (!currMovieData.getNumRecords())
|
||||
playback.StartFromZero();
|
||||
// reduce Piano Roll
|
||||
piano_roll.UpdateItemCount();
|
||||
// register changes
|
||||
int first_input_chanes = history.RegisterAdjustLag(at, -1);
|
||||
// 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_chanes >= 0 && first_input_chanes < currFrameCounter) || (laglog.GetLagInfoAtFrame(at)))
|
||||
{
|
||||
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
|
||||
Invalidate(at);
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.GetPauseFrame();
|
||||
playback.jump(at);
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.SeekingStart(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.PauseEmulation();
|
||||
} else
|
||||
{
|
||||
// just invalidate Greenzone after currFrameCounter
|
||||
Invalidate(currFrameCounter);
|
||||
}
|
||||
if (markers_changed)
|
||||
selection.must_find_current_marker = playback.must_find_current_marker = true;
|
||||
}
|
||||
void GREENZONE::AdjustDown()
|
||||
{
|
||||
int at = currFrameCounter - 1;
|
||||
bool markers_changed = false;
|
||||
// insert blank frame with lag
|
||||
currMovieData.insertEmpty(at, 1);
|
||||
laglog.InsertFrame(at, true, 1);
|
||||
if (taseditor_config.bind_markers)
|
||||
{
|
||||
if (markers_manager.insertEmpty(at, 1))
|
||||
markers_changed = true;
|
||||
}
|
||||
// register changes
|
||||
int first_input_chanes = history.RegisterAdjustLag(at, +1);
|
||||
// if Input in the frame above currFrameCounter has changed then invalidate Greenzone (rewind 1 frame back)
|
||||
if (first_input_chanes >= 0 && first_input_chanes < currFrameCounter)
|
||||
{
|
||||
// custom invalidation procedure, not retriggering LostPosition/PauseFrame
|
||||
Invalidate(at);
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.GetPauseFrame();
|
||||
playback.jump(at);
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.SeekingStart(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.PauseEmulation();
|
||||
} else
|
||||
{
|
||||
// just invalidate Greenzone after currFrameCounter
|
||||
Invalidate(currFrameCounter);
|
||||
}
|
||||
if (markers_changed)
|
||||
selection.must_find_current_marker = playback.must_find_current_marker = true;
|
||||
}
|
||||
// -------------------------------------------------------------------------------------------------
|
||||
// invalidate and restore playback
|
||||
void GREENZONE::InvalidateAndCheck(int after)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,9 @@ public:
|
|||
void save(EMUFILE *os, bool really_save = true);
|
||||
bool load(EMUFILE *is, bool really_load = true);
|
||||
|
||||
void AdjustUp();
|
||||
void AdjustDown();
|
||||
|
||||
bool loadTasSavestate(int frame);
|
||||
|
||||
void RunGreenzoneCleaning();
|
||||
|
|
|
@ -639,7 +639,7 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, int size, const c
|
|||
}
|
||||
return first_changes;
|
||||
}
|
||||
void HISTORY::RegisterAdjustLag(int start, int size)
|
||||
int HISTORY::RegisterAdjustLag(int start, int size)
|
||||
{
|
||||
// create new shanshot
|
||||
SNAPSHOT snap;
|
||||
|
@ -656,9 +656,7 @@ void HISTORY::RegisterAdjustLag(int start, int size)
|
|||
snap.start_frame = current_snap.start_frame;
|
||||
snap.end_frame = current_snap.end_frame;
|
||||
snap.consecutive_tag = current_snap.consecutive_tag;
|
||||
// make sure that consecutive Recordings work even when there's AdjustUp inbetween
|
||||
//if (current_snap.mod_type == MODTYPE_RECORD && size < 0 && current_snap.consecutive_tag == first_changes)
|
||||
// snap.consecutive_tag--;
|
||||
//if (current_snap.mod_type == MODTYPE_RECORD && size < 0 && current_snap.consecutive_tag == first_changes) snap.consecutive_tag--; // make sure that consecutive Recordings work even when there's AdjustUp inbetween
|
||||
snap.rec_joypad_diff_bits = current_snap.rec_joypad_diff_bits;
|
||||
snap.mod_type = current_snap.mod_type;
|
||||
strcpy(snap.description, current_snap.description);
|
||||
|
@ -679,6 +677,7 @@ void HISTORY::RegisterAdjustLag(int start, int size)
|
|||
branches.ChangesMadeSinceBranch();
|
||||
project.SetProjectChanged();
|
||||
}
|
||||
return first_changes;
|
||||
}
|
||||
void HISTORY::RegisterMarkersChange(int mod_type, int start, int end, const char* comment)
|
||||
{
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
void redo();
|
||||
|
||||
int RegisterChanges(int mod_type, int start = 0, int end =-1, int size = 0, const char* comment = NULL, int consecutive_tag = 0, SelectionFrames* frameset = NULL);
|
||||
void RegisterAdjustLag(int start, int size);
|
||||
int RegisterAdjustLag(int start, int size);
|
||||
void RegisterMarkersChange(int mod_type, int start = 0, int end =-1, const char* comment = 0);
|
||||
|
||||
void RegisterBookmarkSet(int slot, BOOKMARK& backup_copy, int old_current_branch);
|
||||
|
|
|
@ -674,72 +674,6 @@ bool SPLICER::PasteInsert()
|
|||
CloseClipboard();
|
||||
return result;
|
||||
}
|
||||
|
||||
// these two functions don't restore Playback cursor, they only invalidate Greenzone
|
||||
void SPLICER::AdjustUp(int at)
|
||||
{
|
||||
if (at < 0)
|
||||
return;
|
||||
bool markers_changed = false;
|
||||
// delete one frame of lag
|
||||
currMovieData.records.erase(currMovieData.records.begin() + at);
|
||||
greenzone.laglog.EraseFrame(at);
|
||||
if (taseditor_config.bind_markers)
|
||||
{
|
||||
if (markers_manager.EraseMarker(at))
|
||||
markers_changed = true;
|
||||
}
|
||||
// check if user deleted all frames
|
||||
if (!currMovieData.getNumRecords())
|
||||
playback.StartFromZero();
|
||||
// reduce Piano Roll
|
||||
piano_roll.UpdateItemCount();
|
||||
// register changes
|
||||
history.RegisterAdjustLag(at, -1);
|
||||
greenzone.Invalidate(at);
|
||||
// rewind, because maybe next frame also needs lag removal
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.GetPauseFrame();
|
||||
playback.jump(currFrameCounter - 1);
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.SeekingStart(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.PauseEmulation();
|
||||
if (markers_changed)
|
||||
selection.must_find_current_marker = playback.must_find_current_marker = true;
|
||||
}
|
||||
void SPLICER::AdjustDown(int at)
|
||||
{
|
||||
if (at < 0)
|
||||
return;
|
||||
bool markers_changed = false;
|
||||
// insert blank frame with lag
|
||||
currMovieData.insertEmpty(at, 1);
|
||||
greenzone.laglog.InsertFrame(at, true, 1);
|
||||
if (taseditor_config.bind_markers)
|
||||
{
|
||||
if (markers_manager.insertEmpty(at, 1))
|
||||
markers_changed = true;
|
||||
}
|
||||
// register changes
|
||||
history.RegisterAdjustLag(at, +1);
|
||||
greenzone.Invalidate(at + 1);
|
||||
/*
|
||||
// this would be needed if "changes of Input in lag frames" were affecting game Output
|
||||
// but since they don't affect it, we can keep current frame savestate in the Greenzone, and only truncate the Greenzone starting from next frame
|
||||
greenzone.Invalidate(at);
|
||||
// rewind
|
||||
bool emu_was_paused = (FCEUI_EmulationPaused() != 0);
|
||||
int saved_pause_frame = playback.GetPauseFrame();
|
||||
playback.jump(currFrameCounter - 1);
|
||||
if (saved_pause_frame >= 0)
|
||||
playback.SeekingStart(saved_pause_frame);
|
||||
if (emu_was_paused)
|
||||
playback.PauseEmulation();
|
||||
*/
|
||||
if (markers_changed)
|
||||
selection.must_find_current_marker = playback.must_find_current_marker = true;
|
||||
}
|
||||
// ----------------------------------------------------------------------------------------------
|
||||
// retrieves some information from clipboard to clipboard_selection
|
||||
void SPLICER::CheckClipboard()
|
||||
|
|
|
@ -19,9 +19,6 @@ public:
|
|||
bool Paste();
|
||||
bool PasteInsert();
|
||||
|
||||
void AdjustUp(int at);
|
||||
void AdjustDown(int at);
|
||||
|
||||
void RedrawTextClipboard();
|
||||
|
||||
SelectionFrames& GetClipboardSelection();
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue