]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Lagless vsync updates
authorToni Wilen <twilen@winuae.net>
Sat, 5 May 2018 15:50:53 +0000 (18:50 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 5 May 2018 15:50:53 +0000 (18:50 +0300)
custom.cpp
events.cpp

index d84aba1cbea8f34b05b1a0407a423ff4bef2b39c..528283e425f396c70bcbad7e562a2bad9cbeea3e 100644 (file)
@@ -8276,6 +8276,14 @@ static void linesync_first_last_line(int *first, int *last)
                *first += y;
 }
 
+static int vsyncnextscanline;
+static int vsyncnextscanline_add;
+static int nextwaitvpos;
+static int display_slice_cnt;
+static int display_slice_lines;
+static int display_slices;
+static bool display_rendered;
+
 static bool linesync_beam_single(void)
 {
        frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
@@ -8315,12 +8323,6 @@ static bool linesync_beam_single(void)
 static bool linesync_beam_multi_dual(void)
 {
        frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
-       static int vsyncnextscanline;
-       static int nextwaitvpos;
-       static int display_slice_cnt;
-       static int display_slice_lines;
-       static int display_slices;
-       static bool display_rendered;
        bool input_read_done = false;
        bool was_syncline = is_syncline != 0;
 
@@ -8422,13 +8424,6 @@ static bool linesync_beam_multi_dual(void)
 static bool linesync_beam_multi_single(void)
 {
        frame_time_t maxtime = read_processor_time() + 2 * vsynctimebase;
-       static int vsyncnextscanline;
-       static int vsyncnextscanline_add;
-       static int nextwaitvpos;
-       static int display_slice_cnt;
-       static int display_slice_lines;
-       static int display_slices;
-       static bool display_rendered;
        bool input_read_done = false;
        bool was_syncline = is_syncline != 0;
 
@@ -8647,6 +8642,10 @@ static bool linesync_beam_multi_single(void)
 // called when extra CPU wait is done
 void vsync_event_done(void)
 {
+       if (!isvsync_chipset()) {
+               is_syncline = 0;
+               return;
+       }
        if (currprefs.gfx_display_sections <= 1) {
                linesync_beam_single();
        } else {
index 3819b216f6de4629cb00bbf3f86e8db5f228b479..c496fcdea64f13d4e3c9106774ccedd765ddd8cb 100644 (file)
@@ -52,59 +52,126 @@ void events_schedule (void)
 extern void vsync_event_done(void);
 extern int vsync_activeheight;
 
-void do_cycles_slow (unsigned long cycles_to_add)
+static bool event_check_vsync(void)
 {
-#ifdef WITH_X86
-       if (x86_turbo_on) {
-               execute_other_cpu_single();
-       }
+       /* Keep only CPU emulation running while waiting for sync point. */
+       if (is_syncline == -1) {
+
+               if (!isvsync_chipset()) {
+                       is_syncline = 0;
+                       return false;
+               }
+               // wait for vblank
+               audio_finish_pull();
+               int done = vsync_isdone(NULL);
+               if (!done) {
+#ifdef WITH_PPC
+                       if (ppc_state) {
+                               if (is_syncline == 1) {
+                                       uae_ppc_execute_check();
+                               } else {
+                                       uae_ppc_execute_quick();
+                               }
+                       }
 #endif
+                       if (currprefs.cachesize)
+                               pissoff = pissoff_value;
+                       else
+                               pissoff = pissoff_nojit_value;
+                       return true;
+               }
+               vsync_clear();
+               vsync_event_done();
 
-       if ((pissoff -= cycles_to_add) >= 0)
-               return;
+       } else if (is_syncline == -2) {
 
-       cycles_to_add = -pissoff;
-       pissoff = 0;
+               if (!isvsync_chipset()) {
+                       is_syncline = 0;
+                       return false;
+               }
+               // wait for vblank or early vblank
+               audio_finish_pull();
+               int done = vsync_isdone(NULL);
+               int vp = target_get_display_scanline(-1);
+               if (vp < 0 || vp >= is_syncline_end)
+                       done = true;
+               if (!done) {
+#ifdef WITH_PPC
+                       if (ppc_state) {
+                               if (is_syncline == 1) {
+                                       uae_ppc_execute_check();
+                               } else {
+                                       uae_ppc_execute_quick();
+                               }
+                       }
+#endif
+                       if (currprefs.cachesize)
+                               pissoff = pissoff_value;
+                       else
+                               pissoff = pissoff_nojit_value;
+                       return true;
+               }
+               vsync_clear();
+               vsync_event_done();
 
-       while ((nextevent - currcycle) <= cycles_to_add) {
+       } else if (is_syncline > 0) {
+
+               if (!isvsync_chipset()) {
+                       is_syncline = 0;
+                       return false;
+               }
+               audio_finish_pull();
+               // wait for specific scanline
+               int vp = target_get_display_scanline(-1);
+               if (vp < 0 || is_syncline > vp) {
+#ifdef WITH_PPC
+                       if (ppc_state) {
+                               uae_ppc_execute_check();
+                       }
+#endif
+                       if (currprefs.cachesize)
+                               pissoff = pissoff_value;
+                       else
+                               pissoff = pissoff_nojit_value;
+                       return true;
+               }
+               vsync_event_done();
 
-               /* Keep only CPU emulation running while waiting for sync point. */
-               if (is_syncline == -1) {
+       } else if (is_syncline == -10) {
 
-                       // wait for vblank
-                       audio_finish_pull();
-                       int done = vsync_isdone(NULL);
-                       if (!done) {
+               // wait is_syncline_end
+               if (event_wait) {
+                       int rpt = read_processor_time();
+                       int v = rpt - is_syncline_end;
+                       if (v < 0) {
 #ifdef WITH_PPC
                                if (ppc_state) {
-                                       if (is_syncline == 1) {
-                                               uae_ppc_execute_check();
-                                       } else {
-                                               uae_ppc_execute_quick();
-                                       }
+                                       uae_ppc_execute_check();
                                }
 #endif
                                if (currprefs.cachesize)
                                        pissoff = pissoff_value;
                                else
                                        pissoff = pissoff_nojit_value;
-                               return;
+                               return true;
                        }
-                       vsync_clear();
-                       vsync_event_done();
-
-               } else if (is_syncline == -2) {
-
-                       // wait for vblank or early vblank
-                       audio_finish_pull();
-                       int done = vsync_isdone(NULL);
-                       int vp = target_get_display_scanline(-1);
-                       if (vp < 0 || vp >= is_syncline_end)
-                               done = true;
-                       if (!done) {
+               }
+               is_syncline = 0;
+
+       } else if (is_syncline < -10) {
+
+               // wait is_syncline_end/vsyncmintime
+               if (event_wait) {
+                       int rpt = read_processor_time();
+                       int v = rpt - vsyncmintime;
+                       int v2 = rpt - is_syncline_end;
+                       if (v > vsynctimebase || v < -vsynctimebase) {
+                               v = 0;
+                       }
+                       if (v < 0 && v2 < 0) {
 #ifdef WITH_PPC
                                if (ppc_state) {
-                                       if (is_syncline == 1) {
+                                       if (is_syncline == -11) {
                                                uae_ppc_execute_check();
                                        } else {
                                                uae_ppc_execute_quick();
@@ -115,80 +182,33 @@ void do_cycles_slow (unsigned long cycles_to_add)
                                        pissoff = pissoff_value;
                                else
                                        pissoff = pissoff_nojit_value;
-                               return;
+                               return true;
                        }
-                       vsync_clear();
-                       vsync_event_done();
-
-               } else if (is_syncline > 0) {
+               }
+               is_syncline = 0;
+       }
+       return false;
+}
 
-                       audio_finish_pull();
-                       // wait for specific scanline
-                       int vp = target_get_display_scanline(-1);
-                       if (vp < 0 || is_syncline > vp) {
-#ifdef WITH_PPC
-                               if (ppc_state) {
-                                       uae_ppc_execute_check();
-                               }
+void do_cycles_slow (unsigned long cycles_to_add)
+{
+#ifdef WITH_X86
+       if (x86_turbo_on) {
+               execute_other_cpu_single();
+       }
 #endif
-                               if (currprefs.cachesize)
-                                       pissoff = pissoff_value;
-                               else
-                                       pissoff = pissoff_nojit_value;
-                               return;
-                       }
-                       vsync_event_done();
 
-               } else if (is_syncline == -10) {
+       if ((pissoff -= cycles_to_add) >= 0)
+               return;
 
-                       // wait is_syncline_end
-                       if (event_wait) {
-                               int rpt = read_processor_time();
-                               int v = rpt - is_syncline_end;
-                               if (v < 0) {
-#ifdef WITH_PPC
-                                       if (ppc_state) {
-                                               uae_ppc_execute_check();
-                                       }
-#endif
-                                       if (currprefs.cachesize)
-                                               pissoff = pissoff_value;
-                                       else
-                                               pissoff = pissoff_nojit_value;
-                                       return;
-                               }
-                       }
-                       is_syncline = 0;
-               
-               } else if (is_syncline < -10) {
-
-                       // wait is_syncline_end/vsyncmintime
-                       if (event_wait) {
-                               int rpt = read_processor_time();
-                               int v = rpt - vsyncmintime;
-                               int v2 = rpt - is_syncline_end;
-                               if (v > vsynctimebase || v < -vsynctimebase) {
-                                       v = 0;
-                               }
-                               if (v < 0 && v2 < 0) {
-#ifdef WITH_PPC
-                                       if (ppc_state) {
-                                               if (is_syncline == -11) {
-                                                       uae_ppc_execute_check();
-                                               } else {
-                                                       uae_ppc_execute_quick();
-                                               }
-                                       }
-#endif
-                                       if (currprefs.cachesize)
-                                               pissoff = pissoff_value;
-                                       else
-                                               pissoff = pissoff_nojit_value;
-                                       return;
-                               }
-                       }
-                       is_syncline = 0;
+       cycles_to_add = -pissoff;
+       pissoff = 0;
 
+       while ((nextevent - currcycle) <= cycles_to_add) {
+
+               if (is_syncline) {
+                       if (event_check_vsync())
+                               return;
                }
 
                cycles_to_add -= nextevent - currcycle;