diff options
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Time/Clock')
14 files changed, 71 insertions, 74 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs index fb7ebdc5..49da1245 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/LocalSystemClockContextWriter.cs @@ -2,7 +2,7 @@ { class LocalSystemClockContextWriter : SystemClockContextUpdateCallback { - private TimeSharedMemory _sharedMemory; + private readonly TimeSharedMemory _sharedMemory; public LocalSystemClockContextWriter(TimeSharedMemory sharedMemory) { @@ -11,7 +11,7 @@ protected override ResultCode Update() { - _sharedMemory.UpdateLocalSystemClockContext(_context); + _sharedMemory.UpdateLocalSystemClockContext(Context); return ResultCode.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs index 36468ec1..ef315ea4 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/NetworkSystemClockContextWriter.cs @@ -2,7 +2,7 @@ { class NetworkSystemClockContextWriter : SystemClockContextUpdateCallback { - private TimeSharedMemory _sharedMemory; + private readonly TimeSharedMemory _sharedMemory; public NetworkSystemClockContextWriter(TimeSharedMemory sharedMemory) { @@ -11,7 +11,7 @@ protected override ResultCode Update() { - _sharedMemory.UpdateNetworkSystemClockContext(_context); + _sharedMemory.UpdateNetworkSystemClockContext(Context); return ResultCode.Success; } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs index 20c334e8..458ec405 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardLocalSystemClockCore.cs @@ -2,6 +2,6 @@ { class StandardLocalSystemClockCore : SystemClockCore { - public StandardLocalSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore) {} + public StandardLocalSystemClockCore(StandardSteadyClockCore steadyClockCore) : base(steadyClockCore) { } } } diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs index aec03485..200ab630 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardNetworkSystemClockCore.cs @@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public bool IsStandardNetworkSystemClockAccuracySufficient(ITickSource tickSource) { - SteadyClockCore steadyClockCore = GetSteadyClockCore(); + SteadyClockCore steadyClockCore = GetSteadyClockCore(); SteadyClockTimePoint currentTimePoint = steadyClockCore.GetCurrentTimePoint(tickSource); bool isStandardNetworkClockSufficientAccuracy = false; diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs index 8392c4b5..3ae699ae 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardSteadyClockCore.cs @@ -11,18 +11,18 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public StandardSteadyClockCore() { - _setupValue = TimeSpanType.Zero; - _testOffset = TimeSpanType.Zero; - _internalOffset = TimeSpanType.Zero; + _setupValue = TimeSpanType.Zero; + _testOffset = TimeSpanType.Zero; + _internalOffset = TimeSpanType.Zero; _cachedRawTimePoint = TimeSpanType.Zero; } public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { - SteadyClockTimePoint result = new SteadyClockTimePoint + SteadyClockTimePoint result = new() { - TimePoint = GetCurrentRawTimePoint(tickSource).ToSeconds(), - ClockSourceId = GetClockSourceId() + TimePoint = GetCurrentRawTimePoint(tickSource).ToSeconds(), + ClockSourceId = GetClockSourceId(), }; return result; @@ -52,7 +52,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); - TimeSpanType rawTimePoint = new TimeSpanType(_setupValue.NanoSeconds + ticksTimeSpan.NanoSeconds); + TimeSpanType rawTimePoint = new(_setupValue.NanoSeconds + ticksTimeSpan.NanoSeconds); if (rawTimePoint.NanoSeconds < _cachedRawTimePoint.NanoSeconds) { diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs index fa485437..e50ee7da 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/StandardUserSystemClockCore.cs @@ -6,19 +6,19 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class StandardUserSystemClockCore : SystemClockCore { - private StandardLocalSystemClockCore _localSystemClockCore; - private StandardNetworkSystemClockCore _networkSystemClockCore; - private bool _autoCorrectionEnabled; - private SteadyClockTimePoint _autoCorrectionTime; - private KEvent _autoCorrectionEvent; + private readonly StandardLocalSystemClockCore _localSystemClockCore; + private readonly StandardNetworkSystemClockCore _networkSystemClockCore; + private bool _autoCorrectionEnabled; + private SteadyClockTimePoint _autoCorrectionTime; + private KEvent _autoCorrectionEvent; public StandardUserSystemClockCore(StandardLocalSystemClockCore localSystemClockCore, StandardNetworkSystemClockCore networkSystemClockCore) : base(localSystemClockCore.GetSteadyClockCore()) { - _localSystemClockCore = localSystemClockCore; + _localSystemClockCore = localSystemClockCore; _networkSystemClockCore = networkSystemClockCore; - _autoCorrectionEnabled = false; - _autoCorrectionTime = SteadyClockTimePoint.GetRandom(); - _autoCorrectionEvent = null; + _autoCorrectionEnabled = false; + _autoCorrectionTime = SteadyClockTimePoint.GetRandom(); + _autoCorrectionEvent = null; } protected override ResultCode Flush(SystemClockContext context) diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs index 18da4ed3..2d12a2a0 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs @@ -7,14 +7,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock abstract class SteadyClockCore { private UInt128 _clockSourceId; - private bool _isRtcResetDetected; - private bool _isInitialized; + private bool _isRtcResetDetected; + private bool _isInitialized; public SteadyClockCore() { - _clockSourceId = UInt128Utils.CreateRandom(); + _clockSourceId = UInt128Utils.CreateRandom(); _isRtcResetDetected = false; - _isInitialized = false; + _isInitialized = false; } public UInt128 GetClockSourceId() @@ -37,7 +37,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return new TimeSpanType(0); } - public virtual void SetTestOffset(TimeSpanType testOffset) {} + public virtual void SetTestOffset(TimeSpanType testOffset) { } public ResultCode GetRtcValue(out ulong rtcValue) { @@ -61,7 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return new TimeSpanType(0); } - public virtual void SetInternalOffset(TimeSpanType internalOffset) {} + public virtual void SetInternalOffset(TimeSpanType internalOffset) { } public virtual SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs index 6229f5ed..3f191820 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockContextUpdateCallback.cs @@ -6,22 +6,22 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { abstract class SystemClockContextUpdateCallback { - private List<KWritableEvent> _operationEventList; - protected SystemClockContext _context; - private bool _hasContext; + private readonly List<KWritableEvent> _operationEventList; + protected SystemClockContext Context; + private bool _hasContext; public SystemClockContextUpdateCallback() { _operationEventList = new List<KWritableEvent>(); - _context = new SystemClockContext(); - _hasContext = false; + Context = new SystemClockContext(); + _hasContext = false; } private bool NeedUpdate(SystemClockContext context) { if (_hasContext) { - return _context.Offset != context.Offset || _context.SteadyTimePoint.ClockSourceId != context.SteadyTimePoint.ClockSourceId; + return Context.Offset != context.Offset || Context.SteadyTimePoint.ClockSourceId != context.SteadyTimePoint.ClockSourceId; } return true; @@ -54,7 +54,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock if (NeedUpdate(context)) { - _context = context; + Context = context; _hasContext = true; result = Update(); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs index f4bbaa60..f8a995b7 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/SystemClockCore.cs @@ -5,19 +5,19 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { abstract class SystemClockCore { - private SteadyClockCore _steadyClockCore; - private SystemClockContext _context; - private bool _isInitialized; + private readonly SteadyClockCore _steadyClockCore; + private SystemClockContext _context; + private bool _isInitialized; private SystemClockContextUpdateCallback _systemClockContextUpdateCallback; public SystemClockCore(SteadyClockCore steadyClockCore) { _steadyClockCore = steadyClockCore; - _context = new SystemClockContext(); - _isInitialized = false; + _context = new SystemClockContext(); + _isInitialized = false; _context.SteadyTimePoint.ClockSourceId = steadyClockCore.GetClockSourceId(); - _systemClockContextUpdateCallback = null; + _systemClockContextUpdateCallback = null; } public virtual SteadyClockCore GetSteadyClockCore() @@ -52,10 +52,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { SteadyClockTimePoint currentTimePoint = _steadyClockCore.GetCurrentTimePoint(tickSource); - SystemClockContext clockContext = new SystemClockContext() + SystemClockContext clockContext = new() { - Offset = posixTime - currentTimePoint.TimePoint, - SteadyTimePoint = currentTimePoint + Offset = posixTime - currentTimePoint.TimePoint, + SteadyTimePoint = currentTimePoint, }; ResultCode result = SetClockContext(clockContext); @@ -99,10 +99,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock public void RegisterOperationEvent(KWritableEvent writableEvent) { - if (_systemClockContextUpdateCallback != null) - { - _systemClockContextUpdateCallback.RegisterOperationEvent(writableEvent); - } + _systemClockContextUpdateCallback?.RegisterOperationEvent(writableEvent); } public ResultCode SetSystemClockContext(SystemClockContext context) diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs index fe74da7e..99e981ec 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/TickBasedSteadyClockCore.cs @@ -4,14 +4,14 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { class TickBasedSteadyClockCore : SteadyClockCore { - public TickBasedSteadyClockCore() {} + public TickBasedSteadyClockCore() { } public override SteadyClockTimePoint GetTimePoint(ITickSource tickSource) { - SteadyClockTimePoint result = new SteadyClockTimePoint + SteadyClockTimePoint result = new() { - TimePoint = 0, - ClockSourceId = GetClockSourceId() + TimePoint = 0, + ClockSourceId = GetClockSourceId(), }; TimeSpanType ticksTimeSpan = TimeSpanType.FromTicks(tickSource.Counter, tickSource.Frequency); diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs index 07c1b405..d0a74a93 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/ClockSnapshot.cs @@ -7,23 +7,23 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Size = 0xD0)] struct ClockSnapshot { - public SystemClockContext UserContext; - public SystemClockContext NetworkContext; - public long UserTime; - public long NetworkTime; - public CalendarTime UserCalendarTime; - public CalendarTime NetworkCalendarTime; + public SystemClockContext UserContext; + public SystemClockContext NetworkContext; + public long UserTime; + public long NetworkTime; + public CalendarTime UserCalendarTime; + public CalendarTime NetworkCalendarTime; public CalendarAdditionalInfo UserCalendarAdditionalTime; public CalendarAdditionalInfo NetworkCalendarAdditionalTime; - public SteadyClockTimePoint SteadyClockTimePoint; + public SteadyClockTimePoint SteadyClockTimePoint; private LocationNameStorageHolder _locationName; public Span<byte> LocationName => MemoryMarshal.Cast<LocationNameStorageHolder, byte>(MemoryMarshal.CreateSpan(ref _locationName, LocationNameStorageHolder.Size)); [MarshalAs(UnmanagedType.I1)] - public bool IsAutomaticCorrectionEnabled; - public byte Type; + public bool IsAutomaticCorrectionEnabled; + public byte Type; public ushort Unknown; @@ -47,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return ResultCode.TimeMismatch; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs index 729e11b6..2bc99ff8 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SteadyClockTimePoint.cs @@ -7,10 +7,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Pack = 1)] struct SteadyClockTimePoint { - public long TimePoint; + public long TimePoint; public UInt128 ClockSourceId; - public ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) + public readonly ResultCode GetSpanBetween(SteadyClockTimePoint other, out long outSpan) { outSpan = 0; @@ -35,9 +35,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { return new SteadyClockTimePoint { - TimePoint = 0, - ClockSourceId = UInt128Utils.CreateRandom() + TimePoint = 0, + ClockSourceId = UInt128Utils.CreateRandom(), }; } } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs index 6b589c28..fc47e775 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/SystemClockContext.cs @@ -5,7 +5,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock [StructLayout(LayoutKind.Sequential, Pack = 1)] struct SystemClockContext { - public long Offset; + public long Offset; public SteadyClockTimePoint SteadyTimePoint; } -}
\ No newline at end of file +} diff --git a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs index 0070193f..a7ef8115 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/Clock/Types/TimeSpanType.cs @@ -8,7 +8,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock { private const long NanoSecondsPerSecond = 1000000000; - public static readonly TimeSpanType Zero = new TimeSpanType(0); + public static readonly TimeSpanType Zero = new(0); public long NanoSeconds; @@ -17,17 +17,17 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock NanoSeconds = nanoSeconds; } - public long ToSeconds() + public readonly long ToSeconds() { return NanoSeconds / NanoSecondsPerSecond; } - public TimeSpanType AddSeconds(long seconds) + public readonly TimeSpanType AddSeconds(long seconds) { return new TimeSpanType(NanoSeconds + (seconds * NanoSecondsPerSecond)); } - public bool IsDaylightSavingTime() + public readonly bool IsDaylightSavingTime() { return DateTime.UnixEpoch.AddSeconds(ToSeconds()).ToLocalTime().IsDaylightSavingTime(); } @@ -47,4 +47,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock return FromSeconds((long)ticks / (long)frequency); } } -}
\ No newline at end of file +} |
