ui, fix sdl flickering and status lines artifact issues

This commit is contained in:
kub 2020-10-07 20:17:01 +02:00
parent 3618d636d2
commit 758abbebc2
7 changed files with 81 additions and 70 deletions

View file

@ -1117,6 +1117,7 @@ static void run_events_ui(unsigned int which)
while (in_menu_wait_any(NULL, 50) & (PBTN_MOK | PBTN_MBACK))
;
in_set_config_int(0, IN_CFG_BLOCKING, 0);
plat_status_msg_clear();
}
if (do_it) {
plat_status_msg_busy_first((which & PEV_STATE_LOAD) ? "LOADING STATE" : "SAVING STATE");
@ -1361,6 +1362,7 @@ void emu_loop(void)
char *notice_msg = NULL;
char fpsbuff[24];
int fskip_cnt = 0;
int statclr_cnt = 4;
fpsbuff[0] = 0;
@ -1408,12 +1410,10 @@ void emu_loop(void)
> ms_to_ticks(STATUS_MSG_TIMEOUT) * 3)
{
notice_msg_time = 0;
plat_status_msg_clear();
#ifndef __GP2X__
plat_video_flip();
plat_status_msg_clear(); /* Do it again in case of double buffering */
#endif
notice_msg = NULL;
/* clear all buffers if multi buffering */
plat_status_msg_clear();
statclr_cnt = 4;
}
else {
int sum = noticeMsg[0] + noticeMsg[1] + noticeMsg[2];
@ -1523,6 +1523,12 @@ void emu_loop(void)
if (!skip && flip_after_sync)
plat_video_flip();
if (!skip && statclr_cnt > 0) {
// clear stat msg area in case of multi buffering
plat_status_msg_clear();
statclr_cnt --;
}
pprof_end(main);
}

View file

@ -172,6 +172,7 @@ void plat_status_msg_clear(void);
void plat_video_toggle_renderer(int change, int menu_call);
void plat_video_loop_prepare(void);
void plat_video_set_buffer(void *);
void plat_update_volume(int has_changed, int is_up);

View file

@ -168,6 +168,7 @@ static void load_progress_cb(int percent)
len = g_menuscreen_w;
menu_draw_begin(0, 1);
memcpy(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2);
dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_pp * me_sfont_h * 2;
for (ln = me_sfont_h - 2; ln > 0; ln--, dst += g_menuscreen_pp)
memset(dst, 0xff, len * 2);
@ -182,6 +183,7 @@ static void cdload_progress_cb(const char *fname, int percent)
menu_draw_begin(0, 1);
dst = (unsigned short *)g_menuscreen_ptr + g_menuscreen_pp * me_sfont_h * 2;
memcpy(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2);
menuscreen_memset_lines(dst, 0xff, me_sfont_h - 2);
smalltext_out16(1, 3 * me_sfont_h, "Processing CD image / MP3s", 0xffff);
@ -201,18 +203,16 @@ static void cdload_progress_cb(const char *fname, int percent)
void menu_romload_prepare(const char *rom_name)
{
const char *p = rom_name + strlen(rom_name);
int i;
while (p > rom_name && *p != '/')
p--;
/* fill all buffers, callbacks won't update in full */
for (i = 0; i < 3; i++) {
menu_draw_begin(1, 1);
smalltext_out16(1, 1, "Loading", 0xffff);
smalltext_out16(1, me_sfont_h, p, 0xffff);
menu_draw_end();
}
menu_draw_begin(1, 1);
smalltext_out16(1, 1, "Loading", 0xffff);
smalltext_out16(1, me_sfont_h, p, 0xffff);
/* background screen for callbacks */
memcpy(g_menubg_ptr, g_menuscreen_ptr, g_menuscreen_w * g_menuscreen_h * 2);
menu_draw_end();
PicoCartLoadProgressCB = load_progress_cb;
PicoCDLoadProgressCB = cdload_progress_cb;
@ -225,6 +225,7 @@ void menu_romload_end(void)
PicoCDLoadProgressCB = NULL;
menu_draw_begin(0, 1);
memcpy(g_menuscreen_ptr, g_menubg_ptr, g_menuscreen_w * g_menuscreen_h * 2);
smalltext_out16(1, (cdload_called ? 6 : 3) * me_sfont_h,
"Starting emulation...", 0xffff);
menu_draw_end();

View file

@ -9,6 +9,7 @@
#include <stdio.h>
#include "../libpicofe/input.h"
#include "../libpicofe/plat.h"
#include "../libpicofe/plat_sdl.h"
#include "../libpicofe/in_sdl.h"
#include "../libpicofe/gl.h"
@ -174,13 +175,14 @@ void plat_video_flip(void)
gl_flip(shadow_fb, g_screen_ppitch, g_screen_height);
}
else {
if (SDL_MUSTLOCK(plat_sdl_screen))
if (SDL_MUSTLOCK(plat_sdl_screen)) {
SDL_UnlockSurface(plat_sdl_screen);
SDL_Flip(plat_sdl_screen);
if (g_screen_ptr != shadow_fb) {
g_screen_ptr = plat_sdl_screen->pixels;
plat_video_toggle_renderer(0, 0);
}
SDL_Flip(plat_sdl_screen);
SDL_LockSurface(plat_sdl_screen);
} else
SDL_Flip(plat_sdl_screen);
g_screen_ptr = plat_sdl_screen->pixels;
plat_video_set_buffer(g_screen_ptr);
}
}
@ -190,8 +192,11 @@ void plat_video_wait_vsync(void)
void plat_video_menu_enter(int is_rom_loaded)
{
if (SDL_MUSTLOCK(plat_sdl_screen))
SDL_UnlockSurface(plat_sdl_screen);
plat_sdl_change_video_mode(g_menuscreen_w, g_menuscreen_h, 0);
g_screen_ptr = shadow_fb;
plat_video_set_buffer(g_screen_ptr);
}
void plat_video_menu_begin(void)
@ -228,7 +233,6 @@ void plat_video_menu_end(void)
SDL_Flip(plat_sdl_screen);
}
g_menuscreen_ptr = NULL;
}
void plat_video_menu_leave(void)
@ -246,8 +250,8 @@ void plat_video_loop_prepare(void)
if (SDL_MUSTLOCK(plat_sdl_screen))
SDL_LockSurface(plat_sdl_screen);
g_screen_ptr = plat_sdl_screen->pixels;
plat_video_toggle_renderer(0, 0);
}
plat_video_set_buffer(g_screen_ptr);
}
void plat_early_init(void)
@ -268,6 +272,10 @@ void plat_init(void)
ret = plat_sdl_init();
if (ret != 0)
exit(1);
#if defined(__RG350__) || defined(__GCW0__)
// opendingux on JZ47x0 may falsely report a HW overlay, fix to window
plat_target.vout_method = 0;
#endif
plat_sdl_quit_cb = plat_sdl_quit;