diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index c4135a6df1..6bdd1c6fed 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,23 @@ void crt_video_restore(void) first_run = true; } +static int crt_compute_dynamic_width(int width) +{ + double p_clock = 18000000; + int min_heught = 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; + break; + } + +} + #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..d73e79a2a7 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -27,7 +27,7 @@ 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); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 4b441b4ba5..dfe571e690 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,10 @@ 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 == 1920) + video_driver_crt_dynamic_super_width = true; + + 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; @@ -2734,6 +2738,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->crt_switch_resolution = settings->uints.crt_switch_resolution; video_info->crt_switch_resolution_super = settings->uints.crt_switch_resolution_super; video_info->crt_switch_center_adjust = settings->ints.crt_switch_center_adjust; + video_info->crt_switch_custom_refresh_enable =settings->bools.crt_switch_custom_refresh_enable; video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames;