GTE: Make widescreen hack use display aspect ratio

This commit is contained in:
Connor McLaughlin 2020-11-11 00:14:58 +10:00
parent 2d3fd621bf
commit ca14e53c4a
5 changed files with 103 additions and 14 deletions

View file

@ -13,6 +13,7 @@ A "BIOS" ROM image is required to to start the emulator and to play games. You c
## Latest News ## Latest News
- 2020/11/10: Widescreen hack now renders in the display aspect ratio instead of always 16:9.
- 2020/11/01: Exclusive fullscreen option added for Windows D3D11 users. Enjoy buttery smooth PAL games. - 2020/11/01: Exclusive fullscreen option added for Windows D3D11 users. Enjoy buttery smooth PAL games.
- 2020/10/31: Multisample antialiasing added as an enhancement. - 2020/10/31: Multisample antialiasing added as an enhancement.
- 2020/10/30: Option to use analog stick as d-pad for analog controller added. - 2020/10/30: Option to use analog stick as d-pad for analog controller added.

View file

@ -613,10 +613,52 @@ static void RTPS(const s16 V[3], u8 shift, bool lm, bool last)
// MAC0=(((H*20000h/SZ3)+1)/2)*IR2+OFY, SY2=MAC0/10000h ;ScrY FIFO -400h..+3FFh // MAC0=(((H*20000h/SZ3)+1)/2)*IR2+OFY, SY2=MAC0/10000h ;ScrY FIFO -400h..+3FFh
const s64 result = static_cast<s64>(ZeroExtend64(UNRDivide(REGS.H, REGS.SZ3))); const s64 result = static_cast<s64>(ZeroExtend64(UNRDivide(REGS.H, REGS.SZ3)));
// (4 / 3) / (16 / 9) -> 0.75 -> (3 / 4) s64 Sx;
const s64 Sx = g_settings.gpu_widescreen_hack ? if (g_settings.gpu_widescreen_hack)
((((s64(result) * s64(REGS.IR1)) * s64(3)) / s64(4)) + s64(REGS.OFX)) : {
(s64(result) * s64(REGS.IR1) + s64(REGS.OFX)); const DisplayAspectRatio ar = g_settings.display_aspect_ratio;
switch (ar)
{
case DisplayAspectRatio::R16_9:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(3)) / s64(4)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R16_10:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(5)) / s64(6)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R19_9:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(12)) / s64(19)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R21_9:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(4)) / s64(7)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R8_7:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(7)) / s64(6)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R2_1:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(2)) / s64(3)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R1_1:
Sx = ((((s64(result) * s64(REGS.IR1)) * s64(7)) / s64(6)) + s64(REGS.OFX));
break;
case DisplayAspectRatio::R4_3:
case DisplayAspectRatio::PAR1_1:
default:
Sx = (s64(result) * s64(REGS.IR1) + s64(REGS.OFX));
break;
}
}
else
{
Sx = (s64(result) * s64(REGS.IR1) + s64(REGS.OFX));
}
const s64 Sy = s64(result) * s64(REGS.IR2) + s64(REGS.OFY); const s64 Sy = s64(result) * s64(REGS.IR2) + s64(REGS.OFY);
CheckMACOverflow<0>(Sx); CheckMACOverflow<0>(Sx);
CheckMACOverflow<0>(Sy); CheckMACOverflow<0>(Sy);
@ -654,7 +696,53 @@ static void RTPS(const s16 V[3], u8 shift, bool lm, bool last)
const float precise_h_div_sz = float(REGS.H) / precise_z; const float precise_h_div_sz = float(REGS.H) / precise_z;
const float fofx = float(REGS.OFX) / float(1 << 16); const float fofx = float(REGS.OFX) / float(1 << 16);
const float fofy = float(REGS.OFY) / float(1 << 16); const float fofy = float(REGS.OFY) / float(1 << 16);
float precise_x = fofx + (precise_ir1 * precise_h_div_sz) * ((g_settings.gpu_widescreen_hack) ? 0.75f : 1.00f); float precise_x;
if (g_settings.gpu_widescreen_hack)
{
precise_x = precise_ir1 * precise_h_div_sz;
const DisplayAspectRatio ar = g_settings.display_aspect_ratio;
switch (ar)
{
case DisplayAspectRatio::R16_9:
precise_x = (precise_x * 3.0f) / 4.0f;
break;
case DisplayAspectRatio::R16_10:
precise_x = (precise_x * 5.0f) / 6.0f;
break;
case DisplayAspectRatio::R19_9:
precise_x = (precise_x * 12.0f) / 19.0f;
break;
case DisplayAspectRatio::R21_9:
precise_x = (precise_x * 4.0f) / 7.0f;
break;
case DisplayAspectRatio::R8_7:
precise_x = (precise_x * 7.0f) / 6.0f;
break;
case DisplayAspectRatio::R2_1:
precise_x = (precise_x * 2.0f) / 3.0f;
break;
case DisplayAspectRatio::R1_1:
precise_x = (precise_x * 7.0f) / 6.0f;
break;
case DisplayAspectRatio::R4_3:
case DisplayAspectRatio::PAR1_1:
default:
break;
}
precise_x += fofx;
}
else
{
precise_x = fofx + (precise_ir1 * precise_h_div_sz);
}
float precise_y = fofy + (precise_ir2 * precise_h_div_sz); float precise_y = fofy + (precise_ir2 * precise_h_div_sz);
precise_x = std::clamp<float>(precise_x, -1024.0f, 1023.0f); precise_x = std::clamp<float>(precise_x, -1024.0f, 1023.0f);

