diff --git a/src/render_soft.c b/src/render_soft.c index 0728e32..3322dcf 100644 --- a/src/render_soft.c +++ b/src/render_soft.c @@ -40,8 +40,32 @@ DWORD WINAPI render_soft_main(void) else Sleep(500); + int maxFPS = ddraw->render.maxfps; + DWORD frameLength = 0; + DWORD lastTick = 0; + + if (maxFPS < 0) + maxFPS = ddraw->mode.dmDisplayFrequency; + + if (maxFPS >= 1000) + maxFPS = 0; + + if (maxFPS > 0) + frameLength = 1000.0f / maxFPS; + while (ddraw->render.run && WaitForSingleObject(ddraw->render.sem, INFINITE) != WAIT_FAILED) { + if (maxFPS > 0) + { + DWORD curTick = timeGetTime(); + if (lastTick + frameLength > curTick) + { + SetEvent(ddraw->render.ev); + continue; + } + lastTick = curTick; + } + #if _DEBUG DrawFrameInfoStart(); #endif diff --git a/src/settings.c b/src/settings.c index 0745c53..0e8a672 100644 --- a/src/settings.c +++ b/src/settings.c @@ -189,7 +189,7 @@ static void CreateSettingsIni() "; Note: Works only for games that support 'handlemouse=true'\n" "boxing=false\n" "\n" - "; Real rendering rate, -1 = screen rate, 0 = unlimited, n = cap (OpenGL / Direct3D only)\n" + "; Real rendering rate, -1 = screen rate, 0 = unlimited, n = cap\n" "maxfps=125\n" "\n" "; Vertical synchronization, enable if you get tearing (OpenGL / Direct3D only)\n" @@ -222,7 +222,7 @@ static void CreateSettingsIni() "; Preliminary libretro shader support - e.g. cubic.glsl (OpenGL only) https://github.com/libretro/glsl-shaders\n" "shader=\n" "\n" - "; Max game ticks per second, possible values: 1-1000 (Can be used to slow down a too fast running game)\n" + "; Max game ticks per second, possible values: 0-1000 (Can be used to slow down a too fast running game)\n" "maxgameticks=0\n" "\n" "; Gives cnc-ddraw full control over the mouse cursor (required for adjmouse/boxing/maintas)\n"