summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2015-08-01 14:39:34 +1200
committerScott Mansell <phiren@gmail.com>2015-08-01 14:39:34 +1200
commita1df1f5ae4e9534222539dd85f7454d17c4ba559 (patch)
tree169cc240c73b0bdf9ac0232ba56601f035125143 /Source/Core
parent615e5db0cbda4afad3ee940f6c160c1ece963c36 (diff)
Widescreen Heuristic: Cleanup code.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoCommon/VertexShaderManager.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/Source/Core/VideoCommon/VertexShaderManager.cpp b/Source/Core/VideoCommon/VertexShaderManager.cpp
index 83e112021e..46884a79d2 100644
--- a/Source/Core/VideoCommon/VertexShaderManager.cpp
+++ b/Source/Core/VideoCommon/VertexShaderManager.cpp
@@ -89,6 +89,23 @@ static float PHackValue(std::string sValue)
return f;
}
+// Due to the BT.601 standard which the GameCube is based on being a compromise
+// between PAL and NTSC, neither standard gets square pixels. They are each off
+// by ~9% in opposite directions.
+// Just in case any game decides to take this into account, we do both these
+// tests with a large amount of slop.
+static bool AspectIs4_3(float width, float height)
+{
+ float aspect = fabsf(width / height);
+ return fabsf(aspect - 4.0f / 3.0f) < 4.0f / 3.0f * 0.11; // within 11% of 4:3
+}
+
+static bool AspectIs16_9(float width, float height)
+{
+ float aspect = fabsf(width / height);
+ return fabsf(aspect - 16.0f / 9.0f) < 16.0f / 9.0f * 0.11; // within 11% of 16:9
+}
+
void UpdateProjectionHack(int iPhackvalue[], std::string sPhackvalue[])
{
float fhackvalue1 = 0, fhackvalue2 = 0;
@@ -422,18 +439,11 @@ void VertexShaderManager::SetConstants()
// Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode.
if (!SConfig::GetInstance().bWii)
{
- // Due to the BT.601 standard which the GameCube is based on being a compromise
- // between PAL and NTSC, neither standard gets square pixels. They are each off
- // by ~9% in opposite directions.
- // Just in case any game decides to take this into account, we do these tests
- // with a large amount of slop.
- float aspect = fabsf(rawProjection[2] / rawProjection[0]);
- float viewport_aspect = fabsf(xfmem.viewport.wd / xfmem.viewport.ht);
- bool viewport_is_4_3 = fabsf(viewport_aspect - 4.0f/3.0f) < 4.0f/3.0f * 0.11;
- if (fabsf(aspect - 16.0f/9.0f) < 16.0f/9.0f * 0.11 && viewport_is_4_3) // within 11% of 16:9
- g_aspect_wide = true;
- else if (fabsf(aspect - 4.0f/3.0f) < 4.0f/3.0f * 0.11 && viewport_is_4_3) // within 11% of 4:3
- g_aspect_wide = false;
+ bool viewport_is_4_3 = AspectIs4_3(xfmem.viewport.wd, xfmem.viewport.ht);
+ if (AspectIs16_9(rawProjection[2], rawProjection[0]) && viewport_is_4_3)
+ g_aspect_wide = true; // Projection is 16:9 and viewport is 4:3, we are rendering an anamorphic widescreen picture
+ else if (AspectIs4_3(rawProjection[2], rawProjection[0]) && viewport_is_4_3)
+ g_aspect_wide = false; // Project and viewports are both 4:3, we are rendering a normal image.
}
SETSTAT_FT(stats.gproj_0, g_fProjectionMatrix[0]);