1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-12-22 17:02:00 +00:00

Change TickSource TickMultiplier from static to an instance variable

This commit is contained in:
unknown 2024-03-10 19:46:30 -03:00 committed by Nicolas Abram
parent 7815fd5746
commit 9731aedf4e
5 changed files with 14 additions and 4 deletions

View file

@ -13,6 +13,11 @@ namespace Ryujinx.Cpu
/// </summary> /// </summary>
TimeSpan ElapsedTime { get; } TimeSpan ElapsedTime { get; }
/// <summary>
/// Clock tick multiplier, in percent points (100 = 1.0).
/// </summary>
long TickMultiplier { get; set; }
/// <summary> /// <summary>
/// Time elapsed since the counter was created, in seconds. /// Time elapsed since the counter was created, in seconds.
/// </summary> /// </summary>

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Cpu
/// <inheritdoc/> /// <inheritdoc/>
public ulong Counter => (ulong)(ElapsedSeconds * Frequency); public ulong Counter => (ulong)(ElapsedSeconds * Frequency);
public static long s_tickMultiplier = 100; public long TickMultiplier { get; set; } = 100;
private static long AcumElapsedTicks = 0; private static long AcumElapsedTicks = 0;
private static long LastElapsedTicks = 0; private static long LastElapsedTicks = 0;
private long Elapsedticks private long Elapsedticks
@ -23,7 +23,7 @@ namespace Ryujinx.Cpu
get get
{ {
long elapsedTicks = _tickCounter.ElapsedTicks; long elapsedTicks = _tickCounter.ElapsedTicks;
AcumElapsedTicks += (elapsedTicks - LastElapsedTicks) * s_tickMultiplier / 100; AcumElapsedTicks += (elapsedTicks - LastElapsedTicks) * TickMultiplier / 100;
LastElapsedTicks = elapsedTicks; LastElapsedTicks = elapsedTicks;
return AcumElapsedTicks; return AcumElapsedTicks;
} }

View file

@ -89,7 +89,7 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
} }
else else
{ {
_ticksPerFrame = (Stopwatch.Frequency / TargetFps * 100) / TickSource.s_tickMultiplier; _ticksPerFrame = (Stopwatch.Frequency / TargetFps * 100) / (_device.System?.TickSource?.TickMultiplier ?? 100);
} }
} }

View file

@ -126,6 +126,11 @@ namespace Ryujinx.HLE
return AudioDeviceDriver.Volume; return AudioDeviceDriver.Volume;
} }
public void SetTickSourceMultiplier(long tickMultiplier)
{
System.TickSource.TickMultiplier = tickMultiplier;
}
public void EnableCheats() public void EnableCheats()
{ {
ModLoader.EnableCheats(Processes.ActiveApplication.ProgramId, TamperMachine); ModLoader.EnableCheats(Processes.ActiveApplication.ProgramId, TamperMachine);

View file

@ -1072,7 +1072,7 @@ namespace Ryujinx.Ava
{ {
Device.TurboMode = !Device.TurboMode; Device.TurboMode = !Device.TurboMode;
long turboMultiplier = Device.TurboMode ? Device.Configuration.TurboMultiplier : 100; long turboMultiplier = Device.TurboMode ? Device.Configuration.TurboMultiplier : 100;
TickSource.s_tickMultiplier = turboMultiplier; Device.SetTickSourceMultiplier(turboMultiplier);
} }
switch (currentHotkeyState) switch (currentHotkeyState)
{ {