platform ps2+psp, fix display out of sync on hotkey save/load
authorkub <derkub@gmail.com>
Sun, 13 Oct 2024 18:08:33 +0000 (20:08 +0200)
committerkub <derkub@gmail.com>
Tue, 15 Oct 2024 22:28:02 +0000 (00:28 +0200)
platform/common/emu.c
platform/common/emu.h
platform/gp2x/emu.c
platform/linux/emu.c
platform/pandora/plat.c
platform/ps2/emu.c
platform/ps2/plat.c
platform/psp/emu.c

index 8f7baed..cd0c2e5 100644 (file)
@@ -1251,6 +1251,7 @@ static void run_events_ui(unsigned int which)
                        emu_save_load_game((which & PEV_STATE_LOAD) ? 1 : 0, 0);\r
                        PicoStateProgressCB = NULL;\r
                }\r
+               plat_status_msg_busy_done();\r
        }\r
        if (which & PEV_SWITCH_RND)\r
        {\r
index c477883..5fb0bf2 100644 (file)
@@ -191,6 +191,7 @@ void plat_finish(void);
 /* used before things blocking for a while (these funcs redraw on return) */
 void plat_status_msg_busy_first(const char *msg);
 void plat_status_msg_busy_next(const char *msg);
+void plat_status_msg_busy_done(void);
 void plat_status_msg_clear(void);
 
 void plat_video_toggle_renderer(int change, int menu_call);
index 8a1fda8..bebde8b 100644 (file)
@@ -544,6 +544,10 @@ void plat_status_msg_busy_first(const char *msg)
        plat_status_msg_busy_next(msg);\r
 }\r
 \r
+void plat_status_msg_busy_done(void)\r
+{\r
+}\r
+\r
 static void vid_reset_mode(void)\r
 {\r
        int gp2x_mode = 16;\r
index 9c9d16c..fd9c3b7 100644 (file)
@@ -311,6 +311,10 @@ void plat_status_msg_busy_first(const char *msg)
        plat_status_msg_busy_next(msg);\r
 }\r
 \r
+void plat_status_msg_busy_done(void)\r
+{\r
+}\r
+\r
 void plat_update_volume(int has_changed, int is_up)\r
 {\r
 }\r
index 1f056c8..60522ac 100644 (file)
@@ -244,6 +244,10 @@ void plat_status_msg_busy_first(const char *msg)
        plat_status_msg_busy_next(msg);\r
 }\r
 \r
+void plat_status_msg_busy_done(void)\r
+{\r
+}\r
+\r
 void plat_update_volume(int has_changed, int is_up)\r
 {\r
 }\r
index 5b0c051..d59615b 100644 (file)
@@ -941,21 +941,29 @@ void plat_finish(void) {
        video_deinit();
 }
 
-/* display emulator status messages before holding emulation */
+/* display emulator status messages while holding emulation */
 void plat_status_msg_busy_first(const char *msg)
 {
+       // stop sound to make sure silence is played
+       pemu_sound_stop();
        plat_status_msg_busy_next(msg);
 }
 
 void plat_status_msg_busy_next(const char *msg)
 {
-       plat_status_msg_clear();
        pemu_finalize_frame("", msg);
+       // flip twice since our gskit pipeline has one frame delay
+       plat_video_flip();
        plat_video_flip();
        emu_status_msg("");
        reset_timing = 1;
 }
 
+void plat_status_msg_busy_done(void)
+{
+       pemu_sound_start();
+}
+
 /* clear status message area */
 void plat_status_msg_clear(void)
 {
index 7e134e0..46f03c3 100644 (file)
@@ -156,9 +156,9 @@ void plat_wait_till_us(unsigned int us_to)
 {
        // TODO hsync depends on NTSC/PAL (15750/15625 Hz), it however doesn't
        // matter if it falls a bit short, the while loop will catch the rest
-       unsigned hsyncs = (us_to - plat_get_ticks_us()) * 15620 / 1000000;
+       int hsyncs = (us_to - plat_get_ticks_us()) * 15620 / 1000000;
 
-       if (hsyncs && SetAlarm(hsyncs, alarm_cb, (void *)GetThreadId()) >= 0)
+       if (hsyncs > 0 && SetAlarm(hsyncs, alarm_cb, (void *)GetThreadId()) >= 0)
                SleepThread();
        while ((int)(us_to - plat_get_ticks_us()) > 0)
                RotateThreadReadyQueue(0);
index a69f370..0b8c8fe 100644 (file)
@@ -759,11 +759,17 @@ void plat_status_msg_busy_next(const char *msg)
 {
        plat_status_msg_clear();
        pemu_finalize_frame("", msg);
+       // flip twice since our GU pipeline has one frame delay
+       plat_video_flip();
        plat_video_flip();
        emu_status_msg("");
        reset_timing = 1;
 }
 
+void plat_status_msg_busy_done(void)
+{
+}
+
 /* clear status message area */
 void plat_status_msg_clear(void)
 {