From 54b79dffa8eafe9da9765329930e8832ae90ae83 Mon Sep 17 00:00:00 2001 From: Thomas Guillemard Date: Thu, 25 Jul 2019 16:44:51 +0200 Subject: Implement time:* 4.0.0 commands (#736) * Abstract SteadyClockCore to follow Nintendo changes in 4.x This is the ground work for 4.0.0 support * Implement TickBasedSteadyClockCore Preparation for the ephemeral clock. * Refactor SystemClockCore to follow 4.0.0 changes * Implement EphemeralNetworkSystemClock * Implement GetSnapshotClock & GetSnapshotClockFromSystemClockContext * Implement CalculateStandardUserSystemClockDifferenceByUser & CalculateSpanBetween * Remove an outdated comment & unused import * Fix a nit and GetClockSnapshot * Address comment --- .../Time/Clock/StandardNetworkSystemClockCore.cs | 42 +++++----------------- 1 file changed, 9 insertions(+), 33 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs') diff --git a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs index c00f460e..5037fb60 100644 --- a/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs +++ b/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs @@ -1,35 +1,28 @@ -using System; -using Ryujinx.HLE.HOS.Kernel.Threading; +using Ryujinx.HLE.HOS.Kernel.Threading; namespace Ryujinx.HLE.HOS.Services.Time.Clock { class StandardNetworkSystemClockCore : SystemClockCore { - private SteadyClockCore _steadyClockCore; - private SystemClockContext _context; private TimeSpanType _standardNetworkClockSufficientAccuracy; - private static StandardNetworkSystemClockCore instance; + private static StandardNetworkSystemClockCore _instance; public static StandardNetworkSystemClockCore Instance { get { - if (instance == null) + if (_instance == null) { - instance = new StandardNetworkSystemClockCore(SteadyClockCore.Instance); + _instance = new StandardNetworkSystemClockCore(StandardSteadyClockCore.Instance); } - return instance; + return _instance; } } - public StandardNetworkSystemClockCore(SteadyClockCore steadyClockCore) + public StandardNetworkSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore) { - _steadyClockCore = steadyClockCore; - _context = new SystemClockContext(); - - _context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId(); _standardNetworkClockSufficientAccuracy = new TimeSpanType(0); } @@ -40,25 +33,6 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return ResultCode.Success; } - public override SteadyClockCore GetSteadyClockCore() - { - return _steadyClockCore; - } - - public override ResultCode GetSystemClockContext(KThread thread, out SystemClockContext context) - { - context = _context; - - return ResultCode.Success; - } - - public override ResultCode SetSystemClockContext(SystemClockContext context) - { - _context = context; - - return ResultCode.Success; - } - public bool IsStandardNetworkSystemClockAccuracySufficient(KThread thread) { SteadyClockCore steadyClockCore = GetSteadyClockCore(); @@ -66,7 +40,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock bool isStandardNetworkClockSufficientAccuracy = false; - if (_context.SteadyTimePoint.GetSpanBetween(currentTimePoint, out long outSpan) == ResultCode.Success) + ResultCode result = GetSystemClockContext(thread, out SystemClockContext context); + + if (result == ResultCode.Success && context.SteadyTimePoint.GetSpanBetween(currentTimePoint, out long outSpan) == ResultCode.Success) { isStandardNetworkClockSufficientAccuracy = outSpan * 1000000000 < _standardNetworkClockSufficientAccuracy.NanoSeconds; } -- cgit v1.2.3