From e2248ca404bbf5588d98e8a42ab07a0507a55e89 Mon Sep 17 00:00:00 2001 From: mart0258 Date: Sun, 8 Nov 2009 05:07:28 +0000 Subject: [PATCH] win32-tasedit: Added mid-movie start for start mid-movie (WIP), and to build greenzone by fast forward. --- src/drivers/win/res.rc | 7 ++- src/drivers/win/tasedit.cpp | 99 +++++++++++++++++++++++++++++++++++-- src/input.h | 1 + src/movie.cpp | 32 +++++++----- src/movie.h | 1 + 5 files changed, 123 insertions(+), 17 deletions(-) diff --git a/src/drivers/win/res.rc b/src/drivers/win/res.rc index a481ba48..3e765eb8 100644 --- a/src/drivers/win/res.rc +++ b/src/drivers/win/res.rc @@ -7,7 +7,8 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +#include "afxres.h" + ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -1274,6 +1275,7 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_LIST1,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_OWNERDATA | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,11,324,364 PUSHBUTTON "Truncate",IDC_HACKY1,338,46,51,16,WS_DISABLED + //PUSHBUTTON "Commit",IDC_HACKY2,404,46,51,16,WS_DISABLED LTEXT "Any number of these icon buttons are pressed",IDC_STATIC,395,84,47,34 PUSHBUTTON "<",TASEDIT_REWIND,367,25,26,14,WS_DISABLED PUSHBUTTON ">",TASEDIT_FOWARD,391,25,26,14,WS_DISABLED @@ -1922,7 +1924,8 @@ IDB_TE_ARROW BITMAP "res/te_arrow.bmp" // // Generated from the TEXTINCLUDE 3 resource. // - + + ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED diff --git a/src/drivers/win/tasedit.cpp b/src/drivers/win/tasedit.cpp index 947d1fc9..e44d62d1 100644 --- a/src/drivers/win/tasedit.cpp +++ b/src/drivers/win/tasedit.cpp @@ -108,10 +108,12 @@ static LONG CustomDraw(NMLVCUSTOMDRAW* msg) case CDDS_SUBITEMPREPAINT: SelectObject(msg->nmcd.hdc,debugSystem->hFixedFont); if((msg->iSubItem-2)/8==0) - if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount) + if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount && + !currMovieData.records[msg->nmcd.dwItemSpec].savestate.empty()) msg->clrTextBk = RGB(192,255,192); else {} - else if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount) + else if((int)msg->nmcd.dwItemSpec < currMovieData.greenZoneCount && + !currMovieData.records[msg->nmcd.dwItemSpec].savestate.empty()) msg->clrTextBk = RGB(144,192,144); else msg->clrTextBk = RGB(192,192,192); return CDRF_DODEFAULT; @@ -125,6 +127,12 @@ void UpdateTasEdit() { if(!hwndTasEdit) return; + if(FCEUMOV_ShouldPause() && FCEUI_EmulationPaused()==0) + { + FCEUI_ToggleEmulationPause(); + turbo = false; + } + //update the number of items int currLVItemCount = ListView_GetItemCount(hwndList); if(currMovieData.getNumRecords() != currLVItemCount) @@ -209,11 +217,80 @@ void RightClick(LPNMITEMACTIVATE info) RightClickMenu(info); } +void LockGreenZone(int newstart) +{ + for (int i=1; icurrMovieData.greenZoneCount) + { + return JumpToFrame(currMovieData.greenZoneCount); + } + + if (!currMovieData.records[index].savestate.empty() && + MovieData::loadSavestateFrom(&currMovieData.records[index].savestate)) + { + currFrameCounter = index; + return true; + } + else + { + /* Disable pause. */ + if (FCEUI_EmulationPaused()) + FCEUI_ToggleEmulationPause(); + + /* Search for an earlier frame, and try warping to the current. */ + for (int i=index-1; i>0; --i) + { + if (!currMovieData.records[index].savestate.empty() && + MovieData::loadSavestateFrom(&currMovieData.records[index].savestate)) + { + currFrameCounter=i; + turbo=i+256256; + pauseframe=index; + } + + // Simply do a reset. + if (index==0) + { + extern int disableBatteryLoading; + disableBatteryLoading = 1; + PowerNES(); + disableBatteryLoading = 0; + currFrameCounter=0; + return true; + } + + return false; +} + void DoubleClick(LPNMITEMACTIVATE info) { int index = info->iItem; @@ -228,8 +305,7 @@ void DoubleClick(LPNMITEMACTIVATE info) //if the row is in the green zone, then move to it if(index < currMovieData.greenZoneCount) { - MovieData::loadSavestateFrom(&currMovieData.records[index].savestate); - currFrameCounter = index; + JumpToFrame(index); } } else //if an input column was clicked: @@ -244,6 +320,14 @@ void DoubleClick(LPNMITEMACTIVATE info) InvalidateGreenZone(index); + // If the change is in the past, move to it. + if(index < currFrameCounter && + index < currMovieData.greenZoneCount) + { + JumpToFrame(index); + } + + //redraw everything to show the reduced green zone RedrawList(); } @@ -522,6 +606,7 @@ void KillTasEdit() //TODO: determine if project has changed, and ask to save changes DestroyWindow(hwndTasEdit); hwndTasEdit = 0; + turbo=false; FCEUMOV_ExitTasEdit(); } @@ -809,6 +894,12 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar UpdateTasEdit(); break; + case IDC_HACKY2: + //hacky2: delete earlier savestates (conserve memory) + LockGreenZone(currFrameCounter); + UpdateTasEdit(); + break; + case ACCEL_CTRL_B: case ID_EDIT_BRANCH: case ID_CONTEXT_SELECTED_BRANCH: diff --git a/src/input.h b/src/input.h index 2d9373de..9a432e72 100644 --- a/src/input.h +++ b/src/input.h @@ -265,6 +265,7 @@ extern struct EMUCMDTABLE FCEUI_CommandTable[]; extern unsigned int lagCounter; extern bool lagCounterDisplay; extern char lagFlag; +extern bool turbo; void LagCounterReset(); #endif //_INPUT_H_ diff --git a/src/movie.cpp b/src/movie.cpp index e6c86ca5..0692b216 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -133,6 +133,9 @@ void MovieData::TryDumpIncremental() MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION); currMovieData.greenZoneCount++; + } else if (currFrameCounter < currMovieData.greenZoneCount || !movie_readonly) + { + MovieData::dumpSavestateTo(&currMovieData.records[currFrameCounter].savestate,Z_DEFAULT_COMPRESSION); } } } @@ -678,19 +681,26 @@ static void poweron(bool shouldDisableBatteryLoading) void FCEUMOV_EnterTasEdit() { - //stop any current movie activity - FCEUI_StopMovie(); + if (movieMode == MOVIEMODE_INACTIVE) + { + //stop any current movie activity + FCEUI_StopMovie(); - //clear the current movie - currFrameCounter = 0; - currMovieData = MovieData(); - currMovieData.guid.newGuid(); - currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0; - currMovieData.romChecksum = GameInfo->MD5; - currMovieData.romFilename = FileBase; + //clear the current movie + currFrameCounter = 0; + currMovieData = MovieData(); + currMovieData.guid.newGuid(); + currMovieData.palFlag = FCEUI_GetCurrentVidSystem(0,0)!=0; + currMovieData.romChecksum = GameInfo->MD5; + currMovieData.romFilename = FileBase; - //reset the rom - poweron(false); + //reset the rom + poweron(false); + } else { + FCEUI_StopMovie(); + + currMovieData.greenZoneCount=currFrameCounter; + } //todo - think about this //ResetInputTypes(); diff --git a/src/movie.h b/src/movie.h index aca2d497..215bd6ba 100644 --- a/src/movie.h +++ b/src/movie.h @@ -243,6 +243,7 @@ extern bool subtitlesOnAVI; extern bool freshMovie; extern bool movie_readonly; extern bool autoMovieBackup; +extern int pauseframe; //-------------------------------------------------- bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists void FCEUI_MakeBackupMovie(bool dispMessage);