ui, revise status line handling

This commit is contained in:
kub 2020-11-12 21:51:35 +01:00
parent ae61303f86
commit 69b7b2641b
5 changed files with 56 additions and 40 deletions

View file

@ -1366,7 +1366,6 @@ void emu_loop(void)
char *notice_msg = NULL; char *notice_msg = NULL;
char fpsbuff[24]; char fpsbuff[24];
int fskip_cnt = 0; int fskip_cnt = 0;
int statclr_cnt = 4;
fpsbuff[0] = 0; fpsbuff[0] = 0;
@ -1415,9 +1414,7 @@ void emu_loop(void)
{ {
notice_msg_time = 0; notice_msg_time = 0;
notice_msg = NULL; notice_msg = NULL;
/* clear all buffers if multi buffering */
plat_status_msg_clear(); plat_status_msg_clear();
statclr_cnt = 4;
} }
else { else {
int sum = noticeMsg[0] + noticeMsg[1] + noticeMsg[2]; int sum = noticeMsg[0] + noticeMsg[1] + noticeMsg[2];
@ -1527,12 +1524,6 @@ void emu_loop(void)
if (!skip && flip_after_sync) if (!skip && flip_after_sync)
plat_video_flip(); 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); pprof_end(main);
} }

View file

@ -176,6 +176,10 @@ void plat_video_set_buffer(void *);
void plat_update_volume(int has_changed, int is_up); void plat_update_volume(int has_changed, int is_up);
/* should be in libpicofe/plat.h */
void plat_video_clear_status(void);
void plat_video_clear_buffers(void);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif

View file

