[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: #118
Co-authored-by: Gamer64 <gamer64@eden-emu.dev>
Co-committed-by: Gamer64 <gamer64@eden-emu.dev>
This commit is contained in:
Gamer64 2025-07-26 04:11:40 +02:00 committed by crueter
parent 8dd0e84343
commit ac675c5296
Signed by: crueter
GPG key ID: 425ACD2D4830EBC6

View file

@ -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() {