From 5a2d97662f1aa4c9bf4d5f7c84ff837691724361 Mon Sep 17 00:00:00 2001 From: ansstuff Date: Tue, 6 Sep 2011 15:42:03 +0000 Subject: [PATCH] * red lines for lag frames, "Show lag frames" in View menu, * "||" button also cancels turbo-seeking * different method of accounting tweakCount: increment once per greenzone invalidation --- src/drivers/win/config.cpp | 2 + src/drivers/win/mapinput.cpp | 1 + src/drivers/win/res.rc | 2 + src/drivers/win/resource.h | 3 +- src/drivers/win/tasedit.cpp | 109 +++++++++++++++++++++-------------- src/drivers/win/tasedit.h | 7 ++- src/fceu.cpp | 5 +- src/movie.cpp | 9 ++- src/movie.h | 3 + 9 files changed, 92 insertions(+), 49 deletions(-) diff --git a/src/drivers/win/config.cpp b/src/drivers/win/config.cpp index 2b998988..e7ad4e57 100644 --- a/src/drivers/win/config.cpp +++ b/src/drivers/win/config.cpp @@ -68,6 +68,7 @@ extern bool oldInputDisplay; extern bool fullSaveStateLoads; extern int frameSkipAmt; extern bool TASEdit_follow_playback; +extern bool TASEdit_show_lag_frames; //window positions and sizes: extern int ChtPosX,ChtPosY; @@ -284,6 +285,7 @@ static CFGSTRUCT fceuconfig[] = { AC(AutoFireOffset), AC(DesynchAutoFire), AC(TASEdit_follow_playback), + AC(TASEdit_show_lag_frames), AC(lagCounterDisplay), AC(oldInputDisplay), AC(movieSubtitles), diff --git a/src/drivers/win/mapinput.cpp b/src/drivers/win/mapinput.cpp index aca833cf..d8d492f5 100644 --- a/src/drivers/win/mapinput.cpp +++ b/src/drivers/win/mapinput.cpp @@ -44,6 +44,7 @@ static struct { EMUCMD_LOAD_STATE, SCAN_P, }, //most people use the loadslotx / savestlotx style system which requires hogging all th F Keys. { EMUCMD_MOVIE_FRAME_DISPLAY_TOGGLE, SCAN_PERIOD, }, { EMUCMD_MOVIE_INPUT_DISPLAY_TOGGLE, SCAN_COMMA, }, + { EMUCMD_MISC_DISPLAY_LAGCOUNTER_TOGGLE, SCAN_SLASH, }, { EMUCMD_MOVIE_READONLY_TOGGLE, SCAN_Q, }, { EMUCMD_SAVE_STATE_SLOT_0, SCAN_F10 | CMD_KEY_SHIFT, }, { EMUCMD_SAVE_STATE_SLOT_1, SCAN_F1 | CMD_KEY_SHIFT, }, diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index c46da283..ae72cd95 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -246,6 +246,8 @@ BEGIN END POPUP "&View" BEGIN + MENUITEM "Show &lag frames", ID_VIEW_SHOW_LAG_FRAMES + MENUITEM SEPARATOR MENUITEM "&Follow playback", ID_VIEW_FOLLOW_PLAYBACK END POPUP "&Help" diff --git a/src/drivers/win/resource.h b/src/drivers/win/resource.h index 3b1a3ce4..09ffb911 100644 --- a/src/drivers/win/resource.h +++ b/src/drivers/win/resource.h @@ -808,6 +808,7 @@ #define ID_GAME_USECONFIG 40417 #define FCEUX_CONTEXT_GUICONFIG 40418 #define ID_VIEW_FOLLOW_PLAYBACK 40419 +#define ID_VIEW_SHOW_LAG_FRAMES 40420 #define IDC_DEBUGGER_ICONTRAY 55535 #define MW_ValueLabel2 65423 #define MW_ValueLabel1 65426 @@ -817,7 +818,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 160 -#define _APS_NEXT_COMMAND_VALUE 40420 +#define _APS_NEXT_COMMAND_VALUE 40421 #define _APS_NEXT_CONTROL_VALUE 1261 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 01b9fb3c..0cb5b9a4 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -23,6 +23,7 @@ using namespace std; int TasEdit_wndx, TasEdit_wndy; bool TASEdit_follow_playback = true; +bool TASEdit_show_lag_frames = true; string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page @@ -112,9 +113,15 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = CUR_FRAMENUM_COLOR; } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; + if (TASEdit_show_lag_frames && currMovieData.frames_flags[cell_y] && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT)) + { + // lag frame + msg->clrTextBk = LAG_FRAMENUM_COLOR; + } else + { + // green zone frame + msg->clrTextBk = GREENZONE_FRAMENUM_COLOR; + } } else msg->clrTextBk = NORMAL_FRAMENUM_COLOR; } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 0 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 2) { @@ -125,9 +132,15 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = CUR_INPUT_COLOR1; } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_INPUT_COLOR1; + if (TASEdit_show_lag_frames && currMovieData.frames_flags[cell_y] && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT)) + { + // lag frame + msg->clrTextBk = LAG_INPUT_COLOR1; + } else + { + // green zone frame + msg->clrTextBk = GREENZONE_INPUT_COLOR1; + } } else msg->clrTextBk = NORMAL_INPUT_COLOR1; } else if((cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 1 || (cell_x - COLUMN_JOYPAD1_A) / NUM_JOYPAD_BUTTONS == 3) { @@ -138,9 +151,15 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) msg->clrTextBk = CUR_INPUT_COLOR2; } else if(cell_y < currMovieData.greenZoneCount && !currMovieData.savestates[cell_y].empty()) { - // TODO: redline for lag frames - // green zone frame - msg->clrTextBk = GREENZONE_INPUT_COLOR2; + if (TASEdit_show_lag_frames && currMovieData.frames_flags[cell_y] && (currMovieData.frames_flags[cell_y] & LAG_FLAG_BIT)) + { + // lag frame + msg->clrTextBk = LAG_INPUT_COLOR2; + } else + { + // green zone frame + msg->clrTextBk = GREENZONE_INPUT_COLOR2; + } } else msg->clrTextBk = NORMAL_INPUT_COLOR2; } } @@ -264,9 +283,15 @@ void LockGreenZone(int newstart) void InvalidateGreenZone(int after) { - currMovieData.greenZoneCount = std::min(after+1,currMovieData.greenZoneCount); - if (currFrameCounter >= currMovieData.greenZoneCount) - JumpToFrame(currMovieData.greenZoneCount-1); + if (currMovieData.greenZoneCount > after+1) + { + currMovieData.greenZoneCount = after+1; + // increase tweakCount + currMovieData.tweakCount++; + InvalidateRect(hwndTasEdit,0,FALSE); + if (currFrameCounter >= currMovieData.greenZoneCount) + JumpToFrame(currMovieData.greenZoneCount-1); + } } /* A function that tries jumping to a given frame. If unsuccessful, it than tries to jump to @@ -287,7 +312,7 @@ bool JumpToFrame(int index) if (FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause(); - turbo=currMovieData.greenZoneCount+60 0) ? index-1 : 0; - //if (i >= static_cast(currMovieData.records.size())) i = currMovieData.records.size()-1; - //Search for an earlier frame with savestate - for (; i > 0; --i) - { - if (currMovieData.loadTasSavestate(i)) break; - } - // continue from the frame - currFrameCounter = i; - if (FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause(); - turbo=i+600)? index-1 : 0; + for (; i > 0; --i) { - poweron(false); - currFrameCounter=0; + if (currMovieData.loadTasSavestate(i)) break; + } + // continue from the frame + currFrameCounter = i; + if (FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause(); + turbo = (i+FRAMES_TOO_FAR < index); + pauseframe=index+1; + if (!i) + { + //starting from frame 0 + poweron(true); MovieData::dumpSavestateTo(&currMovieData.savestates[0],0); - return true; } - */ - return false; + return true; } void DoubleClick(LPNMITEMACTIVATE info) @@ -1237,6 +1248,12 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar case TASEDIT_PLAYSTOP: //Pause/Unpses (Play/Stop) movie FCEUI_ToggleEmulationPause(); + // also cancel turbo-seeking + if (FCEUI_EmulationPaused()) + { + turbo = false; + pauseframe = -1; + } break; case TASEDIT_REWIND_FULL: //rewinds to beginning of greenzone @@ -1254,6 +1271,13 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); FollowPlayback(); break; + case ID_VIEW_SHOW_LAG_FRAMES: + //switch "Show lag frames" flag + TASEdit_show_lag_frames ^= 1; + CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED); + RedrawList(); + break; + } break; } @@ -1286,6 +1310,7 @@ void DoTasEdit() hrmenu = LoadMenu(fceu_hInstance,"TASEDITCONTEXTMENUS"); // check option ticks CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED); + CheckMenuItem(hmenu, ID_VIEW_SHOW_LAG_FRAMES, TASEdit_show_lag_frames?MF_CHECKED : MF_UNCHECKED); if(hwndTasEdit) { diff --git a/src/drivers/win/tasedit.h b/src/drivers/win/tasedit.h index e02099aa..a9f4691c 100644 --- a/src/drivers/win/tasedit.h +++ b/src/drivers/win/tasedit.h @@ -1,5 +1,6 @@ #include "movie.h" +#define FRAMES_TOO_FAR 60 #define NUM_JOYPADS 4 #define NUM_JOYPAD_BUTTONS 8 // listview column names @@ -44,13 +45,13 @@ #define GREENZONE_FRAMENUM_COLOR 0xDCFFDC #define LAG_FRAMENUM_COLOR 0xDAD9FE #define NORMAL_INPUT_COLOR1 0xF0F0F0 -#define CUR_INPUT_COLOR1 0xFBEDB7 +#define CUR_INPUT_COLOR1 0xF7E9B2 #define GREENZONE_INPUT_COLOR1 0xC3FFC3 -#define LAG_INPUT_COLOR1 0xC9C3FF +#define LAG_INPUT_COLOR1 0xCCC8EE #define NORMAL_INPUT_COLOR2 0xDEDEDE #define CUR_INPUT_COLOR2 0xE4D8A8 #define GREENZONE_INPUT_COLOR2 0xAEE2AE -#define LAG_INPUT_COLOR2 0xAFAADC +#define LAG_INPUT_COLOR2 0xB8B3E2 // ----------------------------- void DoTasEdit(); diff --git a/src/fceu.cpp b/src/fceu.cpp index a02b6ed5..afa38b6e 100644 --- a/src/fceu.cpp +++ b/src/fceu.cpp @@ -706,8 +706,6 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski } - currMovieData.TryDumpIncremental(); - if (lagFlag) { lagCounter++; @@ -715,6 +713,9 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski } else justLagged = false; + // auto-savestates for TASEditor + currMovieData.TryDumpIncremental(); + if (movieSubtitles) ProcessSubtitles(); } diff --git a/src/movie.cpp b/src/movie.cpp index cd6dd5b1..842219e1 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -130,6 +130,14 @@ void MovieData::TryDumpIncremental() currMovieData.insertEmpty(-1, 1 + currFrameCounter - (int)currMovieData.records.size()); //always log savestates in taseditor mode currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION); + // also log frame_flags + if (currFrameCounter > 0) + { + if ((int)currMovieData.frames_flags.size() <= currFrameCounter) + currMovieData.frames_flags.resize(currFrameCounter+1); + // lagFlag indicates that lag was in previous frame + currMovieData.frames_flags[currFrameCounter-1] = (lagFlag)?LAG_FLAG_BIT:0; + } // update greenzone upper limit if (currMovieData.greenZoneCount <= currFrameCounter) currMovieData.greenZoneCount = currFrameCounter+1; @@ -904,7 +912,6 @@ void MovieData::storeTasSavestate(int frame, int compression_level) savestates.resize(frame+1); MovieData::dumpSavestateTo(&savestates[frame],compression_level); - tweakCount++; } //begin playing an existing movie diff --git a/src/movie.h b/src/movie.h index a2d87e5c..7f13a134 100644 --- a/src/movie.h +++ b/src/movie.h @@ -1,6 +1,8 @@ #ifndef __MOVIE_H_ #define __MOVIE_H_ +#define LAG_FLAG_BIT 1 + #include #include #include @@ -173,6 +175,7 @@ public: std::vector savestate; std::vector records; std::vector > savestates; + std::vector frames_flags; std::vector comments; std::vector subtitles; //this is the RERECORD COUNT. please rename variable.