View file

@ -624,8 +624,8 @@ static std::array<retro_core_option_definition, 42> s_option_definitions = {{
"Nearest"}, "Nearest"},
{"duckstation_GPU.WidescreenHack", {"duckstation_GPU.WidescreenHack",
"Widescreen Hack", "Widescreen Hack",
"Increases the field of view from 4:3 to 16:9 in 3D games. For 2D games, or games which use pre-rendered " "Increases the field of view from 4:3 to the chosen display aspect ratio in 3D games. For 2D games, or games which "
"backgrounds, this enhancement will not work as expected.", "use pre-rendered backgrounds, this enhancement will not work as expected.",
{{"true", "Enabled"}, {"false", "Disabled"}}, {{"true", "Enabled"}, {"false", "Disabled"}},
"false"}, "false"},
{"duckstation_GPU.PGXPEnable", {"duckstation_GPU.PGXPEnable",

View file

@ -20,9 +20,9 @@ EnhancementSettingsWidget::EnhancementSettingsWidget(QtHostInterface* host_inter
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.force43For24Bit, "Display", "Force4_3For24Bit"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.force43For24Bit, "Display", "Force4_3For24Bit");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.chromaSmoothingFor24Bit, "GPU", SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.chromaSmoothingFor24Bit, "GPU",
"ChromaSmoothing24Bit"); "ChromaSmoothing24Bit");
SettingWidgetBinder::BindWidgetToEnumSetting( SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.textureFiltering, "GPU", "TextureFilter",
m_host_interface, m_ui.textureFiltering, "GPU", "TextureFilter", &Settings::ParseTextureFilterName, &Settings::ParseTextureFilterName, &Settings::GetTextureFilterName,
&Settings::GetTextureFilterName, Settings::DEFAULT_GPU_TEXTURE_FILTER); Settings::DEFAULT_GPU_TEXTURE_FILTER);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.widescreenHack, "GPU", "WidescreenHack"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.widescreenHack, "GPU", "WidescreenHack");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pgxpEnable, "GPU", "PGXPEnable", false); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.pgxpEnable, "GPU", "PGXPEnable", false);
@ -88,9 +88,9 @@ EnhancementSettingsWidget::EnhancementSettingsWidget(QtHostInterface* host_inter
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.widescreenHack, tr("Widescreen Hack"), tr("Unchecked"), m_ui.widescreenHack, tr("Widescreen Hack"), tr("Unchecked"),
tr("Scales vertex positions in screen-space to a widescreen aspect ratio, essentially " tr("Scales vertex positions in screen-space to a widescreen aspect ratio, essentially "
"increasing the field of view from 4:3 to 16:9 in 3D games. <br>For 2D games, or games which " "increasing the field of view from 4:3 to the chosen display aspect ratio in 3D games. <br>For 2D games, or "
"use pre-rendered backgrounds, this enhancement will not work as expected. <br><b><u>May not be compatible with " "games which use pre-rendered backgrounds, this enhancement will not work as expected. <br><b><u>May not be "
"all games.</u></b>")); "compatible with all games.</u></b>"));
dialog->registerWidgetHelp( dialog->registerWidgetHelp(
m_ui.pgxpEnable, tr("Geometry Correction"), tr("Unchecked"), m_ui.pgxpEnable, tr("Geometry Correction"), tr("Unchecked"),
tr("Reduces \"wobbly\" polygons and \"warping\" textures that are common in PS1 games. <br>Only " tr("Reduces \"wobbly\" polygons and \"warping\" textures that are common in PS1 games. <br>Only "

View file

@ -69,7 +69,7 @@
<item row="5" column="0" colspan="2"> <item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="widescreenHack"> <widget class="QCheckBox" name="widescreenHack">
<property name="text"> <property name="text">
<string>Widescreen Hack (render 3D in 16:9)</string> <string>Widescreen Hack (render 3D in display aspect ratio)</string>
</property> </property>
</widget> </widget>
</item> </item>