diff --git a/snapshot.cpp b/snapshot.cpp index b816fd43..00bfa5ad 100644 --- a/snapshot.cpp +++ b/snapshot.cpp @@ -341,6 +341,12 @@ struct SnapshotScreenshotInfo uint8 Data[MAX_SNES_WIDTH * MAX_SNES_HEIGHT * 3]; }; +struct SnapshotRRExtraInfo +{ + uint32 TotalEmulatedFrames; // IPPU.TotalEmulatedFrames + uint32 PadIgnoredFrames; // IPPU.PadIgnoredFrames +}; + static struct Obsolete { uint8 CPU_IRQActive; @@ -1142,6 +1148,15 @@ static FreezeData SnapMovie[] = INT_ENTRY(6, MovieInputDataSize) }; +#undef STRUCT +#define STRUCT struct SnapshotRRExtraInfo + +static FreezeData SnapRRExtra[] = +{ + INT_ENTRY(8, TotalEmulatedFrames), + INT_ENTRY(8, PadIgnoredFrames) +}; + static int UnfreezeBlock (STREAM, const char *, uint8 *, int); static int UnfreezeBlockCopy (STREAM, const char *, uint8 **, int); static int UnfreezeStruct (STREAM, const char *, void *, FreezeData *, int, int); @@ -1431,6 +1446,11 @@ void S9xFreezeToStream (STREAM stream) } } + struct SnapshotRRExtraInfo rri; + rri.TotalEmulatedFrames = IPPU.TotalEmulatedFrames; + rri.PadIgnoredFrames = IPPU.PadIgnoredFrames; + FreezeStruct(stream, "JXQ", &rri, SnapRRExtra, COUNT(SnapRRExtra)); + S9xSetSoundMute(FALSE); delete [] soundsnapshot; @@ -1484,6 +1504,7 @@ int S9xUnfreezeFromStream (STREAM stream) uint8 *local_bsx_data = NULL; uint8 *local_screenshot = NULL; uint8 *local_movie_data = NULL; + uint8 *local_rr_extra = NULL; do { @@ -1620,6 +1641,8 @@ int S9xUnfreezeFromStream (STREAM stream) } } + UnfreezeStructCopy(stream, "JXQ", &local_rr_extra, SnapRRExtra, COUNT(SnapRRExtra), version); + result = SUCCESS; } while (false); @@ -1856,6 +1879,19 @@ int S9xUnfreezeFromStream (STREAM stream) memset(GFX.Screen + y * GFX.RealPPL, 0, GFX.RealPPL * 2); } + if (local_rr_extra) + { + SnapshotRRExtraInfo *rri = new SnapshotRRExtraInfo; + + UnfreezeStructFromCopy(rri, SnapRRExtra, COUNT(SnapRRExtra), local_rr_extra, version); + + IPPU.TotalEmulatedFrames = rri->TotalEmulatedFrames; + IPPU.PadIgnoredFrames = rri->PadIgnoredFrames; + S9xUpdateFrameCounter(-1); + + delete rri; + } + S9xSetSoundMute(FALSE); } @@ -1886,6 +1922,7 @@ int S9xUnfreezeFromStream (STREAM stream) if (local_bsx_data) delete [] local_bsx_data; if (local_screenshot) delete [] local_screenshot; if (local_movie_data) delete [] local_movie_data; + if (local_rr_extra) delete [] local_rr_extra; return (result); } diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index c504b108..7e0461cf 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -2901,6 +2901,7 @@ void S9xOnSNESPadRead() if (lastTime - lastGUIUpdateTime >= guiUpdateFrequency) { UpdateToolWindows(); + S9xUpdateFrameCounter(); InvalidateRect(GUI.hWnd, NULL, FALSE); lastGUIUpdateTime = lastTime; } @@ -3412,6 +3413,7 @@ int WINAPI WinMain( DWORD lastTime = timeGetTime(); if (lastTime - lastGUIUpdateTime >= guiUpdateFrequency) { UpdateToolWindows(); + S9xUpdateFrameCounter(); InvalidateRect(GUI.hWnd, NULL, FALSE); lastGUIUpdateTime = lastTime; }