From af3eb9e851b7d93a476a24169bb7f98bc5969a8e Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 16:40:27 +0100 Subject: [PATCH 1/6] Linux / windows hz bug fix when merging Linux CRT refresh rate hz was dealt with in floats for Linux but ints for windows. --- gfx/video_crt_switch.c | 23 +++++++++++++++++++++-- gfx/video_display_server.c | 4 ++-- gfx/video_display_server.h | 4 ++-- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 90a6f6b481..d848ae5ae0 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -48,6 +48,24 @@ static void crt_check_first_run(void) first_run = false; } +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; + + video_monitor_set_refresh_rate(ra_set_core_hz); + + ra_tmp_core_hz = ra_core_hz; +} + + static void crt_aspect_ratio_switch(unsigned width, unsigned height) { /* send aspect float to videeo_driver */ @@ -60,7 +78,7 @@ static void switch_res_crt(unsigned width, unsigned height) if (height > 100) { video_display_server_switch_resolution(width, height, - 0, ra_core_hz); + ra_set_core_hz, ra_core_hz); video_driver_apply_state_changes(); } } @@ -68,7 +86,8 @@ static void switch_res_crt(unsigned width, unsigned height) /* Create correct aspect to fit video if resolution does not exist */ static void crt_screen_setup_aspect(unsigned width, unsigned height) { - + + switch_crt_hz(); /* get original resolution of core */ if (height == 4) { diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 72fe658796..9e24223e8f 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -84,9 +84,9 @@ bool video_display_server_set_window_decorations(bool on) bool video_display_server_switch_resolution(unsigned width, unsigned height, - int f_restore, float hz) + int win_hz, float hz) { if (current_display_server && current_display_server->switch_resolution) - return current_display_server->switch_resolution(current_display_server_data, width, height, f_restore, hz); + return current_display_server->switch_resolution(current_display_server_data, width, height, win_hz, hz); return false; } diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 719edc8d7b..5f86523d47 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 f_restore, float hz); + unsigned height, int win_hz, float hz); const char *ident; } video_display_server_t; @@ -47,7 +47,7 @@ bool video_display_server_set_window_decorations(bool on); bool video_display_server_switch_resolution( unsigned width, unsigned height, - int f_restore, float hz); + int win_hz, float hz); extern const video_display_server_t dispserv_win32; extern const video_display_server_t dispserv_x11; From f672c7dc5c9c03f7bfe94e73fbbfba6ea2470b03 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 16:49:22 +0100 Subject: [PATCH 2/6] Linux / Windows hz bug fix and Linux low res modeline generator fix when merging Linux CRT refresh rate hz was dealt with in floats for Linux but ints for windows. --- gfx/display_servers/dispserv_win32.c | 34 ++++++++-------------------- gfx/display_servers/dispserv_x11.c | 6 ++--- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 97ab3fed88..addb656580 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -102,11 +102,11 @@ static void* win32_display_server_init(void) static void win32_display_server_destroy(void *data) { - dispserv_win32_t *dispserv = (dispserv_win32_t*)data; - - if (win32_orig_width > 0 && win32_orig_height > 0) + if (win32_orig_width > 0 && win32_orig_height > 0 ) video_display_server_switch_resolution(win32_orig_width, win32_orig_height, - 0, 60); + 60, 60); + + dispserv_win32_t *dispserv = (dispserv_win32_t*)data; #ifdef HAS_TASKBAR_EXT if (g_taskbarList && win32_taskbar_is_created()) @@ -200,14 +200,14 @@ static bool win32_set_window_decorations(void *data, bool on) } static bool win32_display_server_set_resolution(void *data, - unsigned width, unsigned height, int f_restore, float hz) + unsigned width, unsigned height, int win_hz, float hz) { LONG res; DEVMODE curDevmode; DEVMODE devmode; int iModeNum; - int freq = 0; + int freq = win_hz; DWORD flags = 0; int depth = 0; dispserv_win32_t *serv = (dispserv_win32_t*)data; @@ -215,24 +215,10 @@ static bool win32_display_server_set_resolution(void *data, if (!serv) return false; - if (win32_orig_width == 0) - win32_orig_width = GetSystemMetrics(SM_CXSCREEN); - if (win32_orig_height == 0) - win32_orig_height = GetSystemMetrics(SM_CYSCREEN); - - /* set hz float to an int for windows switching */ - if (hz < 53) - hz = 50; - if (hz >= 53 && hz < 57) - hz = 55; - if (hz >= 57) - hz = 60; - - video_monitor_set_refresh_rate(hz); - - - if (f_restore == 0) - freq = hz; + if (orig_width == 0) + orig_width = GetSystemMetrics(SM_CXSCREEN); + if (orig_height == 0) + orig_height = GetSystemMetrics(SM_CYSCREEN); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index da32b4a4e6..6f3bf487d9 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -82,7 +82,7 @@ static bool x11_set_window_decorations(void *data, bool on) } static bool x11_set_resolution(void *data, - unsigned width, unsigned height, int f_restore, float hz) + unsigned width, unsigned height, int win_hz, float hz) { int i = 0; int hfp = 0; @@ -113,13 +113,13 @@ static bool x11_set_resolution(void *data, if (width > 599 && width < 1919) { hfp = width+16; - hbp = width*1.10-8; + hbp = width*1.18; } if (width > 1919 && width < 2559) { hfp = width+32; - hbp = width*1.10; + hbp = width*1.20; } if (width > 2559) From 11b7f7652607316fb6e266c1dc18d5f0ac644e75 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 17:14:19 +0100 Subject: [PATCH 3/6] bug fix with hz switching --- gfx/display_servers/dispserv_win32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index addb656580..6425d348cb 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -215,10 +215,10 @@ static bool win32_display_server_set_resolution(void *data, if (!serv) return false; - if (orig_width == 0) - orig_width = GetSystemMetrics(SM_CXSCREEN); - if (orig_height == 0) - orig_height = GetSystemMetrics(SM_CYSCREEN); + if (win32_orig_width == 0) + win32_orig_width = GetSystemMetrics(SM_CXSCREEN); + if (win32_orig_height == 0) + win32_orig_height = GetSystemMetrics(SM_CYSCREEN); EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &curDevmode); From db751b42412f5545e14dd1021508e2af65b5a1df Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 17:50:13 +0100 Subject: [PATCH 4/6] Variable rename --- gfx/video_display_server.c | 4 ++-- gfx/video_display_server.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 9e24223e8f..c0df92ddf3 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -84,9 +84,9 @@ bool video_display_server_set_window_decorations(bool on) bool video_display_server_switch_resolution(unsigned width, unsigned height, - int win_hz, float hz) + int int_hz, float hz) { if (current_display_server && current_display_server->switch_resolution) - return current_display_server->switch_resolution(current_display_server_data, width, height, win_hz, hz); + return current_display_server->switch_resolution(current_display_server_data, width, height, int_hz, hz); return false; } diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 5f86523d47..e672f0bc7d 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 win_hz, float hz); + unsigned height, int int_hz, float hz); const char *ident; } video_display_server_t; @@ -47,7 +47,7 @@ bool video_display_server_set_window_decorations(bool on); bool video_display_server_switch_resolution( unsigned width, unsigned height, - int win_hz, float hz); + int int_hz, float hz); extern const video_display_server_t dispserv_win32; extern const video_display_server_t dispserv_x11; From 9400754a2b21cf6c5c3e43b8652073a217bcc262 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 17:51:28 +0100 Subject: [PATCH 5/6] Variable rename --- gfx/display_servers/dispserv_win32.c | 2 +- gfx/display_servers/dispserv_x11.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 6425d348cb..b668910550 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -200,7 +200,7 @@ static bool win32_set_window_decorations(void *data, bool on) } static bool win32_display_server_set_resolution(void *data, - unsigned width, unsigned height, int win_hz, float hz) + unsigned width, unsigned height, int int_hz, float hz) { LONG res; DEVMODE curDevmode; diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 6f3bf487d9..4a3bd0c465 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -82,7 +82,7 @@ static bool x11_set_window_decorations(void *data, bool on) } static bool x11_set_resolution(void *data, - unsigned width, unsigned height, int win_hz, float hz) + unsigned width, unsigned height, int int_hz, float hz) { int i = 0; int hfp = 0; From 675da4692e3caacd90bb72f757964413d0d1d992 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Mon, 30 Apr 2018 17:54:00 +0100 Subject: [PATCH 6/6] Moved variable back to the top --- gfx/display_servers/dispserv_win32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index b668910550..422ec4e884 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -102,12 +102,12 @@ static void* win32_display_server_init(void) static void win32_display_server_destroy(void *data) { + dispserv_win32_t *dispserv = (dispserv_win32_t*)data; + if (win32_orig_width > 0 && win32_orig_height > 0 ) video_display_server_switch_resolution(win32_orig_width, win32_orig_height, 60, 60); - dispserv_win32_t *dispserv = (dispserv_win32_t*)data; - #ifdef HAS_TASKBAR_EXT if (g_taskbarList && win32_taskbar_is_created()) {