diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 74f1ae6e..19978398 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -486,6 +486,27 @@ float GPU::GetDisplayAspectRatio() const return corrected_ar; } + else if (g_settings.display_aspect_ratio == DisplayAspectRatio::Native) + { + const CRTCState& cs = m_crtc_state; + float relative_width = static_cast(cs.horizontal_visible_end - cs.horizontal_visible_start); + float relative_height = static_cast(cs.vertical_visible_end - cs.vertical_visible_start); + + if (relative_width <= 0 || relative_height <= 0) + return 4.0f / 3.0f; + + if (m_GPUSTAT.pal_mode) + { + relative_width /= static_cast(PAL_HORIZONTAL_ACTIVE_END - PAL_HORIZONTAL_ACTIVE_START); + relative_height /= static_cast(PAL_VERTICAL_ACTIVE_END - PAL_VERTICAL_ACTIVE_START); + } + else + { + relative_width /= static_cast(NTSC_HORIZONTAL_ACTIVE_END - NTSC_HORIZONTAL_ACTIVE_START); + relative_height /= static_cast(NTSC_VERTICAL_ACTIVE_END - NTSC_VERTICAL_ACTIVE_START); + } + return (relative_width / relative_height) * (4.0f / 3.0f); + } else if (g_settings.display_aspect_ratio == DisplayAspectRatio::PAR1_1) { if (m_crtc_state.display_width == 0 || m_crtc_state.display_height == 0) diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 4b8d3ec1..ea49b051 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -550,9 +550,9 @@ const char* Settings::GetDisplayCropModeDisplayName(DisplayCropMode crop_mode) static std::array(DisplayAspectRatio::Count)> s_display_aspect_ratio_names = { {TRANSLATABLE("DisplayAspectRatio", "Auto (Game Native)"), TRANSLATABLE("DisplayAspectRatio", "Auto (Match Window)"), - TRANSLATABLE("DisplayAspectRatio", "Custom"), "4:3", "16:9", "19:9", "20:9", "PAR 1:1"}}; + TRANSLATABLE("DisplayAspectRatio", "Custom"), "4:3", "16:9", "19:9", "20:9", "PAR 1:1", "Native"}}; static constexpr std::array(DisplayAspectRatio::Count)> s_display_aspect_ratio_values = { - {-1.0f, -1.0f, -1.0f, 4.0f / 3.0f, 16.0f / 9.0f, 19.0f / 9.0f, 20.0f / 9.0f, -1.0f}}; + {-1.0f, -1.0f, -1.0f, 4.0f / 3.0f, 16.0f / 9.0f, 19.0f / 9.0f, 20.0f / 9.0f, -1.0f, -1.0f}}; std::optional Settings::ParseDisplayAspectRatio(const char* str) { diff --git a/src/core/types.h b/src/core/types.h index 67d0e28b..e7fc042b 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -104,6 +104,7 @@ enum class DisplayAspectRatio : u8 R19_9, R20_9, PAR1_1, + Native, Count }; diff --git a/src/libretro/libretro_core_options.h b/src/libretro/libretro_core_options.h index 6245e9d8..91d2a0dd 100644 --- a/src/libretro/libretro_core_options.h +++ b/src/libretro/libretro_core_options.h @@ -811,6 +811,7 @@ struct retro_core_option_v2_definition option_defs_us[] = { { "Custom", "Custom"}, { "Auto", "Corrected" }, { "PAR 1:1", "PAR 1:1 (Uncorrected)" }, + { "Native", "Game Native" }, { NULL, NULL }, }, "Auto"