R/Ryujinx.HLE/HOS/Services/Time/Clock/SteadyClockCore.cs
Mary-nyan c6d05301aa
infra: Migrate to .NET 7 (#3795)
* Update readme to mention .NET 7

* infra: Migrate to .NET 7

.NET 7 is still in preview but this prepare for the release coming up
next month.

* Use Random.Shared in CreateRandom

* Move UInt128Utils.cs to Ryujinx.Common project

* Fix inverted parameters in System.UInt128 constructor

* Fix Visual Studio complains on  Ryujinx.Graphics.Vic

* time: Fix missing alignment enforcement in SystemClockContext

Fixes at least Smash

* time: Fix missing alignment enforcement in SteadyClockContext

Fix games (like recent version of Smash) using time shared memory

* Switch to .NET 7.0.100 release

* Enable Tiered PGO

* Ensure CreateId validity requirements are meet when doing random generation

Also enforce correct packing layout for other Mii structures.

This fix a Mario Kart 8 crashes related to the default Miis.
2022-11-09 20:22:43 +01:00

98 lines
2.4 KiB
C#

using Ryujinx.Common.Utilities;
using Ryujinx.Cpu;
using System;
namespace Ryujinx.HLE.HOS.Services.Time.Clock
{
abstract class SteadyClockCore
{
private UInt128 _clockSourceId;
private bool _isRtcResetDetected;
private bool _isInitialized;
public SteadyClockCore()
{
_clockSourceId = UInt128Utils.CreateRandom();
_isRtcResetDetected = false;
_isInitialized = false;
}
public UInt128 GetClockSourceId()
{
return _clockSourceId;
}
public void SetClockSourceId(UInt128 clockSourceId)
{
_clockSourceId = clockSourceId;
}
public void SetRtcReset()
{
_isRtcResetDetected = true;
}
public virtual TimeSpanType GetTestOffset()
{
return new TimeSpanType(0);
}
public virtual void SetTestOffset(TimeSpanType testOffset) {}
public ResultCode GetRtcValue(out ulong rtcValue)
{
rtcValue = 0;
return ResultCode.NotImplemented;
}
public bool IsRtcResetDetected()
{
return _isRtcResetDetected;
}
public ResultCode GetSetupResultValue()
{
return ResultCode.Success;
}
public virtual TimeSpanType GetInternalOffset()
{
return new TimeSpanType(0);
}
public virtual void SetInternalOffset(TimeSpanType internalOffset) {}
public virtual SteadyClockTimePoint GetTimePoint(ITickSource tickSource)
{
throw new NotImplementedException();
}
public virtual TimeSpanType GetCurrentRawTimePoint(ITickSource tickSource)
{
SteadyClockTimePoint timePoint = GetTimePoint(tickSource);
return TimeSpanType.FromSeconds(timePoint.TimePoint);
}
public SteadyClockTimePoint GetCurrentTimePoint(ITickSource tickSource)
{
SteadyClockTimePoint result = GetTimePoint(tickSource);
result.TimePoint += GetTestOffset().ToSeconds();
result.TimePoint += GetInternalOffset().ToSeconds();
return result;
}
public bool IsInitialized()
{
return _isInitialized;
}
public void MarkInitialized()
{
_isInitialized = true;
}
}
}