From c362a6d7f435b29d5fb979bb129da98ef20d6d5c Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 23 Sep 2018 20:39:40 +0100 Subject: [PATCH 1/2] Added functions for new CRT SwitchRes options --- gfx/video_crt_switch.c | 40 ++++++++++++++++++++++++++++++-------- gfx/video_crt_switch.h | 2 +- gfx/video_display_server.c | 4 ++-- gfx/video_display_server.h | 4 ++-- gfx/video_driver.c | 3 ++- gfx/video_driver.h | 1 + 6 files changed, 40 insertions(+), 14 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 0da427482e..a96218544b 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -31,6 +31,7 @@ static unsigned ra_tmp_height = 0; static unsigned ra_set_core_hz = 0; static unsigned orig_width = 0; static unsigned orig_height = 0; +static int crt_center_adjust = 0; static bool first_run = true; @@ -53,12 +54,25 @@ static void switch_crt_hz(void) if (ra_core_hz == ra_tmp_core_hz) return; /* set hz float to an int for windows switching */ - if (ra_core_hz < 53) - ra_set_core_hz = 50; - if (ra_core_hz >= 53 && ra_core_hz < 57) - ra_set_core_hz = 55; - if (ra_core_hz >= 57) - ra_set_core_hz = 60; + if (ra_core_hz < 100) + { + if (ra_core_hz < 53) + ra_set_core_hz = 50; + if (ra_core_hz >= 53 && ra_core_hz < 57) + ra_set_core_hz = 55; + if (ra_core_hz >= 57) + ra_set_core_hz = 60; + } + + if (ra_core_hz > 100) + { + if (ra_core_hz < 106) + ra_set_core_hz = 120; + if (ra_core_hz >= 106 && ra_core_hz < 114) + ra_set_core_hz = 110; + if (ra_core_hz >= 114) + ra_set_core_hz = 120; + } video_monitor_set_refresh_rate(ra_set_core_hz); @@ -78,7 +92,7 @@ static void switch_res_crt(unsigned width, unsigned height) if (height > 100) { video_display_server_switch_resolution(width, height, - ra_set_core_hz, ra_core_hz); + ra_set_core_hz, ra_core_hz, crt_center_adjust); video_driver_apply_state_changes(); } } @@ -149,13 +163,23 @@ static void crt_screen_setup_aspect(unsigned width, unsigned height) } -void crt_switch_res_core(unsigned width, unsigned height, float hz) +void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust) { /* ra_core_hz float passed from within * void video_driver_monitor_adjust_system_rates(void) */ ra_core_width = width; ra_core_height = height; ra_core_hz = hz; + crt_center_adjust = crt_switch_center_adjust; + + if (crt_mode == 2) + { + if (hz > 53) + ra_core_hz = hz*2; + + if (hz <= 53) + ra_core_hz = 120.0f; + } crt_check_first_run(); diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index e1ca885780..d23c4c3059 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); +void crt_switch_res_core(unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust); void crt_aspect_ratio_switch(unsigned width, unsigned height); diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 51c82d1ffb..653cd0d8ad 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -84,10 +84,10 @@ bool video_display_server_set_window_decorations(bool on) bool video_display_server_switch_resolution(unsigned width, unsigned height, - int int_hz, float hz) + int int_hz, float hz, int center) { if (current_display_server && current_display_server->switch_resolution) - return current_display_server->switch_resolution(current_display_server_data, width, height, int_hz, hz); + return current_display_server->switch_resolution(current_display_server_data, width, height, int_hz, hz, center); return false; } diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index bb048cadc9..6f06228915 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -31,7 +31,7 @@ typedef struct video_display_server bool (*set_window_progress)(void *data, int progress, bool finished); bool (*set_window_decorations)(void *data, bool on); bool (*switch_resolution)(void *data, unsigned width, - unsigned height, int int_hz, float hz); + unsigned height, int int_hz, float hz, int center); const char *(*get_output_options)(void *data); const char *ident; } video_display_server_t; @@ -48,7 +48,7 @@ bool video_display_server_set_window_decorations(bool on); bool video_display_server_switch_resolution( unsigned width, unsigned height, - int int_hz, float hz); + int int_hz, float hz, int center); const char *video_display_server_get_output_options(void); diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 2674952bb8..4192261490 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2643,7 +2643,7 @@ 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); + crt_switch_res_core(width, height, video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust); } else if (!video_info.crt_switch_resolution) video_driver_crt_switching_active = false; @@ -2743,6 +2743,7 @@ void video_driver_build_info(video_frame_info_t *video_info) video_info->refresh_rate = settings->floats.video_refresh_rate; 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->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; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 06d151328f..82d771d28c 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -429,6 +429,7 @@ typedef struct video_frame_info int custom_vp_x; int custom_vp_y; + int crt_switch_center_adjust; unsigned hard_sync_frames; unsigned aspect_ratio_idx; From e6b8dcf5b0102ce4706ed7ca1894b2cf35b8bd20 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Sun, 23 Sep 2018 20:42:31 +0100 Subject: [PATCH 2/2] Added functions for new CRT SwitchRes options --- gfx/display_servers/dispserv_win32.c | 5 +++-- gfx/display_servers/dispserv_x11.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 68702399ce..35d0ed367e 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -69,6 +69,7 @@ be received by your application before it calls any ITaskbarList3 method. static unsigned win32_orig_width = 0; static unsigned win32_orig_height = 0; static unsigned win32_orig_refresh = 0; +static int crt_center = 0; static void* win32_display_server_init(void) { @@ -107,7 +108,7 @@ static void win32_display_server_destroy(void *data) if (win32_orig_width > 0 && win32_orig_height > 0 ) video_display_server_switch_resolution(win32_orig_width, win32_orig_height, - win32_orig_refresh , (float)win32_orig_refresh ); + win32_orig_refresh , (float)win32_orig_refresh, crt_center ); #ifdef HAS_TASKBAR_EXT if (g_taskbarList && win32_taskbar_is_created()) @@ -201,7 +202,7 @@ static bool win32_display_server_set_window_decorations(void *data, bool on) } static bool win32_display_server_set_resolution(void *data, - unsigned width, unsigned height, int int_hz, float hz) + unsigned width, unsigned height, int int_hz, float hz, int center) { LONG res; DEVMODE curDevmode; diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index ddc4fae560..3a93980bea 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -108,7 +108,7 @@ static bool x11_display_server_set_window_decorations(void *data, bool on) } static bool x11_display_server_set_resolution(void *data, - unsigned width, unsigned height, int int_hz, float hz) + unsigned width, unsigned height, int int_hz, float hz, int center) { int i = 0; int hfp = 0;