Merge pull request #4033 from RisingFog/configurable_rtc

Disable changing Custom RTC when game is running
This commit is contained in:
Mat M 2016-07-19 23:09:43 -04:00 committed by GitHub
commit 3fbd781cb8
4 changed files with 23 additions and 17 deletions

View File

@ -421,18 +421,10 @@ u32 CEXIIPL::GetGCTime()
// let's keep time moving forward, regardless of what it starts at
ltime += CoreTiming::GetTicks() / SystemTimers::GetTicksPerSecond();
}
else if (SConfig::GetInstance().bEnableCustomRTC)
{
_assert_(!Core::g_want_determinism);
ltime = SConfig::GetInstance().m_customRTCValue;
// let's keep time moving forward, regardless of what it starts at
ltime += Common::Timer::GetLocalTimeSinceJan1970() - SystemTimers::GetLocalTimeOnBoot();
}
else
{
_assert_(!Core::g_want_determinism);
ltime = Common::Timer::GetLocalTimeSinceJan1970();
ltime = Common::Timer::GetLocalTimeSinceJan1970() - SystemTimers::GetLocalTimeRTCOffset();
}
return ((u32)ltime - cJanuary2000);

View File

@ -84,7 +84,7 @@ static int s_audio_dma_period;
static int s_ipc_hle_period;
// Custom RTC
static u64 s_localtime_on_boot;
static s64 s_localtime_rtc_offset = 0;
u32 GetTicksPerSecond()
{
@ -160,9 +160,9 @@ u64 GetFakeTimeBase()
((CoreTiming::GetTicks() - CoreTiming::GetFakeTBStartTicks()) / TIMER_RATIO);
}
u64 GetLocalTimeOnBoot()
s64 GetLocalTimeRTCOffset()
{
return s_localtime_on_boot;
return s_localtime_rtc_offset;
}
static void PatchEngineCallback(u64 userdata, s64 cyclesLate)
@ -228,7 +228,11 @@ void Init()
Common::Timer::IncreaseResolution();
// store and convert localtime at boot to timebase ticks
s_localtime_on_boot = Common::Timer::GetLocalTimeSinceJan1970();
if (SConfig::GetInstance().bEnableCustomRTC)
{
s_localtime_rtc_offset =
Common::Timer::GetLocalTimeSinceJan1970() - SConfig::GetInstance().m_customRTCValue;
}
CoreTiming::SetFakeTBStartValue((u64)(s_cpu_core_clock / TIMER_RATIO) *
(u64)CEXIIPL::GetGCTime());
CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());
@ -258,7 +262,7 @@ void Init()
void Shutdown()
{
Common::Timer::RestoreResolution();
s_localtime_on_boot = 0;
s_localtime_rtc_offset = 0;
}
} // namespace

View File

@ -45,5 +45,5 @@ u32 GetFakeDecrementer();
void TimeBaseSet();
u64 GetFakeTimeBase();
// Custom RTC
u64 GetLocalTimeOnBoot();
s64 GetLocalTimeRTCOffset();
}

View File

@ -15,6 +15,7 @@
#include <wx/timectrl.h>
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "DolphinWX/Config/AdvancedConfigPane.h"
AdvancedConfigPane::AdvancedConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id)
@ -186,9 +187,18 @@ void AdvancedConfigPane::LoadCustomRTC()
else
m_custom_rtc_date_picker->SetRange(wxDateTime(1, wxDateTime::Jan, 2000),
wxDateTime(31, wxDateTime::Dec, 2099));
if (Core::IsRunning())
{
m_custom_rtc_checkbox->Enable(false);
m_custom_rtc_date_picker->Enable(false);
m_custom_rtc_time_picker->Enable(false);
}
else
{
m_custom_rtc_date_picker->Enable(custom_rtc_enabled);
m_custom_rtc_time_picker->Enable(custom_rtc_enabled);
}
}
void AdvancedConfigPane::UpdateCustomRTC(time_t date, time_t time)
{