From: notaz Date: Wed, 15 Aug 2012 18:51:05 +0000 (+0300) Subject: frontend: move layer size code X-Git-Tag: r16~22 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e5ac38fda66536f2a9e6dd2a747ae37538c3638;p=pcsx_rearmed.git frontend: move layer size code also fix broken layer height limiting --- diff --git a/frontend/menu.c b/frontend/menu.c index 7babfabf..7d360d58 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -78,22 +78,14 @@ typedef enum MA_OPT_SCALER_C, } menu_id; -enum { - SCALE_1_1, - SCALE_4_3, - SCALE_4_3v2, - SCALE_FULLSCREEN, - SCALE_CUSTOM, -}; - static int last_vout_w, last_vout_h, last_vout_bpp; -static int scaling, cpu_clock, cpu_clock_st, volume_boost, frameskip; +static int cpu_clock, cpu_clock_st, volume_boost, frameskip; static char rom_fname_reload[MAXPATHLEN]; static char last_selected_fname[MAXPATHLEN]; static int warned_about_bios, region, in_type_sel1, in_type_sel2; static int psx_clock; static int memcard1_sel, memcard2_sel; -int g_opts; +int g_opts, g_scaler; int soft_scaling, analog_deadzone; // for Caanoo int filter; @@ -216,7 +208,7 @@ static void menu_set_defconfig(void) emu_set_default_config(); g_opts = 0; - scaling = SCALE_4_3; + g_scaler = SCALE_4_3; volume_boost = 0; frameskip = 0; analog_deadzone = 50; @@ -276,7 +268,7 @@ static const struct { CE_CONFIG_VAL(Cpu), CE_CONFIG_VAL(CdrReschedule), CE_INTVAL(region), - CE_INTVAL_V(scaling, 2), + CE_INTVAL_V(g_scaler, 2), CE_INTVAL(g_layer_x), CE_INTVAL(g_layer_y), CE_INTVAL(g_layer_w), @@ -1045,7 +1037,7 @@ static int menu_loop_cscaler(int id, int keys) { unsigned int inp; - scaling = SCALE_CUSTOM; + g_scaler = SCALE_CUSTOM; plat_gvideo_open(Config.PsxType); @@ -1095,7 +1087,7 @@ static int menu_loop_cscaler(int id, int keys) static menu_entry e_menu_gfx_options[] = { - mee_enum ("Scaler", MA_OPT_SCALER, scaling, men_scaler), + mee_enum ("Scaler", MA_OPT_SCALER, g_scaler, men_scaler), mee_onoff ("Software Scaling", MA_OPT_SCALER2, soft_scaling, 1), mee_enum ("Filter", MA_OPT_FILTERING, filter, men_dummy), // mee_onoff ("Vsync", 0, vsync, 1), @@ -2266,58 +2258,9 @@ void menu_init(void) void menu_notify_mode_change(int w, int h, int bpp) { - float mult; - int imult; - last_vout_w = w; last_vout_h = h; last_vout_bpp = bpp; - - // XXX: should really menu code cotrol the layer size? - switch (scaling) { - 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_w = g_menuscreen_h; } static void menu_leave_emu(void) @@ -2361,8 +2304,6 @@ void menu_prepare_emu(void) plat_video_menu_leave(); - menu_notify_mode_change(last_vout_w, last_vout_h, last_vout_bpp); - psxCpu = (Config.Cpu == CPU_INTERPRETER) ? &psxInt : &psxRec; if (psxCpu != prev_cpu) // note that this does not really reset, just clears drc caches diff --git a/frontend/menu.h b/frontend/menu.h index 17163ec1..2062acdf 100644 --- a/frontend/menu.h +++ b/frontend/menu.h @@ -6,7 +6,7 @@ void menu_finish(void); void menu_notify_mode_change(int w, int h, int bpp); void menu_set_filter_list(void *filters); -enum opts { +enum g_opts_opts { OPT_SHOWFPS = 1 << 0, OPT_SHOWCPU = 1 << 1, OPT_NO_FRAMELIM = 1 << 2, @@ -14,6 +14,17 @@ enum opts { OPT_TSGUN_NOTRIGGER = 1 << 4, }; -extern int g_opts; +enum g_scaler_opts { + SCALE_1_1, + SCALE_4_3, + SCALE_4_3v2, + SCALE_FULLSCREEN, + SCALE_CUSTOM, +}; + +extern int g_opts, g_scaler; extern int soft_scaling, analog_deadzone; extern int filter; + +extern int g_menuscreen_w; +extern int g_menuscreen_h; 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",