Add option to limit framerate from UI
Signed-off-by: Madhav Kanbur <abcdjdj@gmail.com>
This commit is contained in:
parent
27e1ca4103
commit
78c767b693
|
@ -47,6 +47,8 @@ int ScreenLayout;
|
||||||
int ScreenSizing;
|
int ScreenSizing;
|
||||||
int ScreenFilter;
|
int ScreenFilter;
|
||||||
|
|
||||||
|
int LimitFPS;
|
||||||
|
|
||||||
int DirectBoot;
|
int DirectBoot;
|
||||||
|
|
||||||
int Threaded3D;
|
int Threaded3D;
|
||||||
|
@ -103,6 +105,8 @@ ConfigEntry ConfigFile[] =
|
||||||
{"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0},
|
{"ScreenSizing", 0, &ScreenSizing, 0, NULL, 0},
|
||||||
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},
|
{"ScreenFilter", 0, &ScreenFilter, 1, NULL, 0},
|
||||||
|
|
||||||
|
{"LimitFPS", 0, &LimitFPS, 1, NULL, 0},
|
||||||
|
|
||||||
{"DirectBoot", 0, &DirectBoot, 1, NULL, 0},
|
{"DirectBoot", 0, &DirectBoot, 1, NULL, 0},
|
||||||
|
|
||||||
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
|
{"Threaded3D", 0, &Threaded3D, 1, NULL, 0},
|
||||||
|
|
|
@ -40,6 +40,8 @@ extern int ScreenLayout;
|
||||||
extern int ScreenSizing;
|
extern int ScreenSizing;
|
||||||
extern int ScreenFilter;
|
extern int ScreenFilter;
|
||||||
|
|
||||||
|
extern int LimitFPS;
|
||||||
|
|
||||||
extern int DirectBoot;
|
extern int DirectBoot;
|
||||||
|
|
||||||
extern int Threaded3D;
|
extern int Threaded3D;
|
||||||
|
|
|
@ -216,7 +216,6 @@ int EmuThreadFunc(void* burp)
|
||||||
u32 lasttick = starttick;
|
u32 lasttick = starttick;
|
||||||
u32 lastmeasuretick = lasttick;
|
u32 lastmeasuretick = lasttick;
|
||||||
u32 fpslimitcount = 0;
|
u32 fpslimitcount = 0;
|
||||||
bool limitfps = true;
|
|
||||||
char melontitle[100];
|
char melontitle[100];
|
||||||
|
|
||||||
while (EmuRunning != 0)
|
while (EmuRunning != 0)
|
||||||
|
@ -306,7 +305,7 @@ int EmuThreadFunc(void* burp)
|
||||||
lasttick = curtick;
|
lasttick = curtick;
|
||||||
|
|
||||||
u32 wantedtick = starttick + (u32)((float)fpslimitcount * framerate);
|
u32 wantedtick = starttick + (u32)((float)fpslimitcount * framerate);
|
||||||
if (curtick < wantedtick && limitfps)
|
if (curtick < wantedtick && Config::LimitFPS)
|
||||||
{
|
{
|
||||||
SDL_Delay(wantedtick - curtick);
|
SDL_Delay(wantedtick - curtick);
|
||||||
}
|
}
|
||||||
|
@ -1299,6 +1298,12 @@ void OnSetScreenFiltering(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
else Config::ScreenFilter = 0;
|
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()
|
void ApplyNewSettings()
|
||||||
{
|
{
|
||||||
|
@ -1509,6 +1514,10 @@ int main(int argc, char** argv)
|
||||||
uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL);
|
uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL);
|
||||||
uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1);
|
uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1);
|
||||||
|
|
||||||
|
menuitem = uiMenuAppendCheckItem(menu, "Limit framerate");
|
||||||
|
uiMenuItemOnClicked(menuitem, OnSetLimitFPS, NULL);
|
||||||
|
uiMenuItemSetChecked(menuitem, Config::LimitFPS==1);
|
||||||
|
|
||||||
|
|
||||||
int w = Config::WindowWidth;
|
int w = Config::WindowWidth;
|
||||||
int h = Config::WindowHeight;
|
int h = Config::WindowHeight;
|
||||||
|
|
Loading…
Reference in New Issue