From 9f3aae873f772e0e2a9ad0b4d8286aa10b72938f Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 29 Jun 2013 20:16:09 -0700 Subject: [PATCH] Add a config setting to force 60 fps in games. --- Core/Config.cpp | 2 ++ Core/Config.h | 1 + Core/HLE/sceDisplay.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/Core/Config.cpp b/Core/Config.cpp index 1e59ba28cd..e904862e86 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -105,6 +105,7 @@ void Config::Load(const char *iniFileName) graphics->Get("VBO", &bUseVBO, false); graphics->Get("FrameSkip", &iFrameSkip, 0); graphics->Get("FrameRate", &iFpsLimit, 60); + graphics->Get("ForceGameFPS", &iForceGameFPS, 0); #ifdef USING_GLES2 graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 0); #else @@ -222,6 +223,7 @@ void Config::Save() graphics->Set("VBO", bUseVBO); graphics->Set("FrameSkip", iFrameSkip); graphics->Set("FrameRate", iFpsLimit); + graphics->Set("ForceGameFPS", iForceGameFPS); graphics->Set("AnisotropyLevel", iAnisotropyLevel); graphics->Set("VertexCache", bVertexCache); graphics->Set("FullScreen", bFullScreen); diff --git a/Core/Config.h b/Core/Config.h index d790965ab1..8a3663cba3 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -88,6 +88,7 @@ public: int iTexScalingType; // 0 = xBRZ, 1 = Hybrid bool bTexDeposterize; int iFpsLimit; + int iForceGameFPS; int iMaxRecent; bool bEnableCheats; bool bReloadCheats; diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 6a0fbe358e..e59a852072 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -124,6 +124,7 @@ static size_t fpsHistoryValid = 0; static int lastNumFlips = 0; static int numFlips = 0; static float flips = 0.0f; +static u64 lastFlipCycles = 0; void hleEnterVblank(u64 userdata, int cyclesLate); void hleLeaveVblank(u64 userdata, int cyclesLate); @@ -142,6 +143,7 @@ void __DisplayInit() { framebuf.topaddr = 0x04000000; framebuf.pspFramebufFormat = PSP_DISPLAY_PIXEL_FORMAT_8888; framebuf.pspFramebufLinesize = 480; // ?? + lastFlipCycles = 0; enterVblankEvent = CoreTiming::RegisterEvent("EnterVBlank", &hleEnterVblank); leaveVblankEvent = CoreTiming::RegisterEvent("LeaveVBlank", &hleLeaveVblank); @@ -512,6 +514,14 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync) if (topaddr != framebuf.topaddr) { ++numFlips; + if (g_Config.iForceGameFPS) { + u64 now = CoreTiming::GetTicks(); + u64 expected = msToCycles(1000) / g_Config.iForceGameFPS; + u64 actual = now - lastFlipCycles; + if (actual < expected) + hleEatCycles((int)(expected - actual)); + lastFlipCycles = CoreTiming::GetTicks(); + } } if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) {