From fb7c3d96fddc7269e396e380c1b3d9a103b0f555 Mon Sep 17 00:00:00 2001 From: Sacha Date: Sat, 16 Nov 2013 02:16:03 +1000 Subject: [PATCH] Introduce Timer Hack. Has been used in previous Symbian releases to improve speed. Was thought to only work on Wipeout but actually works on most games? Games that run based on internal timer will experience 60 VPS without frameskip. --- Core/Config.cpp | 7 +++++++ Core/Config.h | 1 + Core/CoreTiming.cpp | 8 ++++++++ Core/HLE/sceDisplay.cpp | 4 ++++ Core/HLE/sceDisplay.h | 1 + UI/EmuScreen.cpp | 2 ++ UI/GameSettingsScreen.cpp | 1 + 7 files changed, 24 insertions(+) diff --git a/Core/Config.cpp b/Core/Config.cpp index 39d35cbec..d1898f27b 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -187,6 +187,12 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) { graphics->Get("VSyncInterval", &bVSync, false); graphics->Get("DisableStencilTest", &bDisableStencilTest, false); graphics->Get("AlwaysDepthWrite", &bAlwaysDepthWrite, false); +// Has been in use on Symbian since v0.7. Preferred option. +#ifdef __SYMBIAN32__ + graphics->Get("TimerHack", &bTimerHack, true); +#else + graphics->Get("TimerHack", &bTimerHack, false); +#endif graphics->Get("LowQualitySplineBezier", &bLowQualitySplineBezier, false); graphics->Get("WipeFramebufferAlpha", &bWipeFramebufferAlpha, false); graphics->Get("PostShader", &sPostShaderName, "Off"); @@ -427,6 +433,7 @@ void Config::Save() { graphics->Set("VSyncInterval", bVSync); graphics->Set("DisableStencilTest", bDisableStencilTest); graphics->Set("AlwaysDepthWrite", bAlwaysDepthWrite); + graphics->Set("TimerHack", bTimerHack); graphics->Set("LowQualitySplineBezier", bLowQualitySplineBezier); graphics->Set("PostShader", sPostShaderName); diff --git a/Core/Config.h b/Core/Config.h index 2922d4c00..def8072b2 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -101,6 +101,7 @@ public: bool bReloadCheats; bool bDisableStencilTest; bool bAlwaysDepthWrite; + bool bTimerHack; bool bLowQualitySplineBezier; bool bWipeFramebufferAlpha; // this was meant to be CopyStencilToAlpha but not done yet. std::string sPostShaderName; // Off for off. diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index b9867e990..c790dfce9 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -24,8 +24,10 @@ #include "Atomics.h" #include "CoreTiming.h" #include "Core.h" +#include "Config.h" #include "HLE/sceKernelThread.h" #include "../Common/ChunkFile.h" +#include "HLE/sceDisplay.h" int CPU_HZ = 222000000; @@ -97,6 +99,12 @@ void SetClockFrequencyMHz(int cpuMhz) int GetClockFrequencyMHz() { + if (g_Config.bTimerHack) { + float vps; + __DisplayGetVPS(&vps); + if (vps > 5.0f) + return (int)((float)(CPU_HZ / 1000000)*(vps / 60.0f)); + } return CPU_HZ / 1000000; } diff --git a/Core/HLE/sceDisplay.cpp b/Core/HLE/sceDisplay.cpp index 060fd6887..229a47346 100644 --- a/Core/HLE/sceDisplay.cpp +++ b/Core/HLE/sceDisplay.cpp @@ -307,6 +307,10 @@ void __DisplayGetFPS(float *out_vps, float *out_fps, float *out_actual_fps) { *out_actual_fps = actualFps; } +void __DisplayGetVPS(float *out_vps) { + *out_vps = fps; +} + void __DisplayGetAveragedFPS(float *out_vps, float *out_fps) { float avg = 0.0; if (fpsHistoryValid > 0) { diff --git a/Core/HLE/sceDisplay.h b/Core/HLE/sceDisplay.h index 2bec04537..521971845 100644 --- a/Core/HLE/sceDisplay.h +++ b/Core/HLE/sceDisplay.h @@ -35,4 +35,5 @@ void __DisplayListenVblank(VblankCallback callback); void __DisplayGetDebugStats(char stats[2048]); void __DisplayGetFPS(float *out_vps, float *out_fps, float *out_actual_fps); +void __DisplayGetVPS(float *out_vps); void __DisplayGetAveragedFPS(float *out_vps, float *out_fps); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 17fbabbc0..a0ff3ce32 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -613,6 +613,8 @@ void EmuScreen::render() { sprintf(fpsbuf, "FPS: %0.1f", actual_fps); break; case 3: sprintf(fpsbuf, "%0.0f/%0.0f (%0.1f%%)", actual_fps, fps, vps / 60.0f * 100.0f); break; + default: + return; } ui_draw2d.SetFontScale(0.7f, 0.7f); ui_draw2d.DrawText(UBUNTU24, fpsbuf, dp_xres - 8, 12, 0xc0000000, ALIGN_TOPRIGHT | FLAG_DYNAMIC_ASCII); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 22ce9bf5b..699c5ccfc 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -175,6 +175,7 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexFiltering, gs->T("Texture Filter"), texFilters, 1, ARRAY_SIZE(texFilters), gs, screenManager())); graphicsSettings->Add(new ItemHeader(gs->T("Hack Settings", "Hack Settings (these WILL cause glitches)"))); + graphicsSettings->Add(new CheckBox(&g_Config.bTimerHack, gs->T("Timer Hack"))); // Maybe hide this on non-PVR? graphicsSettings->Add(new CheckBox(&g_Config.bDisableAlphaTest, gs->T("Disable Alpha Test (PowerVR speedup)")))->OnClick.Handle(this, &GameSettingsScreen::OnShaderChange); graphicsSettings->Add(new CheckBox(&g_Config.bDisableStencilTest, gs->T("Disable Stencil Test")));