win32: savestate rewinding
This commit is contained in:
parent
2228a8de13
commit
1559e84d0d
|
@ -964,3 +964,60 @@ bool savestate_load(const char *file_name)
|
||||||
|
|
||||||
return savestate_load(&f);
|
return savestate_load(&f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::vector<std::vector <char>> rewindbuffer;
|
||||||
|
|
||||||
|
int rewindstates = 16;
|
||||||
|
int rewindinterval = 4;
|
||||||
|
|
||||||
|
void rewindsave () {
|
||||||
|
|
||||||
|
if(currFrameCounter % rewindinterval)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("rewindsave"); printf("%d%s", currFrameCounter, "\n");
|
||||||
|
|
||||||
|
memorystream ms;
|
||||||
|
|
||||||
|
if(!savestate_save(&ms, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ms.flush();
|
||||||
|
|
||||||
|
std::vector<char> v(ms.buf(), ms.buf() + ms.size());
|
||||||
|
|
||||||
|
//clip the header
|
||||||
|
v.erase(v.begin(),v.begin()+32);
|
||||||
|
|
||||||
|
rewindbuffer.push_back(v);
|
||||||
|
|
||||||
|
if(rewindbuffer.size() > rewindstates) rewindbuffer.erase(rewindbuffer.begin());
|
||||||
|
}
|
||||||
|
|
||||||
|
void dorewind()
|
||||||
|
{
|
||||||
|
|
||||||
|
if(currFrameCounter % rewindinterval)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("rewind\n");
|
||||||
|
|
||||||
|
nds.debugConsole = FALSE;
|
||||||
|
|
||||||
|
int size = rewindbuffer.size();
|
||||||
|
|
||||||
|
if(size < 1) {
|
||||||
|
printf("rewind buffer empty\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d", size);
|
||||||
|
|
||||||
|
memorystream mstemp(&rewindbuffer.at(size-1));
|
||||||
|
|
||||||
|
ReadStateChunks(&mstemp,(s32)mstemp.size());
|
||||||
|
loadstate();
|
||||||
|
|
||||||
|
rewindbuffer.pop_back();
|
||||||
|
|
||||||
|
}
|
|
@ -222,6 +222,12 @@ void HK_PlayMovie(int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rewinding = false;
|
||||||
|
|
||||||
|
void HK_RewindKeyDown(int) {rewinding = true;}
|
||||||
|
|
||||||
|
void HK_RewindKeyUp(int){rewinding = false;}
|
||||||
|
|
||||||
void HK_RecordMovie(int)
|
void HK_RecordMovie(int)
|
||||||
{
|
{
|
||||||
if (romloaded)
|
if (romloaded)
|
||||||
|
@ -568,6 +574,13 @@ void InitCustomKeys (SCustomKeys *keys)
|
||||||
keys->TurboStart.page = HOTKEY_PAGE_TURBO;
|
keys->TurboStart.page = HOTKEY_PAGE_TURBO;
|
||||||
keys->TurboStart.key = NULL;
|
keys->TurboStart.key = NULL;
|
||||||
|
|
||||||
|
keys->Rewind.handleKeyDown = HK_RewindKeyDown;
|
||||||
|
keys->Rewind.handleKeyUp = HK_RewindKeyUp;
|
||||||
|
keys->Rewind.code = "Rewind";
|
||||||
|
keys->Rewind.name = L"Rewind";
|
||||||
|
keys->Rewind.page = HOTKEY_PAGE_MOVIE;
|
||||||
|
keys->Rewind.key = NULL;
|
||||||
|
|
||||||
keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot;
|
keys->NextSaveSlot.handleKeyDown = HK_NextSaveSlot;
|
||||||
keys->NextSaveSlot.code = "NextSaveSlot";
|
keys->NextSaveSlot.code = "NextSaveSlot";
|
||||||
keys->NextSaveSlot.name = L"Next Save Slot";
|
keys->NextSaveSlot.name = L"Next Save Slot";
|
||||||
|
|
|
@ -80,6 +80,8 @@ struct SCustomKeys
|
||||||
|
|
||||||
SCustomKey RecordWAV, RecordAVI;
|
SCustomKey RecordWAV, RecordAVI;
|
||||||
|
|
||||||
|
SCustomKey Rewind;
|
||||||
|
|
||||||
SCustomKey ToggleFrameCounter;
|
SCustomKey ToggleFrameCounter;
|
||||||
SCustomKey ToggleFPS;
|
SCustomKey ToggleFPS;
|
||||||
SCustomKey ToggleInput;
|
SCustomKey ToggleInput;
|
||||||
|
|
|
@ -262,6 +262,7 @@ int autoframeskipenab=0;
|
||||||
int frameskiprate=0;
|
int frameskiprate=0;
|
||||||
int emu_paused = 0;
|
int emu_paused = 0;
|
||||||
bool frameAdvance = false;
|
bool frameAdvance = false;
|
||||||
|
bool staterewindingenabled = false;
|
||||||
|
|
||||||
bool HudEditorMode = false;
|
bool HudEditorMode = false;
|
||||||
bool UseMicSample = false;
|
bool UseMicSample = false;
|
||||||
|
@ -969,6 +970,18 @@ DWORD WINAPI run()
|
||||||
}
|
}
|
||||||
DRV_AviVideoUpdate((u16*)GPU_screen);
|
DRV_AviVideoUpdate((u16*)GPU_screen);
|
||||||
|
|
||||||
|
extern void rewindsave();
|
||||||
|
extern bool rewinding;
|
||||||
|
extern void dorewind();
|
||||||
|
|
||||||
|
if (staterewindingenabled) {
|
||||||
|
|
||||||
|
if(rewinding)
|
||||||
|
dorewind();
|
||||||
|
else
|
||||||
|
rewindsave();
|
||||||
|
}
|
||||||
|
|
||||||
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
|
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
|
||||||
|
|
||||||
static int fps3d = 0;
|
static int fps3d = 0;
|
||||||
|
@ -2570,6 +2583,8 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
MainWindow->checkMenu(IDM_RENDER_SCANLINE, MF_BYCOMMAND | video.currentfilter == video.SCANLINE ? MF_CHECKED:MF_UNCHECKED);
|
MainWindow->checkMenu(IDM_RENDER_SCANLINE, MF_BYCOMMAND | video.currentfilter == video.SCANLINE ? MF_CHECKED:MF_UNCHECKED);
|
||||||
MainWindow->checkMenu(IDM_RENDER_BILINEAR, MF_BYCOMMAND | video.currentfilter == video.BILINEAR ? MF_CHECKED:MF_UNCHECKED);
|
MainWindow->checkMenu(IDM_RENDER_BILINEAR, MF_BYCOMMAND | video.currentfilter == video.BILINEAR ? MF_CHECKED:MF_UNCHECKED);
|
||||||
|
|
||||||
|
MainWindow->checkMenu(IDC_STATEREWINDING, MF_BYCOMMAND | staterewindingenabled == 1 ? MF_CHECKED:MF_UNCHECKED);
|
||||||
|
|
||||||
//Language selection
|
//Language selection
|
||||||
|
|
||||||
MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, MF_BYCOMMAND | ((lostFocusPause)?MF_CHECKED:MF_UNCHECKED));
|
MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, MF_BYCOMMAND | ((lostFocusPause)?MF_CHECKED:MF_UNCHECKED));
|
||||||
|
@ -2896,6 +2911,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||||
else
|
else
|
||||||
WavRecordTo();
|
WavRecordTo();
|
||||||
break;
|
break;
|
||||||
|
case IDC_STATEREWINDING:
|
||||||
|
if(staterewindingenabled) staterewindingenabled = false;
|
||||||
|
else staterewindingenabled = true;
|
||||||
case IDM_RENDER_NORMAL:
|
case IDM_RENDER_NORMAL:
|
||||||
video.setfilter(video.NONE);
|
video.setfilter(video.NONE);
|
||||||
FilterUpdate(hwnd);
|
FilterUpdate(hwnd);
|
||||||
|
|
|
@ -137,6 +137,7 @@
|
||||||
#define IDC_LUAPATHEDIT 364
|
#define IDC_LUAPATHEDIT 364
|
||||||
#define IDC_BROWSELUA 365
|
#define IDC_BROWSELUA 365
|
||||||
#define IDD_PATHSETTINGS 366
|
#define IDD_PATHSETTINGS 366
|
||||||
|
#define IDC_STATEREWINDING 367
|
||||||
#define IDC_DES_BOX 402
|
#define IDC_DES_BOX 402
|
||||||
#define IDC_R0 403
|
#define IDC_R0 403
|
||||||
#define IDC_R1 404
|
#define IDC_R1 404
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue