X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Fplugin_lib.c;h=4dbb9a7d7f6da6ccbb2842776516d4526683315e;hp=1a925ec498de119c5bc31b872687e258683f4939;hb=9e5ac38fda66536f2a9e6dd2a747ae37538c3638;hpb=f6edea0ca83c3c415fa338e3c2d9e1f3d99cc228;ds=sidebyside diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 1a925ec4..4dbb9a7d 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -132,6 +132,58 @@ void pl_print_hud(int xborder) print_cpu_usage(w, h, xborder); } +/* update scaler target size according to user settings */ +static void update_layer_size(int w, int h) +{ + float mult; + int imult; + + switch (g_scaler) { + case SCALE_1_1: + g_layer_w = w; g_layer_h = h; + break; + + case SCALE_4_3v2: + if (h > g_menuscreen_h || (240 < h && h <= 360)) + goto fractional_4_3; + + // 4:3 that prefers integer scaling + imult = g_menuscreen_h / h; + g_layer_w = w * imult; + g_layer_h = h * imult; + mult = (float)g_layer_w / (float)g_layer_h; + if (mult < 1.25f || mult > 1.666f) + g_layer_w = 4.0f/3.0f * (float)g_layer_h; + printf(" -> %dx%d %.1f\n", g_layer_w, g_layer_h, mult); + break; + + fractional_4_3: + case SCALE_4_3: + mult = 240.0f / (float)h * 4.0f / 3.0f; + if (h > 256) + mult *= 2.0f; + g_layer_w = mult * (float)g_menuscreen_h; + g_layer_h = g_menuscreen_h; + printf(" -> %dx%d %.1f\n", g_layer_w, g_layer_h, mult); + break; + + case SCALE_FULLSCREEN: + g_layer_w = g_menuscreen_w; + g_layer_h = g_menuscreen_h; + break; + + default: + break; + } + + g_layer_x = g_menuscreen_w / 2 - g_layer_w / 2; + g_layer_y = g_menuscreen_h / 2 - g_layer_h / 2; + if (g_layer_x < 0) g_layer_x = 0; + if (g_layer_y < 0) g_layer_y = 0; + if (g_layer_w > g_menuscreen_w) g_layer_w = g_menuscreen_w; + if (g_layer_h > g_menuscreen_h) g_layer_h = g_menuscreen_h; +} + static void *pl_vout_set_mode(int w, int h, int bpp) { // special h handling, Wipeout likes to change it by 1-6 @@ -147,6 +199,8 @@ static void *pl_vout_set_mode(int w, int h, int bpp) pl_vout_h = psx_h = h; pl_vout_bpp = psx_bpp = bpp; + update_layer_size(pl_vout_w, pl_vout_h); + pl_vout_buf = plat_gvideo_set_mode(&pl_vout_w, &pl_vout_h, &pl_vout_bpp); if (pl_vout_buf == NULL && pl_rearmed_cbs.pl_vout_raw_flip == NULL) fprintf(stderr, "failed to set mode %dx%d@%d\n",