diff --git a/ChocolArm64/Instruction/AInstEmitSystem.cs b/ChocolArm64/Instruction/AInstEmitSystem.cs index 42a62009b5..1c5d02634f 100644 --- a/ChocolArm64/Instruction/AInstEmitSystem.cs +++ b/ChocolArm64/Instruction/AInstEmitSystem.cs @@ -30,6 +30,7 @@ namespace ChocolArm64.Instruction case 0b11_011_0100_0100_001: PropName = nameof(AThreadState.Fpsr); break; case 0b11_011_1101_0000_010: PropName = nameof(AThreadState.TpidrEl0); break; case 0b11_011_1101_0000_011: PropName = nameof(AThreadState.Tpidr); break; + case 0b11_011_1110_0000_000: PropName = nameof(AThreadState.CntfrqEl0); break; case 0b11_011_1110_0000_001: PropName = nameof(AThreadState.CntpctEl0); break; default: throw new NotImplementedException($"Unknown MRS at {Op.Position:x16}"); diff --git a/ChocolArm64/State/AThreadState.cs b/ChocolArm64/State/AThreadState.cs index ec8621b89b..6f3f62f69f 100644 --- a/ChocolArm64/State/AThreadState.cs +++ b/ChocolArm64/State/AThreadState.cs @@ -1,5 +1,6 @@ using ChocolArm64.Events; using System; +using System.Diagnostics; namespace ChocolArm64.State { @@ -40,15 +41,34 @@ namespace ChocolArm64.State public uint CtrEl0 => 0x8444c004; public uint DczidEl0 => 0x00000004; - private const ulong TicksPerS = 19_200_000; - private const ulong TicksPerMS = TicksPerS / 1_000; + public ulong CntfrqEl0 { get; set; } + public ulong CntpctEl0 + { + get + { + double Ticks = TickCounter.ElapsedTicks * HostTickFreq; - public ulong CntpctEl0 => (ulong)Environment.TickCount * TicksPerMS; + return (ulong)(Ticks * CntfrqEl0); + } + } public event EventHandler Break; public event EventHandler SvcCall; public event EventHandler Undefined; + private static Stopwatch TickCounter; + + private static double HostTickFreq; + + static AThreadState() + { + HostTickFreq = 1.0 / Stopwatch.Frequency; + + TickCounter = new Stopwatch(); + + TickCounter.Start(); + } + internal void OnBreak(int Imm) { Break?.Invoke(this, new AInstExceptionEventArgs(Imm)); diff --git a/Ryujinx.Core/OsHle/Process.cs b/Ryujinx.Core/OsHle/Process.cs index a8719e1c29..239b198039 100644 --- a/Ryujinx.Core/OsHle/Process.cs +++ b/Ryujinx.Core/OsHle/Process.cs @@ -17,6 +17,8 @@ namespace Ryujinx.Core.OsHle private const int TlsSize = 0x200; private const int TotalTlsSlots = 32; + private const int TickFreq = 19_200_000; + private Switch Ns; public bool NeedsHbAbi { get; private set; } @@ -197,6 +199,7 @@ namespace Ryujinx.Core.OsHle Thread.ThreadState.Undefined += UndefinedHandler; Thread.ThreadState.ProcessId = ProcessId; Thread.ThreadState.ThreadId = ThreadId; + Thread.ThreadState.CntfrqEl0 = TickFreq; Thread.ThreadState.Tpidr = Tpidr; Thread.ThreadState.X0 = (ulong)ArgsPtr; Thread.ThreadState.X1 = (ulong)Handle; diff --git a/Ryujinx.Core/OsHle/Services/Pl/ServicePl.cs b/Ryujinx.Core/OsHle/Services/Pl/ServicePl.cs index bb795f3f49..9a61779934 100644 --- a/Ryujinx.Core/OsHle/Services/Pl/ServicePl.cs +++ b/Ryujinx.Core/OsHle/Services/Pl/ServicePl.cs @@ -13,6 +13,7 @@ namespace Ryujinx.Core.OsHle.IpcServices.Pl { m_Commands = new Dictionary() { + { 0, RequestLoad }, { 1, GetLoadState }, { 2, GetFontSize }, { 3, GetSharedMemoryAddressOffset }, @@ -20,6 +21,13 @@ namespace Ryujinx.Core.OsHle.IpcServices.Pl }; } + public long RequestLoad(ServiceCtx Context) + { + SharedFontType FontType = (SharedFontType)Context.RequestData.ReadInt32(); + + return 0; + } + public long GetLoadState(ServiceCtx Context) { Context.ResponseData.Write(1); //Loaded diff --git a/Ryujinx.Core/OsHle/Services/Pl/SharedFontType.cs b/Ryujinx.Core/OsHle/Services/Pl/SharedFontType.cs new file mode 100644 index 0000000000..29fe02b8a4 --- /dev/null +++ b/Ryujinx.Core/OsHle/Services/Pl/SharedFontType.cs @@ -0,0 +1,12 @@ +namespace Ryujinx.Core.OsHle.IpcServices.Pl +{ + enum SharedFontType + { + JapanUsEurope = 0, + SimplifiedChinese = 1, + SimplifiedChineseEx = 2, + TraditionalChinese = 3, + Korean = 4, + NintendoEx = 5 + } +} \ No newline at end of file