From 172f58c1655848df85d35676a4a5aeb094d05b2c Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 13 Sep 2016 11:46:05 +0200 Subject: [PATCH] Fix 5:4 aspect ratio gun and status bar --- src/g_shared/shared_sbar.cpp | 2 +- src/r_main.cpp | 4 ++-- src/r_utility.cpp | 2 +- src/v_draw.cpp | 4 ++-- src/v_video.cpp | 19 +++++++++++++------ src/v_video.h | 3 ++- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index 3c41d18ca6..22171a4bbe 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -300,7 +300,7 @@ void DBaseStatusBar::SetScaled (bool scale, bool force) ST_X = 0; ST_Y = VirticalResolution - RelTop; float aspect = ActiveRatio(SCREENWIDTH, SCREENHEIGHT); - if (aspect >= 1.3f) + if (!Is54Aspect(aspect)) { // Normal resolution ::ST_Y = Scale (ST_Y, SCREENHEIGHT, VirticalResolution); } diff --git a/src/r_main.cpp b/src/r_main.cpp index d84698b7cf..6094f70def 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -318,7 +318,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth = virtwidth2 = fullWidth; virtheight = virtheight2 = fullHeight; - if (trueratio < 1.3f) + if (Is54Aspect(trueratio)) { virtheight2 = virtheight2 * AspectMultiplier(trueratio) / 48; } @@ -327,7 +327,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth2 = virtwidth2 * AspectMultiplier(trueratio) / 48; } - if (WidescreenRatio < 1.3f) + if (Is54Aspect(WidescreenRatio)) { virtheight = virtheight * AspectMultiplier(WidescreenRatio) / 48; } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 8e4284b7e3..76cf05e9b5 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -229,7 +229,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) centery = viewheight/2; centerx = viewwidth/2; - if (WidescreenRatio < 1.3f) + if (Is54Aspect(WidescreenRatio)) { centerxwide = centerx; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index a33fd618bc..3075cd92d8 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -887,7 +887,7 @@ void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h, x = x * Width / vwidth; w = right * Width / vwidth - x; } - if (myratio < 1.3f) + if (Is54Aspect(myratio)) { // The target surface is 5:4 y = (y - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5; h = (bottom - vheight * 0.5) * Height * 600 / (vheight * AspectBaseHeight(myratio)) + Height * 0.5 - y; @@ -950,7 +950,7 @@ void DCanvas::FillBorder (FTexture *img) return; } int bordtop, bordbottom, bordleft, bordright, bord; - if (myratio < 1.3f) + if (Is54Aspect(myratio)) { // Screen is taller than it is wide bordleft = bordright = 0; bord = Height - Height * AspectMultiplier(myratio) / 48; diff --git a/src/v_video.cpp b/src/v_video.cpp index 20e1f526c5..710d8b1cf2 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1362,7 +1362,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real int cx1, cy1, cx2, cy2; ratio = ActiveRatio(realwidth, realheight); - if (ratio < 1.3f) + if (Is54Aspect(ratio)) { cwidth = realwidth; cheight = realheight * AspectMultiplier(ratio) / 48; @@ -1703,22 +1703,29 @@ int CheckRatio (int width, int height, int *trueratio) int AspectBaseWidth(float aspect) { - return (int)round(240.0f * aspect * 3.0f); + return !Is54Aspect(aspect) ? (int)round(240.0f * aspect * 3.0f) : 960; } int AspectBaseHeight(float aspect) { - return (int)round(200.0f * (320.0f / (240.0f * aspect)) * 3.0f); + return !Is54Aspect(aspect) ? (int)round(200.0f * (320.0f / (240.0f * aspect)) * 3.0f) : 640; } -int AspectPspriteOffset(float aspect) +double AspectPspriteOffset(float aspect) { - return aspect < 1.3f ? (int)(6.5*FRACUNIT) : 0; + return !Is54Aspect(aspect) ? 0.0 : 6.5; } int AspectMultiplier(float aspect) { - return (int)round(320.0f / (240.0f * aspect) * 48.0f); + return !Is54Aspect(aspect) ? (int)round(320.0f / (240.0f * aspect) * 48.0f) : 48 * 15 / 16; +} + +bool Is54Aspect(float aspect) +{ + // The 5:4 aspect ratio redefined all the values to mean something else.. + // Limit the range this is active to try prevent square cam textures inheriting this madness. + return aspect > 1.1f && aspect < 1.3f; } void IVideo::DumpAdapters () diff --git a/src/v_video.h b/src/v_video.h index 8d785e43ff..26d45d9a01 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -523,8 +523,9 @@ static inline double ActiveRatio (double width, double height) { return ActiveRa int AspectBaseWidth(float aspect); int AspectBaseHeight(float aspect); -int AspectPspriteOffset(float aspect); +double AspectPspriteOffset(float aspect); int AspectMultiplier(float aspect); +bool Is54Aspect(float aspect); EXTERN_CVAR(Int, uiscale);