summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorsl1nk3.s <sl1nk3.s@gmail.com>2009-08-03 18:35:25 +0000
committersl1nk3.s <sl1nk3.s@gmail.com>2009-08-03 18:35:25 +0000
commit8b0bc273c5f4aaeb9829c2b8d01c21241fd8781d (patch)
tree08cf44d3da07af08e713d9e6442d9c0e482374e5 /Source/Core
parent8c36e85b34cc45dc8afe61ed7668cddbbed82dce (diff)
Fix framelimiter's accuracy, thanks to sskkiipp !(issue 1237)
Also added an "auto" mode which automatically limits the framerate to fullspeed and move it from Interface settings to Basic setttings git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3934 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/Core.cpp42
-rw-r--r--Source/Core/DolphinWX/Src/ConfigMain.cpp25
2 files changed, 33 insertions, 34 deletions
diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp
index 6e40c63adc..7c344c0b68 100644
--- a/Source/Core/Core/Src/Core.cpp
+++ b/Source/Core/Core/Src/Core.cpp
@@ -602,38 +602,33 @@ void Callback_VideoCopiedToXFB(bool video_update)
static Common::Timer Timer;
static u32 frames = 0;
static u32 videoupd = 0;
- static u64 old_frametime=0;
if (video_update)
videoupd++;
else
- {
frames++;
- // Custom frame limiter
- // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
-
- u32 targetfps = (SConfig::GetInstance().m_Framelimit)*5;
- u64 new_frametime;
- s16 wait_frametime;
-
- if (targetfps > 0)
- {
- new_frametime = Timer.GetTimeDifference() - old_frametime;
- old_frametime = Timer.GetTimeDifference();
- wait_frametime = (1000/targetfps) - (u16)new_frametime;
- if (targetfps < 35)
- wait_frametime--;
- if (wait_frametime > 0)
- Common::SleepCurrentThread(wait_frametime*2);
- }
+ // Custom frame limiter
+ // ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+ u32 targetfps = SConfig::GetInstance().m_Framelimit * 5;
+
+ if (targetfps > 5)
+ {
+ double wait_frametime = (1000.0 / targetfps);
+
+ while (Timer.GetTimeDifference() < wait_frametime * frames)
+ Common::SleepCurrentThread(1);
+ }
+ else if (targetfps < 5)
+ {
+ double wait_frametime = (1000.0 / VideoInterface::TargetRefreshRate);
+
+ while (Timer.GetTimeDifference() < wait_frametime * videoupd)
+ Common::SleepCurrentThread(1);
}
if (Timer.GetTimeDifference() >= 1000)
{
- // reset timer for framelimiter, placed here so no additional check for 1000ms is required -> don't delete please :)
- old_frametime = 0;
-
// Time passed
float t = (float)(Timer.GetTimeDifference()) / 1000.f;
@@ -656,7 +651,8 @@ void Callback_VideoCopiedToXFB(bool video_update)
float FPS = (float)frames / t;
// for some reasons "VideoInterface::ActualRefreshRate" gives some odd results :(
float VPS = (float)videoupd / t;
- int TargetVPS = (int)VideoInterface::TargetRefreshRate;
+
+ int TargetVPS = (int)(VideoInterface::TargetRefreshRate + 0.5);
float Speed = (VPS / TargetVPS) * 100.0f;
diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp
index 2fdf9bf4a5..8217d3404e 100644
--- a/Source/Core/DolphinWX/Src/ConfigMain.cpp
+++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp
@@ -174,8 +174,8 @@ void CConfigMain::CreateGUIControls()
// GUI
arrayStringFor_InterfaceLang = arrayStringFor_GCSystemLang;
// Framelimit
+ arrayStringFor_Framelimit.Add(wxT("auto"));
arrayStringFor_Framelimit.Add(wxT("off"));
- arrayStringFor_Framelimit.Add(wxT("5"));
arrayStringFor_Framelimit.Add(wxT("10"));
arrayStringFor_Framelimit.Add(wxT("15"));
arrayStringFor_Framelimit.Add(wxT("20"));
@@ -213,6 +213,12 @@ void CConfigMain::CreateGUIControls()
SkipIdle->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle);
EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, wxT("Enable Cheats"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
EnableCheats->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableCheats);
+
+ // Framelimit
+ wxStaticText *FramelimitText = new wxStaticText(GeneralPage, ID_FRAMELIMIT_TEXT, wxT("Framelimit :"), wxDefaultPosition, wxDefaultSize);
+ Framelimit = new wxChoice(GeneralPage, ID_FRAMELIMIT, wxDefaultPosition, wxDefaultSize, arrayStringFor_Framelimit, 0, wxDefaultValidator);
+ Framelimit->SetSelection(SConfig::GetInstance().m_Framelimit);
+
// Core Settings - Advanced
AlwaysUseHLEBIOS = new wxCheckBox(GeneralPage, ID_ALLWAYS_HLEBIOS, wxT("HLE the BIOS all the time"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
AlwaysUseHLEBIOS->SetValue(SConfig::GetInstance().m_LocalCoreStartupParameter.bHLEBios);
@@ -256,12 +262,7 @@ void CConfigMain::CreateGUIControls()
// need redesign
InterfaceLang->SetSelection(SConfig::GetInstance().m_InterfaceLanguage);
- // Choose Framelimit
- wxStaticText *FramelimitText = new wxStaticText(GeneralPage, ID_FRAMELIMIT_TEXT, wxT("Framelimit (experimental):"), wxDefaultPosition, wxDefaultSize);
- Framelimit = new wxChoice(GeneralPage, ID_FRAMELIMIT, wxDefaultPosition, wxDefaultSize, arrayStringFor_Framelimit, 0, wxDefaultValidator);
- Framelimit->SetSelection(SConfig::GetInstance().m_Framelimit);
-
- // Themes
+ // Themes - this should really be a wxChoice...
wxArrayString ThemeChoices;
ThemeChoices.Add(wxT("Boomy"));
ThemeChoices.Add(wxT("Vista"));
@@ -290,6 +291,7 @@ void CConfigMain::CreateGUIControls()
InterfaceLang->SetToolTip(wxT("For the time being this will only change the text shown in")
wxT("\nthe game list of PAL GC games."));
+
// Copyright notice
Theme->SetItemToolTip(0, wxT("Created by Milosz Wlazlo [miloszwl@miloszwl.com, miloszwl.deviantart.com]"));
Theme->SetItemToolTip(1, wxT("Created by VistaIcons.com"));
@@ -302,6 +304,11 @@ void CConfigMain::CreateGUIControls()
sbBasic->Add(UseDualCore, 0, wxALL, 5);
sbBasic->Add(SkipIdle, 0, wxALL, 5);
sbBasic->Add(EnableCheats, 0, wxALL, 5);
+ wxBoxSizer *sFramelimit = new wxBoxSizer(wxHORIZONTAL);
+ sFramelimit->Add(FramelimitText, 0, wxALL | wxALIGN_CENTER, 1);
+ sFramelimit->Add(Framelimit, 0, wxALL | wxEXPAND, 5);
+ sbBasic->Add(sFramelimit, 0, wxALL | wxEXPAND, 5);
+
sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, wxT("Advanced Settings"));
sbAdvanced->Add(AlwaysUseHLEBIOS, 0, wxALL, 5);
sbAdvanced->Add(UseDynaRec, 0, wxALL, 5);
@@ -330,10 +337,6 @@ void CConfigMain::CreateGUIControls()
sInterfaceLanguage->Add(InterfaceLangText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
sInterfaceLanguage->Add(InterfaceLang, 0, wxEXPAND | wxALL, 5);
sbInterface->Add(sInterfaceLanguage, 0, wxEXPAND | wxALL, 5);
- wxBoxSizer *sFramelimit = new wxBoxSizer(wxHORIZONTAL);
- sFramelimit->Add(FramelimitText, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
- sFramelimit->Add(Framelimit, 0, wxEXPAND | wxALL, 5);
- sbInterface->Add(sFramelimit, 0, wxEXPAND | wxALL, 5);
// Populate the entire page
sGeneralPage = new wxBoxSizer(wxVERTICAL);