* Total overhaul of JumpToFrame function and of TryDumpIncremental routine (logging savestates), now TAS Editor is more stable
* replay.cpp: fixed bug when trying to open Replay without having ROM loaded
This commit is contained in:
parent
2a75b9b8e8
commit
9a76571490
|
@ -1007,5 +1007,5 @@ void Replay_LoadMovie(bool tasedit)
|
||||||
/// Show movie replay dialog and replay the movie if necessary.
|
/// Show movie replay dialog and replay the movie if necessary.
|
||||||
void FCEUD_MovieReplayFrom()
|
void FCEUD_MovieReplayFrom()
|
||||||
{
|
{
|
||||||
Replay_LoadMovie(false);
|
if (GameInfo) Replay_LoadMovie(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "main.h" //For the GetRomName() function
|
#include "main.h" //For the GetRomName() function
|
||||||
//#include "config.h"
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -23,7 +22,7 @@ using namespace std;
|
||||||
//http://forums.devx.com/archive/index.php/t-37234.html
|
//http://forums.devx.com/archive/index.php/t-37234.html
|
||||||
|
|
||||||
int TasEdit_wndx, TasEdit_wndy;
|
int TasEdit_wndx, TasEdit_wndy;
|
||||||
bool TASEdit_follow_playback = false;
|
bool TASEdit_follow_playback = true;
|
||||||
|
|
||||||
string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page
|
string tasedithelp = "{16CDE0C4-02B0-4A60-A88D-076319909A4D}"; //Name of TASEdit Help page
|
||||||
|
|
||||||
|
@ -178,20 +177,14 @@ void UpdateTasEdit()
|
||||||
ListView_SetItemCountEx(hwndList,currMovieData.getNumRecords(),LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL);
|
ListView_SetItemCountEx(hwndList,currMovieData.getNumRecords(),LVSICF_NOSCROLL | LVSICF_NOINVALIDATEALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
//update the cursor when playing
|
//update the cursor
|
||||||
int newCursor = currFrameCounter;
|
if(currFrameCounter != lastCursor)
|
||||||
if(newCursor != lastCursor)
|
|
||||||
{
|
{
|
||||||
/* if (!FCEUI_EmulationPaused())
|
|
||||||
//select the row
|
|
||||||
ListView_SetItemState(hwndList,newCursor,LVIS_FOCUSED|LVIS_SELECTED,LVIS_FOCUSED|LVIS_SELECTED);
|
|
||||||
*/
|
|
||||||
//scroll to the row
|
|
||||||
if (TASEdit_follow_playback) ListView_EnsureVisible(hwndList,newCursor,FALSE);
|
|
||||||
//update the old and new rows
|
//update the old and new rows
|
||||||
ListView_Update(hwndList,newCursor);
|
|
||||||
ListView_Update(hwndList,lastCursor);
|
ListView_Update(hwndList,lastCursor);
|
||||||
lastCursor = newCursor;
|
ListView_Update(hwndList,currFrameCounter);
|
||||||
|
lastCursor = currFrameCounter;
|
||||||
|
FollowPlayback();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int old_movie_readonly=-1;
|
static int old_movie_readonly=-1;
|
||||||
|
@ -285,11 +278,12 @@ bool JumpToFrame(int index)
|
||||||
{
|
{
|
||||||
if (index<0) return false;
|
if (index<0) return false;
|
||||||
|
|
||||||
/* Handle jumps outside greenzone. */
|
if (index >= currMovieData.greenZoneCount)
|
||||||
if (index>currMovieData.greenZoneCount)
|
|
||||||
{
|
{
|
||||||
|
/* Handle jumps outside greenzone. */
|
||||||
if (JumpToFrame(currMovieData.greenZoneCount-1))
|
if (JumpToFrame(currMovieData.greenZoneCount-1))
|
||||||
{
|
{
|
||||||
|
// continue from the end of greenzone
|
||||||
if (FCEUI_EmulationPaused())
|
if (FCEUI_EmulationPaused())
|
||||||
FCEUI_ToggleEmulationPause();
|
FCEUI_ToggleEmulationPause();
|
||||||
|
|
||||||
|
@ -300,42 +294,34 @@ bool JumpToFrame(int index)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/* Handle jumps inside greenzone. */
|
||||||
if (static_cast<unsigned int>(index)<currMovieData.records.size() &&
|
if (currMovieData.loadTasSavestate(index))
|
||||||
currMovieData.loadTasSavestate(index))
|
|
||||||
{
|
{
|
||||||
currFrameCounter = index;
|
currFrameCounter = index;
|
||||||
return true;
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
int i = (index > 0) ? index-1 : 0;
|
||||||
|
//if (i >= static_cast<int>(currMovieData.records.size())) i = currMovieData.records.size()-1;
|
||||||
|
//Search for an earlier frame with savestate
|
||||||
|
for (; i > 0; --i)
|
||||||
|
{
|
||||||
|
if (currMovieData.loadTasSavestate(i)) break;
|
||||||
}
|
}
|
||||||
else
|
// continue from the frame
|
||||||
{
|
currFrameCounter = i;
|
||||||
/* Disable pause. */
|
if (FCEUI_EmulationPaused()) FCEUI_ToggleEmulationPause();
|
||||||
if (FCEUI_EmulationPaused())
|
|
||||||
FCEUI_ToggleEmulationPause();
|
|
||||||
|
|
||||||
int i = index>0? index-1:0;
|
|
||||||
if (i>=static_cast<int>(currMovieData.records.size()))
|
|
||||||
i=currMovieData.records.size()-1;
|
|
||||||
|
|
||||||
/* Search for an earlier frame, and try warping to the current. */
|
|
||||||
for (; i>0; --i)
|
|
||||||
{
|
|
||||||
if (currMovieData.loadTasSavestate(i))
|
|
||||||
{
|
|
||||||
currFrameCounter=i;
|
|
||||||
turbo=i+60<index; // turbo unless close
|
turbo=i+60<index; // turbo unless close
|
||||||
pauseframe=index+1;
|
pauseframe=index+1;
|
||||||
|
if (!i)
|
||||||
|
{
|
||||||
|
//starting from frame 0
|
||||||
|
poweron(true);
|
||||||
|
MovieData::dumpSavestateTo(&currMovieData.savestates[0],0);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
/*
|
||||||
|
|
||||||
poweron(true);
|
|
||||||
currFrameCounter=0;
|
|
||||||
MovieData::dumpSavestateTo(&currMovieData.savestates[0],0);
|
|
||||||
turbo = index>60;
|
|
||||||
pauseframe=index+1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simply do a reset.
|
// Simply do a reset.
|
||||||
if (index==0)
|
if (index==0)
|
||||||
{
|
{
|
||||||
|
@ -344,7 +330,7 @@ bool JumpToFrame(int index)
|
||||||
MovieData::dumpSavestateTo(&currMovieData.savestates[0],0);
|
MovieData::dumpSavestateTo(&currMovieData.savestates[0],0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1203,8 +1189,8 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
|
|
||||||
case IDC_HACKY2:
|
case IDC_HACKY2:
|
||||||
//hacky2: delete earlier savestates (conserve memory)
|
//hacky2: delete earlier savestates (conserve memory)
|
||||||
LockGreenZone(currFrameCounter);
|
//LockGreenZone(currFrameCounter);
|
||||||
UpdateTasEdit();
|
//UpdateTasEdit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACCEL_CTRL_B:
|
case ACCEL_CTRL_B:
|
||||||
|
@ -1241,11 +1227,12 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
case TASEDIT_FOWARD:
|
case TASEDIT_FOWARD:
|
||||||
//advance 1 frame
|
//advance 1 frame
|
||||||
JumpToFrame(currFrameCounter+1);
|
JumpToFrame(currFrameCounter+1);
|
||||||
|
FollowPlayback();
|
||||||
break;
|
break;
|
||||||
case TASEDIT_REWIND:
|
case TASEDIT_REWIND:
|
||||||
//rewinds 1 frame
|
//rewinds 1 frame
|
||||||
if (currFrameCounter>0)
|
if (currFrameCounter>0) JumpToFrame(currFrameCounter-1);
|
||||||
JumpToFrame(currFrameCounter-1);
|
FollowPlayback();
|
||||||
break;
|
break;
|
||||||
case TASEDIT_PLAYSTOP:
|
case TASEDIT_PLAYSTOP:
|
||||||
//Pause/Unpses (Play/Stop) movie
|
//Pause/Unpses (Play/Stop) movie
|
||||||
|
@ -1254,15 +1241,18 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
||||||
case TASEDIT_REWIND_FULL:
|
case TASEDIT_REWIND_FULL:
|
||||||
//rewinds to beginning of greenzone
|
//rewinds to beginning of greenzone
|
||||||
JumpToFrame(FindBeginningOfGreenZone(0));
|
JumpToFrame(FindBeginningOfGreenZone(0));
|
||||||
|
FollowPlayback();
|
||||||
break;
|
break;
|
||||||
case TASEDIT_FOWARD_FULL:
|
case TASEDIT_FOWARD_FULL:
|
||||||
//moves to the end of greenzone
|
//moves to the end of greenzone
|
||||||
JumpToFrame(currMovieData.greenZoneCount-1);
|
JumpToFrame(currMovieData.greenZoneCount-1);
|
||||||
|
FollowPlayback();
|
||||||
break;
|
break;
|
||||||
case ID_VIEW_FOLLOW_PLAYBACK:
|
case ID_VIEW_FOLLOW_PLAYBACK:
|
||||||
//switch "Follow playback" flag
|
//switch "Follow playback" flag
|
||||||
TASEdit_follow_playback ^= 1;
|
TASEdit_follow_playback ^= 1;
|
||||||
CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
|
CheckMenuItem(hmenu, ID_VIEW_FOLLOW_PLAYBACK, TASEdit_follow_playback?MF_CHECKED : MF_UNCHECKED);
|
||||||
|
FollowPlayback();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1279,6 +1269,10 @@ int FindBeginningOfGreenZone(int starting_index)
|
||||||
}
|
}
|
||||||
return starting_index;
|
return starting_index;
|
||||||
}
|
}
|
||||||
|
void FollowPlayback()
|
||||||
|
{
|
||||||
|
if (TASEdit_follow_playback) ListView_EnsureVisible(hwndList,currFrameCounter,FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
void DoTasEdit()
|
void DoTasEdit()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,3 +59,4 @@ void CreateProject(MovieData data);
|
||||||
void InvalidateGreenZone(int after);
|
void InvalidateGreenZone(int after);
|
||||||
bool JumpToFrame(int index);
|
bool JumpToFrame(int index);
|
||||||
int FindBeginningOfGreenZone(int starting_index);
|
int FindBeginningOfGreenZone(int starting_index);
|
||||||
|
void FollowPlayback();
|
||||||
|
|
|
@ -125,31 +125,14 @@ void MovieData::TryDumpIncremental()
|
||||||
{
|
{
|
||||||
if(movieMode == MOVIEMODE_TASEDIT)
|
if(movieMode == MOVIEMODE_TASEDIT)
|
||||||
{
|
{
|
||||||
//only log the savestate if we are appending to the green zone
|
// if movie length is less than currFrame, pad it with empty frames
|
||||||
if (turbo && pauseframe!=-1 && static_cast<unsigned int>(currFrameCounter)<currMovieData.records.size())
|
if(currFrameCounter >= (int)currMovieData.records.size() || currMovieData.records.size()==0)
|
||||||
{
|
currMovieData.insertEmpty(-1, 1 + currFrameCounter - (int)currMovieData.records.size());
|
||||||
if (turbo && pauseframe-256>currFrameCounter && ((currFrameCounter-pauseframe)&0xff))
|
//always log savestates in taseditor mode
|
||||||
return;
|
|
||||||
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
||||||
}
|
// update greenzone upper limit
|
||||||
if(currFrameCounter == currMovieData.greenZoneCount)
|
if (currMovieData.greenZoneCount <= currFrameCounter)
|
||||||
{
|
currMovieData.greenZoneCount = currFrameCounter+1;
|
||||||
if(currFrameCounter == (int)currMovieData.records.size() || currMovieData.records.size()==0)
|
|
||||||
{
|
|
||||||
currMovieData.insertEmpty(-1,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
|
||||||
currMovieData.greenZoneCount=currFrameCounter+1;
|
|
||||||
} else if (currFrameCounter < currMovieData.greenZoneCount && !movie_readonly)
|
|
||||||
{
|
|
||||||
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
|
||||||
} else if (currFrameCounter > currMovieData.greenZoneCount && static_cast<unsigned int>(currMovieData.greenZoneCount)<currMovieData.records.size())
|
|
||||||
{
|
|
||||||
/* May be required in some malformed TAS projects. */
|
|
||||||
currMovieData.storeTasSavestate(currFrameCounter, Z_DEFAULT_COMPRESSION);
|
|
||||||
currMovieData.greenZoneCount= currFrameCounter+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue