diff options
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs index b69b7d3c..e661ab53 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs @@ -1,4 +1,5 @@ using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Services.Bpc; using Ryujinx.HLE.Utilities; using System; @@ -6,6 +7,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class SteadyClockCore { + private long _setupValue; + private ResultCode _setupResultCode; + private bool _isRtcResetDetected; private TimeSpanType _testOffset; private TimeSpanType _internalOffset; private UInt128 _clockSourceId; @@ -42,7 +46,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(thread.Context.ThreadState.CntpctEl0, thread.Context.ThreadState.CntfrqEl0); - result.TimePoint = _internalOffset.ToSeconds() + ticksTimeSpan.ToSeconds(); + result.TimePoint = _setupValue + ticksTimeSpan.ToSeconds(); return result; } @@ -57,6 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock SteadyClockTimePoint result = GetTimePoint(thread); result.TimePoint += _testOffset.ToSeconds(); + result.TimePoint += _internalOffset.ToSeconds(); return result; } @@ -71,16 +76,56 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock _testOffset = testOffset; } - // TODO: check if this is accurate + public ResultCode GetRtcValue(out ulong rtcValue) + { + return (ResultCode)IRtcManager.GetExternalRtcValue(out rtcValue); + } + + public bool IsRtcResetDetected() + { + return _isRtcResetDetected; + } + + public ResultCode GetSetupResultCode() + { + return _setupResultCode; + } + public TimeSpanType GetInternalOffset() { return _internalOffset; } - // TODO: check if this is accurate public void SetInternalOffset(TimeSpanType internalOffset) { _internalOffset = internalOffset; } + + public ResultCode GetSetupResultValue() + { + return _setupResultCode; + } + + public void ConfigureSetupValue() + { + int retry = 0; + + ResultCode result = ResultCode.Success; + + while (retry < 20) + { + result = (ResultCode)IRtcManager.GetExternalRtcValue(out ulong rtcValue); + + if (result == ResultCode.Success) + { + _setupValue = (long)rtcValue; + break; + } + + retry++; + } + + _setupResultCode = result; + } } } |
