win32-tasedit: Added mid-movie start for start mid-movie (WIP), and to build greenzone by fast forward.

This commit is contained in:
mart0258 2009-11-08 05:07:28 +00:00
parent 2cf4d23994
commit e2248ca404
5 changed files with 123 additions and 17 deletions

View File

@ -8,6 +8,7 @@
// Generated from the TEXTINCLUDE 2 resource.
//
#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
@ -1923,6 +1925,7 @@ IDB_TE_ARROW BITMAP "res/te_arrow.bmp"
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -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; i<newstart; ++i)
{
currMovieData.records[i].savestate.clear();
}
}
void InvalidateGreenZone(int after)
{
currMovieData.greenZoneCount = std::min(after+1,currMovieData.greenZoneCount);
}
/* A function that tries jumping to a given frame. If unsuccessful, it than tries to jump to
a previously good frame and fastforward to it.
Returns true if a jump to the frame is made, false if nothing done.
*/
bool JumpToFrame(int index)
{
/* Work only within the greenzone. */
if (index>currMovieData.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+256<index; // turbo unless close
pauseframe=index;
return true;
}
}
extern int disableBatteryLoading;
disableBatteryLoading = 1;
PowerNES();
disableBatteryLoading = 0;
currFrameCounter=0;
turbo = index>256;
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:

View File

@ -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_

View File

@ -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);
}
}
}
@ -677,6 +680,8 @@ static void poweron(bool shouldDisableBatteryLoading)
void FCEUMOV_EnterTasEdit()
{
if (movieMode == MOVIEMODE_INACTIVE)
{
//stop any current movie activity
FCEUI_StopMovie();
@ -691,6 +696,11 @@ void FCEUMOV_EnterTasEdit()
//reset the rom
poweron(false);
} else {
FCEUI_StopMovie();
currMovieData.greenZoneCount=currFrameCounter;
}
//todo - think about this
//ResetInputTypes();

View File

@ -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);