diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 6e75e87714..715cb9752d 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -144,6 +144,7 @@ static bool x11_display_server_set_resolution(void *data, int vmax = 0; int pdefault = 8; int pwidth = 0; + int x_offset = center; float roundw = 0.0f; float roundh = 0.0f; float pixel_clock = 0; @@ -160,7 +161,7 @@ static bool x11_display_server_set_resolution(void *data, video_monitor_set_refresh_rate(hz); /* following code is the mode line generator */ - hsp = width * 1.140; + hsp = (width * 1.140) + x_offset; hfp = width * 1.055; pwidth = width; diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index c4135a6df1..35586ab9dd 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -177,7 +177,7 @@ static void crt_screen_setup_aspect(unsigned width, unsigned height) void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, - int crt_switch_center_adjust, int monitor_index) + int crt_switch_center_adjust, int monitor_index, bool dynamic) { /* ra_core_hz float passed from within * void video_driver_monitor_adjust_system_rates(void) */ @@ -185,6 +185,10 @@ void crt_switch_res_core(unsigned width, unsigned height, ra_core_width = width; ra_core_height = height; ra_core_hz = hz; + + if (dynamic == true) + ra_core_width = crt_compute_dynamic_width(width); + crt_center_adjust = crt_switch_center_adjust; crt_index = monitor_index; @@ -209,7 +213,7 @@ void crt_switch_res_core(unsigned width, unsigned height, ra_tmp_height = ra_core_height; ra_tmp_width = ra_core_width; - /* Check if aspect is correct, if notchange */ + /* Check if aspect is correct, if not change */ if (video_driver_get_aspect_ratio() != fly_aspect) { video_driver_set_aspect_ratio_value((float)fly_aspect); @@ -225,6 +229,24 @@ void crt_video_restore(void) first_run = true; } +int crt_compute_dynamic_width(int width) +{ + double p_clock = 18000000; + int min_height = 261; + #if defined(HAVE_VIDEOCORE) + double p_clock = 32000000; + #endif + + for (int i =1; i < 10; i++) + { + if (((width*0.5*i) * min_height * ra_core_hz) > p_clock) + width = width*i; + return width; + break; + } + return 0; +} + #if defined(HAVE_VIDEOCORE) static void crt_rpi_switch(int width, int height, float hz) { diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 8bf588bae7..7e3c9541e9 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -27,12 +27,14 @@ RETRO_BEGIN_DECLS -void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index); +void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, int monitor_index, bool dynamic); void crt_aspect_ratio_switch(unsigned width, unsigned height); void crt_video_restore(void); +int crt_compute_dynamic_width(int width); + RETRO_END_DECLS #endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4b441b4ba5..28ee36f792 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -142,6 +142,7 @@ static unsigned video_driver_state_scale = 0; static unsigned video_driver_state_out_bpp = 0; static bool video_driver_state_out_rgb32 = false; static bool video_driver_crt_switching_active = false; +static bool video_driver_crt_dynamic_super_width = false; static struct retro_system_av_info video_driver_av_info; @@ -2647,7 +2648,12 @@ void video_driver_frame(const void *data, unsigned width, width = 3840; if (video_info.crt_switch_resolution_super == 1920) width = 1920; - crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index); + if (video_info.crt_switch_resolution_super == 1) + video_driver_crt_dynamic_super_width = true; + else + video_driver_crt_dynamic_super_width = false; + + crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, video_info.monitor_index, video_driver_crt_dynamic_super_width); } else if (!video_info.crt_switch_resolution) video_driver_crt_switching_active = false; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 319e5084af..50782557a4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1198,6 +1198,11 @@ static void setting_get_string_representation_crt_switch_resolution_super( strlcpy(s, msg_hash_to_str(MSG_NATIVE), len); else snprintf(s, len, "%d", *setting->value.target.unsigned_integer); +/* TO DO make 1 read as DYNAMIC */ + if (*setting->value.target.unsigned_integer == 1) + strlcpy(s, msg_hash_to_str(MSG_DYNAMIC), len); + else + snprintf(s, len, "%d", *setting->value.target.unsigned_integer); } static int setting_action_left_analog_dpad_mode(rarch_setting_t *setting, bool wraparound) @@ -1300,8 +1305,10 @@ static int setting_uint_action_left_crt_switch_resolution_super( case 0: *setting->value.target.unsigned_integer = 3840; break; - case 1920: + case 1: /* for dynamic super resolution switching - best fit */ *setting->value.target.unsigned_integer = 0; + case 1920: + *setting->value.target.unsigned_integer = 1; break; case 2560: *setting->value.target.unsigned_integer = 1920; @@ -1565,8 +1572,10 @@ static int setting_uint_action_right_crt_switch_resolution_super( switch (*setting->value.target.unsigned_integer) { case 0: - *setting->value.target.unsigned_integer = 1920; + *setting->value.target.unsigned_integer = 1; break; + case 1: /* for dynamic super resolution switching - best fit */ + *setting->value.target.unsigned_integer = 1920; case 1920: *setting->value.target.unsigned_integer = 2560; break; diff --git a/msg_hash.h b/msg_hash.h index 441d3fe1bd..f86a7737b3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -208,6 +208,7 @@ enum msg_hash_enums MSG_NO_ARGUMENTS_SUPPLIED_AND_NO_MENU_BUILTIN, MSG_COMPILER, MSG_NATIVE, + MSG_DYNAMIC, MSG_UNKNOWN_COMPILER, MSG_FAILED, MSG_SUCCEEDED,