@ -159,6 +159,8 @@ void rgb565_to_uyvy(void *d, const void *s, int pixels)
} }
} }
static int clear_buf_cnt, clear_stat_cnt;
void plat_video_flip(void) void plat_video_flip(void)
{ {
if (plat_sdl_overlay != NULL) { if (plat_sdl_overlay != NULL) {
@ -183,6 +185,16 @@ void plat_video_flip(void)
SDL_Flip(plat_sdl_screen); SDL_Flip(plat_sdl_screen);
g_screen_ptr = plat_sdl_screen->pixels; g_screen_ptr = plat_sdl_screen->pixels;
plat_video_set_buffer(g_screen_ptr); plat_video_set_buffer(g_screen_ptr);
if (clear_buf_cnt) {
memset(g_screen_ptr, 0, plat_sdl_screen->w*plat_sdl_screen->h * 2);
clear_buf_cnt--;
}
}
if (clear_stat_cnt) {
unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_ppitch * g_screen_height;
int l = g_screen_ppitch * 8;
memset((int *)(d - l), 0, l * 2);
clear_stat_cnt--;
} }
} }
@ -190,6 +202,21 @@ void plat_video_wait_vsync(void)
{ {
} }
void plat_video_clear_status(void)
{
clear_stat_cnt = 3; // do it thrice in case of triple buffering
}
void plat_video_clear_buffers(void)
{
if (plat_sdl_overlay != NULL || plat_sdl_gl_active)
memset(shadow_fb, 0, plat_sdl_screen->w*plat_sdl_screen->h * 2);
else {
memset(g_screen_ptr, 0, plat_sdl_screen->w*plat_sdl_screen->h * 2);
clear_buf_cnt = 3; // do it thrice in case of triple buffering
}
}
void plat_video_menu_enter(int is_rom_loaded) void plat_video_menu_enter(int is_rom_loaded)
{ {
if (SDL_MUSTLOCK(plat_sdl_screen)) if (SDL_MUSTLOCK(plat_sdl_screen))

View file

@ -433,29 +433,31 @@ void plat_video_wait_vsync(void)
void plat_status_msg_clear(void) void plat_status_msg_clear(void)
{ {
int is_8bit = !is_16bit_mode(); int i, is_8bit = !is_16bit_mode();
for (i = 0; i < 4; i++) {
if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) { if (currentConfig.EmuOpt & EOPT_WIZ_TEAR_FIX) {
/* ugh.. */ /* ugh.. */
int u, *p; int u, *p;
if (is_8bit) { if (is_8bit) {
p = (int *)g_screen_ptr + (240-8) / 4; p = (int *)gp2x_screens[i] + (240-8) / 4;
for (u = 320; u > 0; u--, p += 240/4) for (u = 320; u > 0; u--, p += 240/4)
p[0] = p[1] = 0xe0e0e0e0; p[0] = p[1] = 0xe0e0e0e0;
} else { } else {
p = (int *)g_screen_ptr + (240-8)*2 / 4; p = (int *)gp2x_screens[i] + (240-8)*2 / 4;
for (u = 320; u > 0; u--, p += 240*2/4) for (u = 320; u > 0; u--, p += 240*2/4)
p[0] = p[1] = p[2] = p[3] = 0; p[0] = p[1] = p[2] = p[3] = 0;
} }
return;
} else { } else {
if (is_8bit) { if (is_8bit) {
char *d = (char *)g_screen_ptr + 320 * (240-8); char *d = (char *)gp2x_screens[i] + 320 * (240-8);
memset32((int *)d, 0xe0, 320 * 8 / 4); memset32((int *)d, 0xe0, 320 * 8 / 4);
} else { } else {
short *d = (short *)g_screen_ptr + 320 * (240-8); char *d = (char *)gp2x_screens[i] + 320*2 * (240-8);
memset32((int *)d, 0, 2*320 * 8 / 4); memset32((int *)d, 0, 2*320 * 8 / 4);
} }
} }
}
} }
void plat_status_msg_busy_next(const char *msg) void plat_status_msg_busy_next(const char *msg)

View file

@ -24,7 +24,6 @@ enum renderer_types { RT_16BIT, RT_8BIT_ACC, RT_8BIT_FAST, RT_COUNT };
static int out_x, out_y; static int out_x, out_y;
static int out_w, out_h; static int out_w, out_h;
static int clr_cnt;
void pemu_prep_defconfig(void) void pemu_prep_defconfig(void)
{ {
@ -84,10 +83,6 @@ void pemu_finalize_frame(const char *fps, const char *notice)
void plat_video_set_buffer(void *buf) void plat_video_set_buffer(void *buf)
{ {
if (clr_cnt > 0) {
memset32(g_screen_ptr, 0, g_screen_ppitch*g_screen_height*2 / 4);
clr_cnt --;
}
if (currentConfig.renderer == RT_16BIT || (PicoIn.AHW & PAHW_32X)) if (currentConfig.renderer == RT_16BIT || (PicoIn.AHW & PAHW_32X))
PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2);
} }
@ -118,7 +113,6 @@ static void apply_renderer(void)
PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
clr_cnt = 4;
} }
void plat_video_toggle_renderer(int change, int is_menu) void plat_video_toggle_renderer(int change, int is_menu)
@ -137,9 +131,7 @@ void plat_video_toggle_renderer(int change, int is_menu)
void plat_status_msg_clear(void) void plat_status_msg_clear(void)
{ {
unsigned short *d = (unsigned short *)g_screen_ptr + g_screen_ppitch * g_screen_height; plat_video_clear_status();
int l = g_screen_ppitch * 8;
memset32((int *)(d - l), 0, l * 2 / 4);
} }
void plat_status_msg_busy_next(const char *msg) void plat_status_msg_busy_next(const char *msg)
@ -153,7 +145,6 @@ void plat_status_msg_busy_next(const char *msg)
void plat_status_msg_busy_first(const char *msg) void plat_status_msg_busy_first(const char *msg)
{ {
clr_cnt = 4;
plat_status_msg_busy_next(msg); plat_status_msg_busy_next(msg);
} }
@ -187,7 +178,7 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols)
// clear whole screen in all buffers // clear whole screen in all buffers
if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X)) if (currentConfig.renderer != RT_16BIT && !(PicoIn.AHW & PAHW_32X))
memset32(Pico.est.Draw2FB, 0xe0e0e0e0, (320+8) * (8+240+8) / 4); memset32(Pico.est.Draw2FB, 0xe0e0e0e0, (320+8) * (8+240+8) / 4);
clr_cnt = 4; plat_video_clear_buffers();
out_y = start_line; out_x = (is_32cols ? 32 : 0); out_y = start_line; out_x = (is_32cols ? 32 : 0);
out_h = line_count; out_w = (is_32cols ? 256:320); out_h = line_count; out_w = (is_32cols ? 256:320);
@ -196,6 +187,7 @@ void emu_video_mode_change(int start_line, int line_count, int is_32cols)
void pemu_loop_prep(void) void pemu_loop_prep(void)
{ {
apply_renderer(); apply_renderer();
plat_video_clear_buffers();
} }
void pemu_loop_end(void) void pemu_loop_end(void)