From 6b7eda1267c9fc81bf2e7c85668d91da13cd322b Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 10 Sep 2022 01:19:58 +0100 Subject: [PATCH] inverted logic fix --- Source/AliveLibAE/Psx.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/Source/AliveLibAE/Psx.cpp b/Source/AliveLibAE/Psx.cpp index 25a8199b2..6cc176454 100644 --- a/Source/AliveLibAE/Psx.cpp +++ b/Source/AliveLibAE/Psx.cpp @@ -899,19 +899,19 @@ EXPORT s32 CC PSX_VSync_4F6170(s32 mode) } else { - // During recording or playback do not call SsSeqCalledTbyT_4FDC80 an undeterminate - // amount of times as this can leak to de-syncs. - if (GetGameAutoPlayer().IsRecording() || GetGameAutoPlayer().IsPlaying()) + s32 frameTimeInMilliseconds = currentTime - sVSyncLastMillisecond_BD0F2C; + if (mode > 0 && frameTimeInMilliseconds < 1000 * mode / 60) { - s32 frameTimeInMilliseconds = currentTime - sVSyncLastMillisecond_BD0F2C; - if (mode > 0 && frameTimeInMilliseconds < 1000 * mode / 60) - { - s32 timeSinceLastFrame = 0; - sVSync_Unused_578325 = 1; + s32 timeSinceLastFrame = 0; + sVSync_Unused_578325 = 1; - do + do + { + timeSinceLastFrame = SYS_GetTicks() - sVSyncLastMillisecond_BD0F2C; + // During recording or playback do not call SsSeqCalledTbyT_4FDC80 an undeterminate + // amount of times as this can leak to de-syncs. + if (!GetGameAutoPlayer().IsRecording() && !GetGameAutoPlayer().IsPlaying()) { - timeSinceLastFrame = SYS_GetTicks() - sVSyncLastMillisecond_BD0F2C; SsSeqCalledTbyT_4FDC80(); // Prevent max CPU usage, will probably cause stuttering on weaker machines @@ -920,18 +920,16 @@ EXPORT s32 CC PSX_VSync_4F6170(s32 mode) SDL_Delay(1); } } - while (timeSinceLastFrame < 1000 * mode / 60); - - frameTimeInMilliseconds = 1000 * mode / 60; } + while (timeSinceLastFrame < 1000 * mode / 60); + frameTimeInMilliseconds = 1000 * mode / 60; + } - sVSyncLastMillisecond_BD0F2C += frameTimeInMilliseconds; - sLastFrameTimestampMilliseconds_BD0F24 = currentTime + frameTimeInMilliseconds; + sVSyncLastMillisecond_BD0F2C += frameTimeInMilliseconds; + sLastFrameTimestampMilliseconds_BD0F24 = currentTime + frameTimeInMilliseconds; - return 240 * frameTimeInMilliseconds / 60000; - } - return 0; + return 240 * frameTimeInMilliseconds / 60000; } }