From: Toni Wilen Date: Sun, 15 Sep 2024 15:07:14 +0000 (+0300) Subject: Reduce amount of read_processor_time() calls. X-Git-Tag: 5310~13 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=c10655ea60ecd6964910bca90a24ce405df4a3b0;p=francis%2Fwinuae.git Reduce amount of read_processor_time() calls. --- 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;