* Tasedit: execute lua functions when jumping inside greenzone
* added rewind hotkey (~), works only in Taseditor
This commit is contained in:
parent
4ece1d273e
commit
11a99a56e3
|
@ -1531,7 +1531,7 @@ int FCEUD_TestCommandState(int c)
|
|||
// else
|
||||
// keys_nr=GetKeyboard_nr();
|
||||
}
|
||||
else if(c != EMUCMD_SPEED_TURBO) // TODO: this should be made more general by detecting if the command has an "off" function, but right now Turbo is the only command that has it
|
||||
else if(c != EMUCMD_SPEED_TURBO && c != EMUCMD_TASEDIT_REWIND) // TODO: this should be made more general by detecting if the command has an "off" function
|
||||
{
|
||||
keys=GetKeyboard_jd();
|
||||
keys_nr=GetKeyboard_nr();
|
||||
|
|
|
@ -73,6 +73,7 @@ static struct
|
|||
{ EMUCMD_RELOADROM, SCAN_R | CMD_KEY_CTRL | CMD_KEY_SHIFT , },
|
||||
{ EMUCMD_MISC_UNDOREDOSAVESTATE, SCAN_Z | CMD_KEY_CTRL, },
|
||||
{ EMUCMD_MISC_TOGGLEFULLSCREEN, SCAN_ENTER | CMD_KEY_ALT, },
|
||||
{ EMUCMD_TASEDIT_REWIND, SCAN_GRAVE, },
|
||||
};
|
||||
|
||||
#define NUM_DEFAULT_MAPPINGS (sizeof(DefaultCommandMapping)/sizeof(DefaultCommandMapping[0]))
|
||||
|
|
|
@ -24,6 +24,7 @@ using namespace std;
|
|||
int old_multitrack_recording_joypad, multitrack_recording_joypad;
|
||||
bool old_movie_readonly;
|
||||
bool TASEdit_focus = false;
|
||||
bool Tasedit_rewind_now = false;
|
||||
int listItems; // number of items per list page
|
||||
// saved FCEU config
|
||||
int saved_eoptions;
|
||||
|
@ -417,7 +418,7 @@ void SingleClick(LPNMITEMACTIVATE info)
|
|||
{
|
||||
// click on the "icons" column - jump to the frame
|
||||
ClearSelection();
|
||||
playback.JumpToFrame(row_index);
|
||||
playback.jump(row_index);
|
||||
RedrawList();
|
||||
} else if(column_index == COLUMN_FRAMENUM || column_index == COLUMN_FRAMENUM2)
|
||||
{
|
||||
|
@ -450,7 +451,7 @@ void DoubleClick(LPNMITEMACTIVATE info)
|
|||
{
|
||||
// double click sends playback to the frame
|
||||
ClearSelection();
|
||||
playback.JumpToFrame(row_index);
|
||||
playback.jump(row_index);
|
||||
RedrawList();
|
||||
} else if(column_index >= COLUMN_JOYPAD1_A && column_index <= COLUMN_JOYPAD4_R)
|
||||
{
|
||||
|
@ -1034,9 +1035,7 @@ void OpenProject()
|
|||
tempstr.append(".tas");
|
||||
splitpath(tempstr.c_str(), drv, dir, name, ext); //Split the path...
|
||||
project.SetProjectName(name);
|
||||
std::string filename = name; //Get the filename
|
||||
filename.append(ext); //Shove the extension back onto it...
|
||||
project.SetProjectFile(filename); //And update the project's filename.
|
||||
project.SetProjectFile(tempstr);
|
||||
//Set the fm2 name
|
||||
std::string thisfm2name = name;
|
||||
thisfm2name.append(".fm2");
|
||||
|
@ -1096,9 +1095,7 @@ bool SaveProjectAs()
|
|||
|
||||
splitpath(tempstr.c_str(), drv, dir, name, ext); //Split it up...
|
||||
project.SetProjectName(name);
|
||||
std::string filename = name; //Grab the name...
|
||||
filename.append(ext); //Stick extension back on...
|
||||
project.SetProjectFile(filename); //And update the project's filename.
|
||||
project.SetProjectFile(tempstr);
|
||||
std::string thisfm2name = name;
|
||||
thisfm2name.append(".fm2"); //Setup the fm2 name
|
||||
project.SetFM2Name(thisfm2name); //Set the project's fm2 name
|
||||
|
@ -1425,17 +1422,13 @@ BOOL CALLBACK WndprocTasEdit(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|||
if (selectionFrames.size()) ClearFrames();
|
||||
break;
|
||||
case TASEDIT_REWIND_FULL:
|
||||
//rewinds to beginning of greenzone
|
||||
playback.JumpToFrame(greenzone.FindBeginningOfGreenZone());
|
||||
FollowPlayback();
|
||||
playback.RewindFull();
|
||||
break;
|
||||
case TASEDIT_PLAYSTOP:
|
||||
playback.ToggleEmulationPause();
|
||||
break;
|
||||
case TASEDIT_FORWARD_FULL:
|
||||
//moves to the end of greenzone
|
||||
playback.JumpToFrame(greenzone.greenZoneCount-1);
|
||||
FollowPlayback();
|
||||
playback.ForwardFull();
|
||||
break;
|
||||
case ACCEL_CTRL_F:
|
||||
case CHECK_FOLLOW_CURSOR:
|
||||
|
@ -1741,6 +1734,7 @@ void EnterTasEdit()
|
|||
project.init();
|
||||
history.init(TasEdit_undo_levels);
|
||||
SetFocus(hwndHistoryList);
|
||||
greenzone.TryDumpIncremental(lagFlag != 0);
|
||||
FCEU_DispMessage("Tasedit engaged",0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,9 @@ GREENZONE::GREENZONE()
|
|||
|
||||
void GREENZONE::init()
|
||||
{
|
||||
|
||||
clearGreenzone();
|
||||
|
||||
currMovieData.frames_flags.resize(currMovieData.records.size());
|
||||
reset();
|
||||
}
|
||||
void GREENZONE::reset()
|
||||
|
@ -42,7 +43,15 @@ void GREENZONE::TryDumpIncremental(bool lagFlag)
|
|||
if((int)currMovieData.records.size() <= currFrameCounter)
|
||||
currMovieData.insertEmpty(-1, 1 + currFrameCounter - (int)currMovieData.records.size());
|
||||
|
||||
// if frame chanegd - log savestate
|
||||
// update greenzone upper limit
|
||||
if (greenZoneCount <= currFrameCounter)
|
||||
greenZoneCount = currFrameCounter+1;
|
||||
if ((int)savestates.size() < greenZoneCount)
|
||||
savestates.resize(greenZoneCount);
|
||||
if ((int)currMovieData.frames_flags.size() < greenZoneCount)
|
||||
currMovieData.frames_flags.resize(greenZoneCount);
|
||||
|
||||
// if frame changed - log savestate
|
||||
storeTasSavestate(currFrameCounter);
|
||||
// also log frame_flags
|
||||
if (currFrameCounter > 0)
|
||||
|
@ -53,9 +62,8 @@ void GREENZONE::TryDumpIncremental(bool lagFlag)
|
|||
else
|
||||
currMovieData.frames_flags[currFrameCounter-1] &= ~LAG_FLAG_BIT;
|
||||
}
|
||||
// update greenzone upper limit
|
||||
if (greenZoneCount <= currFrameCounter)
|
||||
greenZoneCount = currFrameCounter+1;
|
||||
|
||||
|
||||
|
||||
ClearGreenzoneTail();
|
||||
}
|
||||
|
@ -109,8 +117,9 @@ void GREENZONE::clearGreenzone()
|
|||
{
|
||||
ClearSavestate(i);
|
||||
}
|
||||
greenZoneCount = 1;
|
||||
currMovieData.frames_flags.resize(1);
|
||||
savestates.resize(0);
|
||||
greenZoneCount = 0;
|
||||
currMovieData.frames_flags.resize(0);
|
||||
// reset lua_colorings
|
||||
// reset monitorings
|
||||
|
||||
|
@ -226,7 +235,7 @@ void GREENZONE::InvalidateGreenZone(int after)
|
|||
if (TASEdit_restore_position)
|
||||
playback.restorePosition();
|
||||
else
|
||||
playback.JumpToFrame(greenZoneCount-1);
|
||||
playback.jump(greenZoneCount-1);
|
||||
}
|
||||
}
|
||||
// redraw list even if greenzone didn't change
|
||||
|
|
|
@ -5,10 +5,15 @@
|
|||
#include "taseditproj.h"
|
||||
#include "../tasedit.h"
|
||||
|
||||
#ifdef _S9XLUA_H
|
||||
extern void ForceExecuteLuaFrameFunctions();
|
||||
#endif
|
||||
|
||||
extern HWND hwndProgressbar, hwndList, hwndRewind, hwndForward;
|
||||
extern void FCEU_printf(char *format, ...);
|
||||
extern bool turbo;
|
||||
extern GREENZONE greenzone;
|
||||
extern bool Tasedit_rewind_now;
|
||||
|
||||
PLAYBACK::PLAYBACK()
|
||||
{
|
||||
|
@ -59,9 +64,12 @@ void PLAYBACK::update()
|
|||
old_pauseframe = pauseframe;
|
||||
old_show_pauseframe = show_pauseframe;
|
||||
if (pauseframe)
|
||||
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD) & 1;
|
||||
{
|
||||
if (emu_paused)
|
||||
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_PAUSED) & 1;
|
||||
else
|
||||
show_pauseframe = false;
|
||||
show_pauseframe = (int)(clock() / PAUSEFRAME_BLINKING_PERIOD_SEEKING) & 1;
|
||||
} else show_pauseframe = false;
|
||||
if (old_show_pauseframe != show_pauseframe) RedrawRow(pauseframe-1);
|
||||
|
||||
//update the playback cursor
|
||||
|
@ -79,7 +87,7 @@ void PLAYBACK::update()
|
|||
if(emu_paused)
|
||||
{
|
||||
old_rewind_button_state = rewind_button_state;
|
||||
rewind_button_state = (Button_GetState(hwndRewind) & BST_PUSHED) != 0;
|
||||
rewind_button_state = ((Button_GetState(hwndRewind) & BST_PUSHED) != 0 || Tasedit_rewind_now);
|
||||
if (rewind_button_state)
|
||||
{
|
||||
if (!old_rewind_button_state)
|
||||
|
@ -93,7 +101,7 @@ void PLAYBACK::update()
|
|||
}
|
||||
old_forward_button_state = forward_button_state;
|
||||
forward_button_state = (Button_GetState(hwndForward) & BST_PUSHED) != 0;
|
||||
if (forward_button_state)
|
||||
if (forward_button_state && !rewind_button_state)
|
||||
{
|
||||
if (!old_forward_button_state)
|
||||
{
|
||||
|
@ -156,16 +164,28 @@ void PLAYBACK::SeekingStop()
|
|||
|
||||
void PLAYBACK::RewindFrame()
|
||||
{
|
||||
if (currFrameCounter > 0) JumpToFrame(currFrameCounter-1);
|
||||
if (currFrameCounter > 0) jump(currFrameCounter-1);
|
||||
turbo = false;
|
||||
FollowPlayback();
|
||||
}
|
||||
void PLAYBACK::ForwardFrame()
|
||||
{
|
||||
JumpToFrame(currFrameCounter+1);
|
||||
jump(currFrameCounter+1);
|
||||
turbo = false;
|
||||
FollowPlayback();
|
||||
}
|
||||
void PLAYBACK::RewindFull()
|
||||
{
|
||||
// rewind to the beginning of greenzone
|
||||
jump(greenzone.FindBeginningOfGreenZone());
|
||||
FollowPlayback();
|
||||
}
|
||||
void PLAYBACK::ForwardFull()
|
||||
{
|
||||
// move to the end of greenzone
|
||||
jump(greenzone.greenZoneCount-1);
|
||||
FollowPlayback();
|
||||
}
|
||||
|
||||
void PLAYBACK::StartFromZero()
|
||||
{
|
||||
|
@ -174,6 +194,19 @@ void PLAYBACK::StartFromZero()
|
|||
greenzone.TryDumpIncremental();
|
||||
}
|
||||
|
||||
void PLAYBACK::jump(int frame)
|
||||
{
|
||||
if (JumpToFrame(frame))
|
||||
ForceExecuteLuaFrameFunctions();
|
||||
}
|
||||
void PLAYBACK::restorePosition()
|
||||
{
|
||||
if (pauseframe)
|
||||
jump(pauseframe-1);
|
||||
else
|
||||
jump(currFrameCounter);
|
||||
}
|
||||
|
||||
bool PLAYBACK::JumpToFrame(int index)
|
||||
{
|
||||
// Returns true if a jump to the frame is made, false if started seeking or if nothing's done
|
||||
|
@ -211,14 +244,6 @@ bool PLAYBACK::JumpToFrame(int index)
|
|||
return false;
|
||||
}
|
||||
|
||||
void PLAYBACK::restorePosition()
|
||||
{
|
||||
if (pauseframe)
|
||||
JumpToFrame(pauseframe-1);
|
||||
else
|
||||
JumpToFrame(currFrameCounter);
|
||||
}
|
||||
|
||||
int PLAYBACK::GetPauseFrame()
|
||||
{
|
||||
if (show_pauseframe)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
//Specification file for Playback class
|
||||
|
||||
#define PAUSEFRAME_BLINKING_PERIOD 100
|
||||
#define PAUSEFRAME_BLINKING_PERIOD_SEEKING 100
|
||||
#define PAUSEFRAME_BLINKING_PERIOD_PAUSED 250
|
||||
|
||||
#define HOLD_REPEAT_DELAY 250 // in milliseconds
|
||||
|
||||
|
||||
|
@ -12,6 +14,9 @@ public:
|
|||
void reset();
|
||||
void update();
|
||||
|
||||
void jump(int frame);
|
||||
void restorePosition();
|
||||
|
||||
void updateProgressbar();
|
||||
|
||||
void SeekingStart(int finish_frame);
|
||||
|
@ -22,9 +27,9 @@ public:
|
|||
|
||||
void RewindFrame();
|
||||
void ForwardFrame();
|
||||
void RewindFull();
|
||||
void ForwardFull();
|
||||
|
||||
bool JumpToFrame(int index);
|
||||
void restorePosition();
|
||||
|
||||
void StartFromZero();
|
||||
|
||||
|
@ -34,6 +39,7 @@ public:
|
|||
int pauseframe;
|
||||
|
||||
private:
|
||||
bool JumpToFrame(int index);
|
||||
|
||||
int lastCursor; // for currentCursor we use external variable currFrameCounter
|
||||
bool old_emu_paused, emu_paused;
|
||||
|
|
|
@ -721,7 +721,7 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
|||
|
||||
#ifdef WIN32
|
||||
if(FCEUMOV_Mode(MOVIEMODE_TASEDIT))
|
||||
greenzone.TryDumpIncremental(lagFlag);
|
||||
greenzone.TryDumpIncremental((bool)lagFlag);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@
|
|||
#include "drivers/win/memview.h"
|
||||
#include "drivers/win/window.h"
|
||||
#include "drivers/win/ntview.h"
|
||||
|
||||
extern bool Tasedit_rewind_now;
|
||||
#endif // WIN32
|
||||
|
||||
//it is easier to declare these input drivers extern here than include a bunch of files
|
||||
|
@ -645,6 +647,8 @@ static void MovieSubtitleToggle(void);
|
|||
static void UndoRedoSavestate(void);
|
||||
static void FCEUI_DoExit(void);
|
||||
static void ToggleFullscreen(void);
|
||||
static void TaseditRewindOn(void);
|
||||
static void TaseditRewindOff(void);
|
||||
|
||||
struct EMUCMDTABLE FCEUI_CommandTable[]=
|
||||
{
|
||||
|
@ -768,6 +772,7 @@ struct EMUCMDTABLE FCEUI_CommandTable[]=
|
|||
{ EMUCMD_TOOL_RAMSEARCHGTE, EMUCMDTYPE_TOOL, RamSearchOpGTE, 0, 0, "Ram Search - Greater Than or Equal", 0},
|
||||
{ EMUCMD_TOOL_RAMSEARCHEQ, EMUCMDTYPE_TOOL, RamSearchOpEQ, 0, 0, "Ram Search - Equal", 0},
|
||||
{ EMUCMD_TOOL_RAMSEARCHNE, EMUCMDTYPE_TOOL, RamSearchOpNE, 0, 0, "Ram Search - Not Equal", 0},
|
||||
{ EMUCMD_TASEDIT_REWIND, EMUCMDTYPE_TOOL, TaseditRewindOn, TaseditRewindOff, 0, "Rewind Frame (Tasedit-only)", EMUCMDFLAG_TASEDIT},
|
||||
};
|
||||
|
||||
#define NUM_EMU_CMDS (sizeof(FCEUI_CommandTable)/sizeof(FCEUI_CommandTable[0]))
|
||||
|
@ -1104,3 +1109,18 @@ static void ToggleFullscreen(void)
|
|||
changerecursive=0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void TaseditRewindOn(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Tasedit_rewind_now = true;
|
||||
#endif
|
||||
}
|
||||
static void TaseditRewindOff(void)
|
||||
{
|
||||
#ifdef WIN32
|
||||
Tasedit_rewind_now = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -228,9 +228,11 @@ enum EMUCMD
|
|||
EMUCMD_TOOL_RAMSEARCHGTE,
|
||||
EMUCMD_TOOL_RAMSEARCHEQ,
|
||||
EMUCMD_TOOL_RAMSEARCHNE,
|
||||
EMUCMD_TOOL_OPENNTVIEW,
|
||||
//-----------------------------
|
||||
//keep adding these in order of newness or else the hotkey binding configs will get messed up...
|
||||
EMUCMD_TOOL_OPENNTVIEW,
|
||||
EMUCMD_TASEDIT_REWIND,
|
||||
|
||||
EMUCMD_MAX
|
||||
};
|
||||
|
||||
|
|
|
@ -1869,6 +1869,13 @@ void CallRegisteredLuaFunctions(LuaCallID calltype)
|
|||
}
|
||||
}
|
||||
|
||||
void ForceExecuteLuaFrameFunctions()
|
||||
{
|
||||
FCEU_LuaFrameBoundary();
|
||||
CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION);
|
||||
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
|
||||
}
|
||||
|
||||
// Not for the signed versions though
|
||||
static int memory_readbytesigned(lua_State *L) {
|
||||
signed char c = (signed char) FCEU_CheatGetByte(luaL_checkinteger(L,1));
|
||||
|
|
|
@ -178,7 +178,6 @@ public:
|
|||
std::string romFilename;
|
||||
std::vector<uint8> savestate;
|
||||
std::vector<MovieRecord> records;
|
||||
//std::vector<std::vector<uint8> > savestates;
|
||||
std::vector<uint8> frames_flags;
|
||||
std::vector<std::wstring> comments;
|
||||
std::vector<std::string> subtitles;
|
||||
|
|
Loading…
Reference in New Issue