From: kub Date: Sun, 31 Jan 2021 19:14:49 +0000 (+0100) Subject: ui, fix for SDL emulation display if resolution != 320x240 X-Git-Tag: v2.00~604 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=832faed320feacc855c0ffa92b8184ad2727532c;p=picodrive.git ui, fix for SDL emulation display if resolution != 320x240 --- diff --git a/platform/common/emu.c b/platform/common/emu.c index af07bd52..089189d5 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1212,7 +1212,7 @@ static void mkdir_path(char *path_with_reserve, int pos, const char *name) lprintf("failed to create: %s\n", path_with_reserve); } -void emu_cmn_forced_frame(int no_scale, int do_emu) +void emu_cmn_forced_frame(int no_scale, int do_emu, void *buf) { int po_old = PicoIn.opt; int y; @@ -1227,7 +1227,7 @@ void emu_cmn_forced_frame(int no_scale, int do_emu) PicoIn.opt |= POPT_EN_SOFTSCALE; PicoDrawSetOutFormat(PDF_RGB555, 1); - PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); + PicoDrawSetOutBuf(buf, g_screen_ppitch * 2); Pico.m.dirtyPal = 1; Pico.est.rendstatus |= PDRAW_DIRTY_SPRITES; if (do_emu) diff --git a/platform/common/emu.h b/platform/common/emu.h index af857bc1..512ed716 100644 --- a/platform/common/emu.h +++ b/platform/common/emu.h @@ -146,7 +146,7 @@ void emu_sound_stop(void); void emu_sound_wait(void); /* used by some (but not all) platforms */ -void emu_cmn_forced_frame(int no_scale, int do_emu); +void emu_cmn_forced_frame(int no_scale, int do_emu, void *buf); /* stuff to be implemented by platform code */ extern const char *renderer_names[]; diff --git a/platform/common/plat_sdl.c b/platform/common/plat_sdl.c index 75dda2c5..9557997d 100644 --- a/platform/common/plat_sdl.c +++ b/platform/common/plat_sdl.c @@ -211,17 +211,23 @@ void plat_video_menu_leave(void) void plat_video_loop_prepare(void) { - plat_sdl_change_video_mode(g_screen_width, g_screen_height, 0); - if (plat_sdl_overlay != NULL || plat_sdl_gl_active) { g_screen_ptr = shadow_fb; + g_screen_width = 320; + g_screen_height = 240; + g_screen_ppitch = g_screen_width; } else { if (SDL_MUSTLOCK(plat_sdl_screen)) SDL_LockSurface(plat_sdl_screen); g_screen_ptr = plat_sdl_screen->pixels; + g_screen_width = g_menuscreen_w; + g_screen_height = g_menuscreen_h; + g_screen_ppitch = g_menuscreen_pp; } plat_video_set_buffer(g_screen_ptr); + + plat_sdl_change_video_mode(g_screen_width, g_screen_height, 0); } void plat_early_init(void) diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index d60177ed..88379985 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -732,7 +732,7 @@ void pemu_forced_frame(int no_scale, int do_emu) if (!no_scale) no_scale = currentConfig.scaling == EOPT_SCALE_NONE; - emu_cmn_forced_frame(no_scale, do_emu); + emu_cmn_forced_frame(no_scale, do_emu, g_screen_ptr); g_menubg_src_ptr = g_screen_ptr; doing_bg_frame = 0; diff --git a/platform/linux/emu.c b/platform/linux/emu.c index b8645b10..bc71f0e2 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -81,6 +81,13 @@ static void draw_cd_leds(void) #undef p } +static unsigned short *get_16bit_start(unsigned short *buf) +{ + // center the output on the screen + int offs = (g_screen_height-240)/2 * g_screen_ppitch + (g_screen_width-320)/2; + return buf + offs; +} + void pemu_finalize_frame(const char *fps, const char *notice) { if (!is_16bit_mode()) { @@ -91,11 +98,12 @@ void pemu_finalize_frame(const char *fps, const char *notice) unsigned short *pal = Pico.est.HighPal; int i, x; + pd = get_16bit_start(pd); PicoDrawUpdateHighPal(); for (i = 0; i < out_h; i++, ps += 8) { for (x = 0; x < out_w; x++) *pd++ = pal[*ps++]; - pd += 320 - out_w; + pd += g_screen_ppitch - out_w; ps += 320 - out_w; } } @@ -111,7 +119,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) void plat_video_set_buffer(void *buf) { if (is_16bit_mode()) - PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); + PicoDrawSetOutBuf(get_16bit_start(buf), g_screen_ppitch * 2); } static void apply_renderer(void) @@ -121,7 +129,7 @@ static void apply_renderer(void) PicoIn.opt &= ~POPT_ALT_RENDERER; PicoIn.opt &= ~POPT_DIS_32C_BORDER; PicoDrawSetOutFormat(PDF_RGB555, 0); - PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); + PicoDrawSetOutBuf(get_16bit_start(g_screen_ptr), g_screen_ppitch * 2); break; case RT_8BIT_ACC: PicoIn.opt &= ~POPT_ALT_RENDERER; @@ -137,7 +145,7 @@ static void apply_renderer(void) } if (PicoIn.AHW & PAHW_32X) - PicoDrawSetOutBuf(g_screen_ptr, g_screen_ppitch * 2); + PicoDrawSetOutBuf(get_16bit_start(g_screen_ptr), g_screen_ppitch * 2); Pico.m.dirtyPal = 1; } @@ -181,11 +189,13 @@ void plat_update_volume(int has_changed, int is_up) void pemu_forced_frame(int no_scale, int do_emu) { + unsigned short *pd = get_16bit_start(g_screen_ptr); + PicoIn.opt &= ~POPT_DIS_32C_BORDER; PicoDrawSetCallbacks(NULL, NULL); Pico.m.dirtyPal = 1; - emu_cmn_forced_frame(no_scale, do_emu); + emu_cmn_forced_frame(no_scale, do_emu, pd); g_menubg_src_ptr = g_screen_ptr; } diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index 5f10b17b..0bd151cc 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -233,11 +233,10 @@ void plat_update_volume(int has_changed, int is_up) void pemu_forced_frame(int no_scale, int do_emu) { doing_bg_frame = 1; - emu_cmn_forced_frame(no_scale, do_emu); + // making a copy because enabling the layer clears it's mem + emu_cmn_forced_frame(no_scale, do_emu, fb_copy); doing_bg_frame = 0; - // making a copy because enabling the layer clears it's mem - memcpy((void *)fb_copy, g_screen_ptr, sizeof(fb_copy)); g_menubg_src_ptr = fb_copy; } diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 99bca5a5..74008735 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -665,7 +665,7 @@ void pemu_forced_frame(int no_scale, int do_emu) if (!no_scale) no_scale = currentConfig.scaling == EOPT_SCALE_NONE; - emu_cmn_forced_frame(no_scale, do_emu); + emu_cmn_forced_frame(no_scale, do_emu, g_screen_ptr); } /* change the platform output rendering */