diff options
author | Madhav Kanbur <abcdjdj@gmail.com> | 2018-11-21 11:11:02 +0530 |
---|---|---|
committer | Madhav Kanbur <abcdjdj@gmail.com> | 2018-11-21 11:11:02 +0530 |
commit | 78c767b69352c8103738adac7159914bad666d31 (patch) | |
tree | 8028e01a0994fec74c46536360a2d00ec36ffdd8 | |
parent | 27e1ca41031a0216d7d9a940b336a232217e6abf (diff) |
Add option to limit framerate from UI
Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
-rw-r--r-- | src/Config.cpp | 4 | ||||
-rw-r--r-- | src/Config.h | 2 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/Config.cpp b/src/Config.cpp index fea92e9..9b8f148 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -47,6 +47,8 @@ int ScreenLayout; int ScreenSizing; int ScreenFilter; +int LimitFPS; + int DirectBoot; int Threaded3D; @@ -103,6 +105,8 @@ ConfigEntry ConfigFile[] = {"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0}, {"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0}, + {"LimitFPS", 0, &LimitFPS, 1, NULL, 0}, + {"DirectBoot", 0, &DirectBoot, 1, NULL, 0}, {"Threaded3D", 0, &Threaded3D, 1, NULL, 0}, diff --git a/src/Config.h b/src/Config.h index d7b0858..cea051f 100644 --- a/src/Config.h +++ b/src/Config.h @@ -40,6 +40,8 @@ extern int ScreenLayout; extern int ScreenSizing; extern int ScreenFilter; +extern int LimitFPS; + extern int DirectBoot; extern int Threaded3D; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index 9ca829e..880ffa3 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -216,7 +216,6 @@ int EmuThreadFunc(void* burp) u32 lasttick = starttick; u32 lastmeasuretick = lasttick; u32 fpslimitcount = 0; - bool limitfps = true; char melontitle[100]; while (EmuRunning != 0) @@ -306,7 +305,7 @@ int EmuThreadFunc(void* burp) lasttick = curtick; u32 wantedtick = starttick + (u32)((float)fpslimitcount * framerate); - if (curtick < wantedtick && limitfps) + if (curtick < wantedtick && Config::LimitFPS) { SDL_Delay(wantedtick - curtick); } @@ -1299,6 +1298,12 @@ void OnSetScreenFiltering(uiMenuItem* item, uiWindow* window, void* blarg) else Config::ScreenFilter = 0; } +void OnSetLimitFPS(uiMenuItem* item, uiWindow* window, void* blarg) +{ + int chk = uiMenuItemChecked(item); + if (chk != 0) Config::LimitFPS = true; + else Config::LimitFPS = false; +} void ApplyNewSettings() { @@ -1509,6 +1514,10 @@ int main(int argc, char** argv) uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL); uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1); + menuitem = uiMenuAppendCheckItem(menu, "Limit framerate"); + uiMenuItemOnClicked(menuitem, OnSetLimitFPS, NULL); + uiMenuItemSetChecked(menuitem, Config::LimitFPS==1); + int w = Config::WindowWidth; int h = Config::WindowHeight; |