]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Reduce amount of read_processor_time() calls.
authorToni Wilen <twilen@winuae.net>
Sun, 15 Sep 2024 15:07:14 +0000 (18:07 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 15 Sep 2024 15:07:14 +0000 (18:07 +0300)
custom.cpp
events.cpp

index 8623228b796c472f837c4cb2a38daaae15238932..a8a60c362f4f5cfa384c2341a5adf7b7764b84e4 100644 (file)
@@ -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) {
index 92bbc8f8d9abec1a108b7c006b77ba7f8ebc1c34..4a22f987f266c1fbc1c3e102fb76e25432e2e43d 100644 (file)
@@ -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;