From 55e3bd3d2dd6a0313271dd9509c4428f3e7a712c Mon Sep 17 00:00:00 2001 From: alphanu1 Date: Tue, 28 Jul 2020 14:25:38 +0100 Subject: [PATCH 1/4] Added ability to adjust porch values Porches can now be manipulated from the CRTSwitchRes menu --- config.def.h | 2 ++ configuration.c | 1 + configuration.h | 1 + gfx/display_servers/dispserv_x11.c | 10 +++++----- gfx/video_crt_switch.c | 8 ++++++-- gfx/video_crt_switch.h | 3 +++ gfx/video_display_server.h | 2 +- intl/msg_hash_lbl.h | 4 ++++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_ok.c | 2 +- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 1 + menu/menu_setting.c | 17 +++++++++++++++++ msg_hash.h | 1 + retroarch.c | 2 ++ retroarch.h | 1 + 16 files changed, 58 insertions(+), 9 deletions(-) diff --git a/config.def.h b/config.def.h index 70564d37e7..f673d15f14 100644 --- a/config.def.h +++ b/config.def.h @@ -133,6 +133,8 @@ #define DEFAULT_CRT_SWITCH_CENTER_ADJUST 0 +#define DEFAULT_CRT_SWITCH_PORCH_ADJUST 0 + #define DEFAULT_HISTORY_LIST_ENABLE true #define DEFAULT_PLAYLIST_ENTRY_RENAME true diff --git a/configuration.c b/configuration.c index 042378cfbb..6532e271d2 100644 --- a/configuration.c +++ b/configuration.c @@ -2021,6 +2021,7 @@ static struct config_int_setting *populate_settings_int( SETTING_INT("audio_wasapi_sh_buffer_length", &settings->ints.audio_wasapi_sh_buffer_length, true, DEFAULT_WASAPI_SH_BUFFER_LENGTH, false); #endif SETTING_INT("crt_switch_center_adjust", &settings->ints.crt_switch_center_adjust, false, DEFAULT_CRT_SWITCH_CENTER_ADJUST, false); + SETTING_INT("crt_switch_porch_adjust", &settings->ints.crt_switch_porch_adjust, false, DEFAULT_CRT_SWITCH_PORCH_ADJUST, false); #ifdef HAVE_VULKAN SETTING_INT("vulkan_gpu_index", &settings->ints.vulkan_gpu_index, true, DEFAULT_VULKAN_GPU_INDEX, false); #endif diff --git a/configuration.h b/configuration.h index 5836115473..fd0255ad4c 100644 --- a/configuration.h +++ b/configuration.h @@ -471,6 +471,7 @@ typedef struct settings int state_slot; int audio_wasapi_sh_buffer_length; int crt_switch_center_adjust; + int crt_switch_porch_adjust; #ifdef HAVE_VULKAN int vulkan_gpu_index; #endif diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 15f94ef8e3..80ecb2beb5 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -165,7 +165,7 @@ static bool x11_display_server_set_window_decorations(void *data, bool on) #ifdef HAVE_XRANDR static bool x11_display_server_set_resolution(void *data, - unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset) + unsigned width, unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust) { int screen; Window window; @@ -201,11 +201,11 @@ static bool x11_display_server_set_resolution(void *data, /* following code is the mode line generator */ if (width < 700) { - hfp = (width * 1.033); - hbp = width * 1.225; + hfp = (width * 1.033)+(padjust*2); + hbp = (width * 1.225)+(padjust*2); }else { - hfp = (width * 1.033) + (width / 112); - hbp = (width * 1.225) + (width /58); + hfp = ((width * 1.033) + (width / 112))+(padjust*4); + hbp = ((width * 1.225) + (width /58))+(padjust*4); xoffset = xoffset*2; } diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 2e9ddaa960..15bbda1d8e 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -81,7 +81,8 @@ static void switch_res_crt( p_switch->ra_core_hz, p_switch->center_adjust, p_switch->index, - p_switch->center_adjust); + p_switch->center_adjust, + p_switch->porch_adjust); #if defined(HAVE_VIDEOCORE) crt_rpi_switch(width, height, @@ -196,6 +197,7 @@ void crt_switch_res_core( unsigned width, unsigned height, float hz, unsigned crt_mode, int crt_switch_center_adjust, + int crt_switch_porch_adjust, int monitor_index, bool dynamic) { /* ra_core_hz float passed from within @@ -206,6 +208,7 @@ void crt_switch_res_core( height = 240; } + p_switch->porch_adjust = crt_switch_porch_adjust; p_switch->ra_core_height = height; p_switch->ra_core_hz = hz; @@ -229,7 +232,8 @@ void crt_switch_res_core( if ( (p_switch->ra_tmp_height != p_switch->ra_core_height) || (p_switch->ra_core_width != p_switch->ra_tmp_width) || - (p_switch->center_adjust != p_switch->tmp_center_adjust) + (p_switch->center_adjust != p_switch->tmp_center_adjust|| + p_switch->porch_adjust != p_switch->tmp_porch_adjust ) ) crt_screen_setup_aspect( p_switch, diff --git a/gfx/video_crt_switch.h b/gfx/video_crt_switch.h index 91a8db389a..168b0c54fa 100644 --- a/gfx/video_crt_switch.h +++ b/gfx/video_crt_switch.h @@ -30,6 +30,8 @@ RETRO_BEGIN_DECLS typedef struct videocrt_switch { int center_adjust; + int porch_adjust; + int tmp_porch_adjust; int tmp_center_adjust; unsigned ra_core_width; unsigned ra_core_height; @@ -52,6 +54,7 @@ void crt_switch_res_core( float hz, unsigned crt_mode, int crt_switch_center_adjust, + int crt_switch_porch_adjust, int monitor_index, bool dynamic); diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 151e60fe49..27c4799f28 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -49,7 +49,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 (*set_resolution)(void *data, unsigned width, - unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset); + unsigned height, int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust ); void *(*get_resolution_list)(void *data, unsigned *size); const char *(*get_output_options)(void *data); diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 91107f61f9..5e6a37b1d8 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -2900,6 +2900,10 @@ MSG_HASH( MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING, "crt_switch_center_adjust" ) +MSG_HASH( + MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST, + "crt_switch_porch_adjust" + ) MSG_HASH( MENU_ENUM_LABEL_VIDEO_ASPECT_RATIO, "video_aspect_ratio" diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 2164a93f3a..02004e0346 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1375,6 +1375,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_CRT_SWITCH_X_AXIS_CENTERING, "Cycle through these options if the image is not centered properly on the display." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CRT_SWITCH_PORCH_ADJUST, + "Porch Adjust" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_CRT_SWITCH_PORCH_ADJUST, + "Cycle through these options to adjust the porch settings to change the image size." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE, "Use Custom Refresh Rate" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 09cbda4834..120ce81d38 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -5633,7 +5633,7 @@ int action_cb_push_dropdown_item_resolution(const char *path, refreshrate = (unsigned)strtoul(pch, NULL, 0); if (video_display_server_set_resolution(width, height, - refreshrate, (float)refreshrate, 0, 0, 0)) + refreshrate, (float)refreshrate, 0, 0, 0, 0)) { settings_t *settings = config_get_ptr(); diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index b527d241f1..78b184dbb9 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -124,6 +124,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_quick_menu_stop_recording, DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_super, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_SUPER) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_x_axis_centering, MENU_ENUM_SUBLABEL_CRT_SWITCH_X_AXIS_CENTERING) +DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_porch_adjust, MENU_ENUM_SUBLABEL_CRT_SWITCH_PORCH_ADJUST) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_crt_switchres_use_custom_refresh_rate, MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_driver_settings_list, MENU_ENUM_SUBLABEL_DRIVER_SETTINGS) DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_retro_achievements_settings_list, MENU_ENUM_SUBLABEL_RETRO_ACHIEVEMENTS_SETTINGS) @@ -1692,6 +1693,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_x_axis_centering); break; + case MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_porch_adjust); + break; case MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_crt_switchres_use_custom_refresh_rate); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6040266448..bf5330bb39 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -7362,6 +7362,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION, PARSE_ONLY_UINT}, {MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_SUPER, PARSE_ONLY_UINT}, {MENU_ENUM_LABEL_CRT_SWITCH_X_AXIS_CENTERING, PARSE_ONLY_INT }, + {MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST, PARSE_ONLY_INT }, {MENU_ENUM_LABEL_CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE, PARSE_ONLY_BOOL}, }; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0cfec76b40..9cc18b0c14 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -10840,6 +10840,23 @@ static bool setting_append_list( SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED); menu_settings_list_current_add_range(list, list_info, -3, 4, 1.0, true, true); + CONFIG_INT( + list, list_info, + &settings->ints.crt_switch_porch_adjust, + MENU_ENUM_LABEL_CRT_SWITCH_PORCH_ADJUST, + MENU_ENUM_LABEL_VALUE_CRT_SWITCH_PORCH_ADJUST, + DEFAULT_CRT_SWITCH_PORCH_ADJUST, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_SPINBOX; + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; + (*list)[list_info->index - 1].offset_by = 0; + SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED); + menu_settings_list_current_add_range(list, list_info, -20, 20, 1.0, true, true); + CONFIG_BOOL( list, list_info, &settings->bools.crt_switch_custom_refresh_enable, diff --git a/msg_hash.h b/msg_hash.h index 4ef2ee8de1..78769f58cb 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -940,6 +940,7 @@ enum msg_hash_enums MENU_LABEL(CRT_SWITCH_RESOLUTION_OUTPUT_DISPLAY_ID), MENU_LABEL(CRT_SWITCH_RESOLUTION_USE_CUSTOM_REFRESH_RATE), MENU_LABEL(CRT_SWITCH_X_AXIS_CENTERING), + MENU_LABEL(CRT_SWITCH_PORCH_ADJUST), MENU_LABEL(VIDEO_FONT_ENABLE), MENU_LABEL(VIDEO_FONT_PATH), MENU_LABEL(VIDEO_FONT_SIZE), diff --git a/retroarch.c b/retroarch.c index 906bac9ac1..fe8f1b848d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -32827,6 +32827,7 @@ static void video_driver_frame(const void *data, unsigned width, p_rarch->video_driver_core_hz, video_info.crt_switch_resolution, video_info.crt_switch_center_adjust, + video_info.crt_switch_porch_adjust, video_info.monitor_index, p_rarch->video_driver_crt_dynamic_super_width); } @@ -32938,6 +32939,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_porch_adjust = settings->ints.crt_switch_porch_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/retroarch.h b/retroarch.h index cde9837de9..c5e34f1540 100644 --- a/retroarch.h +++ b/retroarch.h @@ -1141,6 +1141,7 @@ typedef struct video_frame_info int custom_vp_x; int custom_vp_y; int crt_switch_center_adjust; + int crt_switch_porch_adjust; unsigned hard_sync_frames; unsigned aspect_ratio_idx; From 610f9d6c48c3abaae7a51a45c0016b7c1accca27 Mon Sep 17 00:00:00 2001 From: alphanu1 Date: Tue, 28 Jul 2020 18:15:01 +0100 Subject: [PATCH 2/4] Fix missing arg --- retroarch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroarch.c b/retroarch.c index fe8f1b848d..02f4e61474 100644 --- a/retroarch.c +++ b/retroarch.c @@ -30512,13 +30512,13 @@ bool video_display_server_set_window_decorations(bool on) } bool video_display_server_set_resolution(unsigned width, unsigned height, - int int_hz, float hz, int center, int monitor_index, int xoffset) + int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust) { struct rarch_state *p_rarch = &rarch_st; if (current_display_server && current_display_server->set_resolution) return current_display_server->set_resolution( p_rarch->current_display_server_data, width, height, int_hz, - hz, center, monitor_index, xoffset); + hz, center, monitor_index, xoffset, padjust); return false; } From 50f54fcb43879fed1646e3498102b1dd1cc12a96 Mon Sep 17 00:00:00 2001 From: alphanu1 Date: Tue, 28 Jul 2020 18:28:31 +0100 Subject: [PATCH 3/4] Update video_display_server.h fixed function --- gfx/video_display_server.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h index 27c4799f28..8e0fc1253f 100644 --- a/gfx/video_display_server.h +++ b/gfx/video_display_server.h @@ -73,7 +73,7 @@ bool video_display_server_set_window_decorations(bool on); bool video_display_server_set_resolution( unsigned width, unsigned height, - int int_hz, float hz, int center, int monitor_index, int xoffset); + int int_hz, float hz, int center, int monitor_index, int xoffset, int padjust); void *video_display_server_get_resolution_list(unsigned *size); From d3a2f2f9214f3d4c69ce9452a8e193f355e60855 Mon Sep 17 00:00:00 2001 From: alphanu1 Date: Tue, 28 Jul 2020 18:43:29 +0100 Subject: [PATCH 4/4] Update video_crt_switch.c Fixed infinate switching bug --- gfx/video_crt_switch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 15bbda1d8e..5c25f3de08 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -243,6 +243,7 @@ void crt_switch_res_core( p_switch->ra_tmp_height = p_switch->ra_core_height; p_switch->ra_tmp_width = p_switch->ra_core_width; p_switch->tmp_center_adjust = p_switch->center_adjust; + p_switch->tmp_porch_adjust = p_switch->porch_adjust; /* Check if aspect is correct, if not change */ if (video_driver_get_aspect_ratio() != p_switch->fly_aspect)