diff --git a/Core/Config.cpp b/Core/Config.cpp index 83bf9602b..1c37fef2e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -85,6 +85,7 @@ void Config::Load(const char *iniFileName) #endif //FastMemory Default set back to True when solve UNIMPL _sceAtracGetContextAddress making game crash cpu->Get("FastMemory", &bFastMemory, false); + cpu->Get("CPUSpeed", &iLockedCPUSpeed, false); IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics"); graphics->Get("ShowFPSCounter", &iShowFPSCounter, false); @@ -204,6 +205,7 @@ void Config::Save() IniFile::Section *cpu = iniFile.GetOrCreateSection("CPU"); cpu->Set("Jit", bJit); cpu->Set("FastMemory", bFastMemory); + cpu->Set("CPUSpeed", iLockedCPUSpeed); IniFile::Section *graphics = iniFile.GetOrCreateSection("Graphics"); graphics->Set("ShowFPSCounter", iShowFPSCounter); diff --git a/Core/Config.h b/Core/Config.h index 2622fbad1..ff99aced4 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -52,6 +52,7 @@ public: bool bIgnoreBadMemAccess; bool bFastMemory; bool bJit; + int iLockedCPUSpeed; bool bAutoSaveSymbolMap; std::string sReportHost; std::vector recentIsos; diff --git a/Core/HLE/scePower.cpp b/Core/HLE/scePower.cpp index 0903e3d07..1493f85c6 100644 --- a/Core/HLE/scePower.cpp +++ b/Core/HLE/scePower.cpp @@ -22,6 +22,7 @@ #include "scePower.h" #include "sceKernelThread.h" +#include "Core/Config.h" const int PSP_POWER_ERROR_TAKEN_SLOT = 0x80000020; const int PSP_POWER_ERROR_SLOTS_FULL = 0x80000022; @@ -52,6 +53,12 @@ static int busFreq = 111; void __PowerInit() { memset(powerCbSlots, 0, sizeof(powerCbSlots)); volatileMemLocked = false; + + if(g_Config.iLockedCPUSpeed > 0) { + CoreTiming::SetClockFrequencyMHz(g_Config.iLockedCPUSpeed); + pllFreq = g_Config.iLockedCPUSpeed; + busFreq = g_Config.iLockedCPUSpeed / 2; + } } void __PowerDoState(PointerWrap &p) { @@ -226,22 +233,37 @@ int sceKernelVolatileMemLock(int type, int paddr, int psize) { u32 scePowerSetClockFrequency(u32 pllfreq, u32 cpufreq, u32 busfreq) { - CoreTiming::SetClockFrequencyMHz(cpufreq); - pllFreq = pllfreq; - busFreq = busfreq; - INFO_LOG(HLE,"scePowerSetClockFrequency(%i,%i,%i)", pllfreq, cpufreq, busfreq); + if(g_Config.iLockedCPUSpeed > 0) { + INFO_LOG(HLE,"scePowerSetClockFrequency(%i,%i,%i): locked by user config at %i, %i, %i", pllfreq, cpufreq, busfreq, g_Config.iLockedCPUSpeed, g_Config.iLockedCPUSpeed, busFreq); + } + else { + CoreTiming::SetClockFrequencyMHz(cpufreq); + pllFreq = pllfreq; + busFreq = busfreq; + INFO_LOG(HLE,"scePowerSetClockFrequency(%i,%i,%i)", pllfreq, cpufreq, busfreq); + } return 0; } u32 scePowerSetCpuClockFrequency(u32 cpufreq) { - CoreTiming::SetClockFrequencyMHz(cpufreq); - DEBUG_LOG(HLE,"scePowerSetCpuClockFrequency(%i)", cpufreq); + if(g_Config.iLockedCPUSpeed > 0) { + DEBUG_LOG(HLE,"scePowerSetCpuClockFrequency(%i): locked by user config at %i", cpufreq, g_Config.iLockedCPUSpeed); + } + else { + CoreTiming::SetClockFrequencyMHz(cpufreq); + DEBUG_LOG(HLE,"scePowerSetCpuClockFrequency(%i)", cpufreq); + } return 0; } u32 scePowerSetBusClockFrequency(u32 busfreq) { - busFreq = busfreq; - DEBUG_LOG(HLE,"scePowerSetBusClockFrequency(%i)", busfreq); + if(g_Config.iLockedCPUSpeed > 0) { + DEBUG_LOG(HLE,"scePowerSetBusClockFrequency(%i): locked by user config at %i", busfreq, busFreq); + } + else { + busFreq = busfreq; + DEBUG_LOG(HLE,"scePowerSetBusClockFrequency(%i)", busfreq); + } return 0; } diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index b2f137d8e..5cdb7fd55 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -1189,6 +1189,18 @@ void SystemScreen::render() { if (g_Config.bJit) UICheckBox(GEN_ID, x, y += stride, s->T("Fast Memory", "Fast Memory (unstable)"), ALIGN_TOPLEFT, &g_Config.bFastMemory); + bool LockCPUSpeed = g_Config.iLockedCPUSpeed != 0; + UICheckBox(GEN_ID, x, y += stride, s->T("Lock PSP CPU Speed"), ALIGN_TOPLEFT, &LockCPUSpeed); + if(LockCPUSpeed) { + if(g_Config.iLockedCPUSpeed <= 0) + g_Config.iLockedCPUSpeed = 222; + char showCPUSpeed[256]; + sprintf(showCPUSpeed, "%s %d", s->T("Locked CPU Speed: "), g_Config.iLockedCPUSpeed); + ui_draw2d.DrawText(UBUNTU24, showCPUSpeed, x + 60, (y += stride) - 5, 0xFFFFFFFF, ALIGN_LEFT); + } + else { + g_Config.iLockedCPUSpeed = 0; + } //UICheckBox(GEN_ID, x, y += stride, s->T("Daylight Savings"), ALIGN_TOPLEFT, &g_Config.bDayLightSavings); const char *buttonPreferenceTitle;