aboutsummaryrefslogtreecommitdiff
path: root/src/core/core_timing.cpp
diff options
context:
space:
mode:
authorGamer64 <gamer64@eden-emu.dev>2025-07-26 04:11:40 +0200
committercrueter <crueter@eden-emu.dev>2025-07-26 04:11:40 +0200
commitac675c52966f656dd308346b982393199d32ead3 (patch)
tree92fe0f4dcfe52b35bdec05d44a1d9edcc9d3ee69 /src/core/core_timing.cpp
parent8dd0e8434385e396779ea9ddc792c3b741f83d59 (diff)
[core]: Custom CPU Ticks rewrite (#118)
For now this is for testing purposes Co-authored-by: Gamer64 <76565986+Gamer64ytb@users.noreply.github.com> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/118 Co-authored-by: Gamer64 <gamer64@eden-emu.dev> Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
Diffstat (limited to 'src/core/core_timing.cpp')
-rw-r--r--src/core/core_timing.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index c4ea15c1dd..ed07e80ce2 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -174,15 +174,21 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type,
}
}
+static u64 GetNextTickCount(u64 next_ticks) {
+ if (Settings::values.use_custom_cpu_ticks.GetValue()) {
+ return Settings::values.cpu_ticks.GetValue();
+ }
+ return next_ticks;
+}
+
void CoreTiming::AddTicks(u64 ticks_to_add) {
- cpu_ticks = Settings::values.use_custom_cpu_ticks.GetValue()
- ? Settings::values.cpu_ticks.GetValue()
- : cpu_ticks + ticks_to_add;
- downcount -= static_cast<s64>(cpu_ticks);
+ const u64 ticks = GetNextTickCount(ticks_to_add);
+ cpu_ticks += ticks;
+ downcount -= static_cast<s64>(ticks);
}
void CoreTiming::Idle() {
- cpu_ticks += 1000U;
+ AddTicks(1000U);
}
void CoreTiming::ResetTicks() {