From 904e9fbe1d34d2aed0aaa7907feaaea437c7971a Mon Sep 17 00:00:00 2001 From: Cpod12 Date: Sat, 12 Aug 2023 05:51:12 -0700 Subject: [PATCH] Added 21:9 as an option to RGUI (#15572) * added 21:9 as an option to RGUI * reverted files that weren't supposed to be changed * fixed issue with 21:9 not showing in the menu and corrected buffer width --- cores/dynamic_dummy.c | 4 ++++ gfx/drivers/gx_gfx.c | 11 ++++++++-- intl/msg_hash_us.h | 8 ++++++++ menu/drivers/rgui.c | 47 +++++++++++++++++++++++++++++++++++++++++-- menu/menu_defines.h | 2 ++ menu/menu_setting.c | 12 +++++++++++ msg_hash.h | 2 ++ 7 files changed, 82 insertions(+), 4 deletions(-) diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index e6ab996d27..e4a5134ae8 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -86,6 +86,10 @@ void libretro_dummy_retro_init(void) case RGUI_ASPECT_RATIO_16_10_CENTRE: frame_buf_width = 384; break; + case RGUI_ASPECT_RATIO_21_9: + case RGUI_ASPECT_RATIO_21_9_CENTRE: + frame_buf_width = 560; + break; default: /* 4:3 */ frame_buf_width = 320; diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 22fb57eee0..9e9c721902 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -526,6 +526,13 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, else new_fb_width = (unsigned)((16.0f / 10.0f) * (float)new_fb_height) & ~3; break; + case RGUI_ASPECT_RATIO_21_9: + case RGUI_ASPECT_RATIO_21_9_CENTRE: + if (new_fb_height == 240) + new_fb_width = 560; + else + new_fb_width = (unsigned)((21.0f / 9.0f) * (float)new_fb_height) & ~3; + break; default: /* 4:3 */ if (new_fb_height == 240) @@ -534,8 +541,8 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, new_fb_width = (unsigned)((4.0f / 3.0f) * (float)new_fb_height) & ~3; break; } - if (new_fb_width > 424) - new_fb_width = 424; + if (new_fb_width > 560) + new_fb_width = 560; new_fb_pitch = new_fb_width * 2; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index bef8dd23fb..da1c5453c3 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -10970,6 +10970,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10_CENTRE, "16:10 (Centered)" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9, + "21:9" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9_CENTRE, + "21:9 (Centered)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_3_2, "3:2" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index ac610898b0..10e26d9feb 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -83,7 +83,7 @@ #define RGUI_MIN_FB_HEIGHT 192 #define RGUI_MIN_FB_WIDTH 256 -#define RGUI_MAX_FB_WIDTH 426 +#define RGUI_MAX_FB_WIDTH 560 #if defined(DINGUX) #if defined(RS90) && !defined(MIYOO) @@ -3083,6 +3083,10 @@ static void rgui_load_custom_theme( case RGUI_ASPECT_RATIO_16_10_CENTRE: wallpaper_key = "rgui_wallpaper_16_10"; break; + case RGUI_ASPECT_RATIO_21_9: + case RGUI_ASPECT_RATIO_21_9_CENTRE: + wallpaper_key = "rgui_wallpaper_21_9"; + break; case RGUI_ASPECT_RATIO_3_2: case RGUI_ASPECT_RATIO_3_2_CENTRE: wallpaper_key = "rgui_wallpaper_3_2"; @@ -6131,6 +6135,28 @@ static bool rgui_set_aspect_ratio( ( 4.0f / 3.0f) * (float)rgui->frame_buf.height); } break; + case RGUI_ASPECT_RATIO_21_9: + if (rgui->frame_buf.height == 240) + rgui->frame_buf.width = max_frame_buf_width; + else + rgui->frame_buf.width = RGUI_ROUND_FB_WIDTH( + (21.0f / 9.0f) * (float)rgui->frame_buf.height); + base_term_width = rgui->frame_buf.width; + break; + case RGUI_ASPECT_RATIO_21_9_CENTRE: + if (rgui->frame_buf.height == 240) + { + rgui->frame_buf.width = max_frame_buf_width; + base_term_width = 320; + } + else + { + rgui->frame_buf.width = RGUI_ROUND_FB_WIDTH( + (21.0f / 9.0f) * (float)rgui->frame_buf.height); + base_term_width = RGUI_ROUND_FB_WIDTH( + ( 4.0f / 3.0f) * (float)rgui->frame_buf.height); + } + break; case RGUI_ASPECT_RATIO_3_2: if (rgui->frame_buf.height == 240) rgui->frame_buf.width = 360; @@ -6262,6 +6288,19 @@ static bool rgui_set_aspect_ratio( base_term_width = (base_term_width < RGUI_MIN_FB_WIDTH) ? RGUI_MIN_FB_WIDTH : base_term_width; break; + case RGUI_ASPECT_RATIO_21_9: + rgui->frame_buf.height = (unsigned)( + ( 9.0f / 21.0f) * (float)rgui->frame_buf.width); + base_term_width = rgui->frame_buf.width; + break; + case RGUI_ASPECT_RATIO_21_9_CENTRE: + rgui->frame_buf.height = (unsigned)( + ( 9.0f / 21.0f) * (float)rgui->frame_buf.width); + base_term_width = RGUI_ROUND_FB_WIDTH( + ( 4.0f / 3.0f) * (float)rgui->frame_buf.height); + base_term_width = (base_term_width < RGUI_MIN_FB_WIDTH) ? + RGUI_MIN_FB_WIDTH : base_term_width; + break; case RGUI_ASPECT_RATIO_3_2: rgui->frame_buf.height = (unsigned)( (3.0f / 2.0f) * (float)rgui->frame_buf.width); @@ -7685,12 +7724,16 @@ static void rgui_frame(void *data, video_frame_info_t *video_info) { case RGUI_ASPECT_RATIO_16_9: case RGUI_ASPECT_RATIO_16_9_CENTRE: - default_fb_width = RGUI_MAX_FB_WIDTH; + default_fb_width = 426; break; case RGUI_ASPECT_RATIO_16_10: case RGUI_ASPECT_RATIO_16_10_CENTRE: default_fb_width = 384; break; + case RGUI_ASPECT_RATIO_21_9: + case RGUI_ASPECT_RATIO_21_9_CENTRE: + default_fb_width = RGUI_MAX_FB_WIDTH; + break; case RGUI_ASPECT_RATIO_3_2: case RGUI_ASPECT_RATIO_3_2_CENTRE: default_fb_width = 360; diff --git a/menu/menu_defines.h b/menu/menu_defines.h index ba37b2f148..07c3cd1e1f 100644 --- a/menu/menu_defines.h +++ b/menu/menu_defines.h @@ -342,6 +342,8 @@ enum rgui_aspect_ratio RGUI_ASPECT_RATIO_16_9_CENTRE, RGUI_ASPECT_RATIO_16_10, RGUI_ASPECT_RATIO_16_10_CENTRE, + RGUI_ASPECT_RATIO_21_9, + RGUI_ASPECT_RATIO_21_9_CENTRE, RGUI_ASPECT_RATIO_3_2, RGUI_ASPECT_RATIO_3_2_CENTRE, RGUI_ASPECT_RATIO_5_3, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cfe3a26ae6..123b14e41a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3923,6 +3923,18 @@ static void setting_get_string_representation_uint_rgui_aspect_ratio( MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10_CENTRE), len); break; + case RGUI_ASPECT_RATIO_21_9: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9), + len); + break; + case RGUI_ASPECT_RATIO_21_9_CENTRE: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9_CENTRE), + len); + break; case RGUI_ASPECT_RATIO_3_2: strlcpy(s, msg_hash_to_str( diff --git a/msg_hash.h b/msg_hash.h index f84f4c41fb..eca16c043e 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -3517,6 +3517,8 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_9_CENTRE, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_16_10_CENTRE, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9, + MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_21_9_CENTRE, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_3_2, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_3_2_CENTRE, MENU_ENUM_LABEL_VALUE_RGUI_ASPECT_RATIO_5_3,