From 95b089432923ddc8ca7a02d70761652cc0aeda64 Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 13 Oct 2024 20:08:33 +0200 Subject: [PATCH] platform ps2+psp, fix display out of sync on hotkey save/load --- platform/common/emu.c | 1 + platform/common/emu.h | 1 + platform/gp2x/emu.c | 4 ++++ platform/linux/emu.c | 4 ++++ platform/pandora/plat.c | 4 ++++ platform/ps2/emu.c | 12 ++++++++++-- platform/ps2/plat.c | 4 ++-- platform/psp/emu.c | 6 ++++++ 8 files changed, 32 insertions(+), 4 deletions(-) diff --git a/platform/common/emu.c b/platform/common/emu.c index 8f7baed6..cd0c2e58 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1251,6 +1251,7 @@ static void run_events_ui(unsigned int which) emu_save_load_game((which & PEV_STATE_LOAD) ? 1 : 0, 0); PicoStateProgressCB = NULL; } + plat_status_msg_busy_done(); } if (which & PEV_SWITCH_RND) { diff --git a/platform/common/emu.h b/platform/common/emu.h index c477883e..5fb0bf25 100644 --- a/platform/common/emu.h +++ b/platform/common/emu.h @@ -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); diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 8a1fda83..bebde8b7 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -544,6 +544,10 @@ void plat_status_msg_busy_first(const char *msg) plat_status_msg_busy_next(msg); } +void plat_status_msg_busy_done(void) +{ +} + static void vid_reset_mode(void) { int gp2x_mode = 16; diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 9c9d16cb..fd9c3b72 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -311,6 +311,10 @@ void plat_status_msg_busy_first(const char *msg) plat_status_msg_busy_next(msg); } +void plat_status_msg_busy_done(void) +{ +} + void plat_update_volume(int has_changed, int is_up) { } diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index 1f056c87..60522ac9 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -244,6 +244,10 @@ void plat_status_msg_busy_first(const char *msg) plat_status_msg_busy_next(msg); } +void plat_status_msg_busy_done(void) +{ +} + void plat_update_volume(int has_changed, int is_up) { } diff --git a/platform/ps2/emu.c b/platform/ps2/emu.c index 5b0c051b..d59615b0 100644 --- a/platform/ps2/emu.c +++ b/platform/ps2/emu.c @@ -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) { diff --git a/platform/ps2/plat.c b/platform/ps2/plat.c index 7e134e09..46f03c35 100644 --- a/platform/ps2/plat.c +++ b/platform/ps2/plat.c @@ -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); diff --git a/platform/psp/emu.c b/platform/psp/emu.c index a69f3707..0b8c8fee 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -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) { -- 2.39.5