From c10655ea60ecd6964910bca90a24ce405df4a3b0 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 15 Sep 2024 18:07:14 +0300 Subject: [PATCH] Reduce amount of read_processor_time() calls. --- custom.cpp | 5 +++-- events.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/custom.cpp b/custom.cpp index 8623228b..a8a60c36 100644 --- a/custom.cpp +++ b/custom.cpp @@ -12196,8 +12196,9 @@ static bool framewait(void) } } } - idletime += read_processor_time() - start; - curr_time = read_processor_time(); + evt_t tnow = read_processor_time(); + idletime += tnow - start; + curr_time = tnow; vsyncmintime = curr_time; vsyncmaxtime = vsyncwaittime = curr_time + vstb; if (frame_rendered) { diff --git a/events.cpp b/events.cpp index 92bbc8f8..4a22f987 100644 --- a/events.cpp +++ b/events.cpp @@ -25,6 +25,7 @@ static const int pissoff_nojit_value = 256 * CYCLE_UNIT; evt_t event_cycles, nextevent, currcycle; int is_syncline; +static int syncline_cnt; frame_time_t is_syncline_end; int cycles_to_next_event; int max_cycles_to_next_event; @@ -266,6 +267,19 @@ void do_cycles_slow(int cycles_to_add) #endif #endif + if (syncline_cnt > 0) { + syncline_cnt--; + return; + } + if (is_syncline) { + // runs CPU emulation with chipset stopped + // when there is free time to do so + if (event_check_vsync()) { + syncline_cnt = 16; + return; + } + } + if (!currprefs.cpu_thread) { if ((pissoff -= cycles_to_add) >= 0) return; -- 2.47.3