From a4c34112af75b96b149afa31ed152ebd8d650324 Mon Sep 17 00:00:00 2001 From: Trihedraf Date: Thu, 11 Mar 2021 23:58:20 -0800 Subject: [PATCH] :triangular_flag_on_post: Add ini toggle for FPS Limit. Enabled by default. (#1165) --- Source/diablo.cpp | 2 ++ Source/diablo.h | 2 ++ SourceX/dx.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 310007e37..b6eee2ab6 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -416,6 +416,7 @@ static void SaveOptions() setIniInt("Graphics", "Blended Transparency", sgOptions.Graphics.bBlendedTransparancy); setIniInt("Graphics", "Gamma Correction", sgOptions.Graphics.nGammaCorrection); setIniInt("Graphics", "Color Cycling", sgOptions.Graphics.bColorCycling); + setIniInt("Graphics", "FPS Limiter", sgOptions.Graphics.bFPSLimit); setIniInt("Game", "Speed", sgOptions.Gameplay.nTickRate); setIniInt("Game", "Fast Walk", sgOptions.Gameplay.bJogInTown); @@ -469,6 +470,7 @@ static void LoadOptions() sgOptions.Graphics.bBlendedTransparancy = getIniBool("Graphics", "Blended Transparency", true); sgOptions.Graphics.nGammaCorrection = getIniInt("Graphics", "Gamma Correction", 100); sgOptions.Graphics.bColorCycling = getIniBool("Graphics", "Color Cycling", true); + sgOptions.Graphics.bFPSLimit = getIniBool("Graphics", "FPS Limiter", true); sgOptions.Gameplay.nTickRate = getIniInt("Game", "Speed", 20); sgOptions.Gameplay.bJogInTown = getIniBool("Game", "Fast Walk", false); diff --git a/Source/diablo.h b/Source/diablo.h index c7d1582a3..6f8ffe399 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -57,6 +57,8 @@ typedef struct GraphicsOptions { Sint32 nGammaCorrection; /** @brief Enable color cycling animations. */ bool bColorCycling; + /** @brief Enable FPS Limit. */ + bool bFPSLimit; } GraphicsOptions; typedef struct GameplayOptions { diff --git a/SourceX/dx.cpp b/SourceX/dx.cpp index c931b30d1..5073fab50 100644 --- a/SourceX/dx.cpp +++ b/SourceX/dx.cpp @@ -246,6 +246,8 @@ void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect) */ void LimitFrameRate() { + if (!sgOptions.Graphics.bFPSLimit) + return; static uint32_t frameDeadline; uint32_t tc = SDL_GetTicks() * 1000; uint32_t v = 0;