From dc7805cfc583c66e8786a9b7e327ce18bf7680f9 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Sun, 25 Nov 2012 09:50:46 +0000 Subject: [PATCH] * Taseditor: fixed bug in project saving * Taseditor: fixed bug in laglog truncating when no Input changes are made by inserting/deleting frames --- src/drivers/win/taseditor.cpp | 5 +++- src/drivers/win/taseditor/bookmarks.cpp | 16 ++++++------- src/drivers/win/taseditor/greenzone.cpp | 6 ++--- src/drivers/win/taseditor/history.cpp | 8 +++---- src/drivers/win/taseditor/piano_roll.cpp | 24 +++++++++---------- .../win/taseditor/taseditor_project.cpp | 2 +- 6 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/drivers/win/taseditor.cpp b/src/drivers/win/taseditor.cpp index dcd72b9a..9d6a2b5a 100644 --- a/src/drivers/win/taseditor.cpp +++ b/src/drivers/win/taseditor.cpp @@ -21,6 +21,7 @@ Main - Main gate between emulator and Taseditor #include "utils/xstring.h" #include "main.h" // for GetRomName #include "taseditor.h" +#include "window.h" #include "../../input.h" #include "../keyboard.h" #include "../joystick.h" @@ -63,7 +64,6 @@ extern int EnableAutosave; int saved_frame_display; // FCEUX extern EMOVIEMODE movieMode; // maybe we need normal setter for movieMode, to encapsulate it -extern void UpdateCheckedMenuItems(); // lua engine extern void TaseditorAutoFunction(); extern void TaseditorManualFunction(); @@ -801,6 +801,9 @@ void ApplyMovieInputConfig() PushCurrentVideoSettings(); // update PPU type newppu = currMovieData.PPUflag; + SetMainWindowText(); + // return focus to TAS Editor window + SetFocus(taseditor_window.hwndTasEditor); } // this getter contains formula to decide whether to record or replay movie diff --git a/src/drivers/win/taseditor/bookmarks.cpp b/src/drivers/win/taseditor/bookmarks.cpp index 53481758..f416fb22 100644 --- a/src/drivers/win/taseditor/bookmarks.cpp +++ b/src/drivers/win/taseditor/bookmarks.cpp @@ -667,10 +667,10 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = LAG_FRAMENUM_COLOR; else msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else if ((!greenzone.SavestateIsEmpty(frame & EVERY16TH) && !greenzone.SavestateIsEmpty((frame & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(frame & EVERY8TH) && !greenzone.SavestateIsEmpty((frame & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(frame & EVERY4TH) && !greenzone.SavestateIsEmpty((frame & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(frame & EVERY2ND) && !greenzone.SavestateIsEmpty((frame & EVERY2ND) + 2))) + } else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY8TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY4TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY2ND)) { if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES) msg->clrTextBk = PALE_LAG_FRAMENUM_COLOR; @@ -698,10 +698,10 @@ LONG BOOKMARKS::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = LAG_INPUT_COLOR1; else msg->clrTextBk = GREENZONE_INPUT_COLOR1; - } else if ((!greenzone.SavestateIsEmpty(frame & EVERY16TH) && !greenzone.SavestateIsEmpty((frame & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(frame & EVERY8TH) && !greenzone.SavestateIsEmpty((frame & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(frame & EVERY4TH) && !greenzone.SavestateIsEmpty((frame & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(frame & EVERY2ND) && !greenzone.SavestateIsEmpty((frame & EVERY2ND) + 2))) + } else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY8TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY4TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY2ND)) { if (greenzone.laglog.GetLagInfoAtFrame(frame) == LAGGED_YES) msg->clrTextBk = PALE_LAG_INPUT_COLOR1; diff --git a/src/drivers/win/taseditor/greenzone.cpp b/src/drivers/win/taseditor/greenzone.cpp index ab10125d..c360e703 100644 --- a/src/drivers/win/taseditor/greenzone.cpp +++ b/src/drivers/win/taseditor/greenzone.cpp @@ -475,14 +475,14 @@ void GREENZONE::AdjustDown() markers_changed = true; } // register changes - int first_input_chanes = history.RegisterAdjustLag(at, +1); + 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_chanes >= 0 && first_input_chanes < currFrameCounter) + if (first_input_changes >= 0 && first_input_changes < currFrameCounter) { // custom invalidation procedure, not retriggering LostPosition/PauseFrame - Invalidate(first_input_chanes); + Invalidate(first_input_changes); bool emu_was_paused = (FCEUI_EmulationPaused() != 0); int saved_pause_frame = playback.GetPauseFrame(); playback.EnsurePlaybackIsInsideGreenzone(); diff --git a/src/drivers/win/taseditor/history.cpp b/src/drivers/win/taseditor/history.cpp index 5e525f06..d909bf82 100644 --- a/src/drivers/win/taseditor/history.cpp +++ b/src/drivers/win/taseditor/history.cpp @@ -414,7 +414,7 @@ int HISTORY::JumpInTime(int new_pos) piano_roll.RedrawList(); // even though the Greenzone invalidation most likely will also sent the command to redraw // Greenzone should be invalidated after the frame of Lag changes if this frame is less than the frame of Input changes - if (first_lag_changes >= 0 && first_changes > first_lag_changes) + if (first_lag_changes >= 0 && (first_changes > first_lag_changes || first_changes < 0)) first_changes = first_lag_changes; return first_changes; } @@ -635,7 +635,7 @@ int HISTORY::RegisterChanges(int mod_type, int start, int end, int size, const c branches.ChangesMadeSinceBranch(); project.SetProjectChanged(); } - if (first_lag_changes >= 0 && first_changes > first_lag_changes) + if (first_lag_changes >= 0 && (first_changes > first_lag_changes || first_changes < 0)) first_changes = first_lag_changes; return first_changes; } @@ -793,7 +793,7 @@ int HISTORY::RegisterBranching(int slot, bool markers_changed) snap.laglog = greenzone.laglog; } // Greenzone should be invalidated after the frame of Lag changes if this frame is less than the frame of Input changes - if (first_lag_changes >= 0 && first_changes > first_lag_changes) + if (first_lag_changes >= 0 && (first_changes > first_lag_changes || first_changes < 0)) first_changes = first_lag_changes; return first_changes; } @@ -978,7 +978,7 @@ int HISTORY::RegisterLuaChanges(const char* name, int start, bool InsertionDelet branches.ChangesMadeSinceBranch(); project.SetProjectChanged(); } - if (first_lag_changes >= 0 && first_changes > first_lag_changes) + if (first_lag_changes >= 0 && (first_changes > first_lag_changes || first_changes < 0)) first_changes = first_lag_changes; return first_changes; } diff --git a/src/drivers/win/taseditor/piano_roll.cpp b/src/drivers/win/taseditor/piano_roll.cpp index 05804907..96484428 100644 --- a/src/drivers/win/taseditor/piano_roll.cpp +++ b/src/drivers/win/taseditor/piano_roll.cpp @@ -1362,10 +1362,10 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = LAG_FRAMENUM_COLOR; else msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; - } else if ((!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY8TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) + } else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY8TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY4TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY2ND)) { // the frame is in a gap (in Greenzone tail) if (frame_lag == LAGGED_YES) @@ -1421,10 +1421,10 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = LAG_INPUT_COLOR1; else msg->clrTextBk = GREENZONE_INPUT_COLOR1; - } else if ((!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY8TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) + } else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY8TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY4TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY2ND)) { // the frame is in a gap (in Greenzone tail) if (frame_lag == LAGGED_YES) @@ -1480,10 +1480,10 @@ LONG PIANO_ROLL::CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = LAG_INPUT_COLOR2; else msg->clrTextBk = GREENZONE_INPUT_COLOR2; - } else if ((!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY16TH) + 16)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY8TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY8TH) + 8)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY4TH) && !greenzone.SavestateIsEmpty((cell_y & EVERY4TH) + 4)) - || (!greenzone.SavestateIsEmpty(cell_y & EVERY2ND) && !greenzone.SavestateIsEmpty((cell_y & EVERY2ND) + 2))) + } else if (!greenzone.SavestateIsEmpty(cell_y & EVERY16TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY8TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY4TH) + || !greenzone.SavestateIsEmpty(cell_y & EVERY2ND)) { // the frame is in a gap (in Greenzone tail) if (frame_lag == LAGGED_YES) diff --git a/src/drivers/win/taseditor/taseditor_project.cpp b/src/drivers/win/taseditor/taseditor_project.cpp index 82914f61..a5bd30fe 100644 --- a/src/drivers/win/taseditor/taseditor_project.cpp +++ b/src/drivers/win/taseditor/taseditor_project.cpp @@ -140,7 +140,7 @@ bool TASEDITOR_PROJECT::save(const char* different_name, bool save_binary, bool if (save_selection) saved_stuff_map |= SELECTION_SAVED; write32le(saved_stuff_map, ofs); unsigned int number_of_pointers = DEFAULT_NUMBER_OF_POINTERS; - write32le(saved_stuff_map, ofs); + write32le(number_of_pointers, ofs); // write dummy zeros to the file, where the offsets will be for (unsigned int i = 0; i < number_of_pointers; ++i) write32le(0, ofs);