aboutsummaryrefslogtreecommitdiff
path: root/src/frontend
diff options
context:
space:
mode:
authorRSDuck <rsduck@users.noreply.github.com>2020-12-04 00:00:35 +0100
committerRSDuck <rsduck@users.noreply.github.com>2020-12-04 00:00:35 +0100
commit42e083960e52cce31589714dcc7fab8e173efb81 (patch)
tree834d30bec567362033462fb26ec8b0c9f1edf927 /src/frontend
parent906521e7e9ab32f0502a680244db22f53f23b0b7 (diff)
always cap FPS to 1000
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/qt_sdl/main.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 6fcd8ce..2d3749d 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -495,24 +495,24 @@ void EmuThread::run()
double frametimeStep = nlines / (60.0 * 263.0);
{
+ bool limitfps = Config::LimitFPS && !fastforward;
+
+ double practicalFramelimit = limitfps ? frametimeStep : 1.0 / 1000.0;
+
double curtime = SDL_GetPerformanceCounter() * perfCountsSec;
- bool limitfps = Config::LimitFPS && !fastforward;
- if (limitfps)
+ frameLimitError += practicalFramelimit - (curtime - lastTime);
+ if (frameLimitError < -practicalFramelimit)
+ frameLimitError = -practicalFramelimit;
+ if (frameLimitError > practicalFramelimit)
+ frameLimitError = practicalFramelimit;
+
+ if (round(frameLimitError * 1000.0) > 0.0)
{
- frameLimitError += frametimeStep - (curtime - lastTime);
- if (frameLimitError < -frametimeStep)
- frameLimitError = -frametimeStep;
- if (frameLimitError > frametimeStep)
- frameLimitError = frametimeStep;
-
- if (round(frameLimitError * 1000.0) > 0.0)
- {
- SDL_Delay(round(frameLimitError * 1000.0));
- double timeBeforeSleep = curtime;
- curtime = SDL_GetPerformanceCounter() * perfCountsSec;
- frameLimitError -= curtime - timeBeforeSleep;
- }
+ SDL_Delay(round(frameLimitError * 1000.0));
+ double timeBeforeSleep = curtime;
+ curtime = SDL_GetPerformanceCounter() * perfCountsSec;
+ frameLimitError -= curtime - timeBeforeSleep;
}
lastTime = curtime;