diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index dabddbaa0..d0153a98f 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1058,7 +1058,7 @@ void DBaseStatusBar::RefreshBackground () const int x, x2, y, ratio; ratio = CheckRatio (SCREENWIDTH, SCREENHEIGHT); - x = (!(ratio & 3) || !Scaled) ? ST_X : SCREENWIDTH*(48-BaseRatioSizes[ratio][3])/(48*2); + x = (!IsRatioWidescreen(ratio) || !Scaled) ? ST_X : SCREENWIDTH*(48-BaseRatioSizes[ratio][3])/(48*2); y = x == ST_X && x > 0 ? ST_Y : ::ST_Y; if(!CompleteBorder) @@ -1078,7 +1078,7 @@ void DBaseStatusBar::RefreshBackground () const { if(!CompleteBorder) { - x2 = !(ratio & 3) || !Scaled ? ST_X+HorizontalResolution : + x2 = !IsRatioWidescreen(ratio) || !Scaled ? ST_X+HorizontalResolution : SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2); } else diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 75d663266..213ca044d 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -308,7 +308,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CCMD (vid_listmodes) { - static const char *ratios[5] = { "", " - 16:9", " - 16:10", "", " - 5:4" }; + static const char *ratios[6] = { "", " - 16:9", " - 16:10", "", " - 5:4", " - 21:9" }; int width, height, bits; bool letterbox; @@ -325,7 +325,7 @@ CCMD (vid_listmodes) int ratio = CheckRatio (width, height); Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, "%s%4d x%5d x%3d%s%s\n", - thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, + thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD, width, height, bits, ratios[ratio], thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB" diff --git a/src/r_main.cpp b/src/r_main.cpp index c445787a0..43c22b0f9 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -363,7 +363,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth = virtwidth2 = fullWidth; virtheight = virtheight2 = fullHeight; - if (trueratio & 4) + if (Is54Aspect(trueratio)) { virtheight2 = virtheight2 * BaseRatioSizes[trueratio][3] / 48; } @@ -372,7 +372,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, virtwidth2 = virtwidth2 * BaseRatioSizes[trueratio][3] / 48; } - if (WidescreenRatio & 4) + if (Is54Aspect(WidescreenRatio)) { virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48; } diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 089c65379..d301b45fc 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -434,7 +434,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) centery = viewheight/2; centerx = viewwidth/2; - if (WidescreenRatio & 4) + if (Is54Aspect(WidescreenRatio)) { centerxwide = centerx; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index de096e3a9..eeb1a7d9c 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -816,7 +816,7 @@ void DCanvas::FillBorder (FTexture *img) return; } int bordtop, bordbottom, bordleft, bordright, bord; - if (myratio & 4) + if (Is54Aspect(myratio)) { // Screen is taller than it is wide bordleft = bordright = 0; bord = Height - Height * BaseRatioSizes[myratio][3] / 48; diff --git a/src/v_video.cpp b/src/v_video.cpp index 73681fdc2..b69bba63f 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1397,7 +1397,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real int cx1, cy1, cx2, cy2; ratio = CheckRatio(realwidth, realheight); - if (ratio & 4) + if (Is54Aspect(ratio)) { cwidth = realwidth; cheight = realheight * BaseRatioSizes[ratio][3] / 48; @@ -1645,12 +1645,14 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // 2: 16:10 // 3: 17:10 // 4: 5:4 +// 5: 17:10 (redundant) +// 6: 21:9 int CheckRatio (int width, int height, int *trueratio) { int fakeratio = -1; int ratio; - if ((vid_aspect >= 1) && (vid_aspect <= 5)) + if ((vid_aspect >= 1) && (vid_aspect <= 6)) { // [SP] User wants to force aspect ratio; let them. fakeratio = int(vid_aspect); @@ -1661,7 +1663,7 @@ int CheckRatio (int width, int height, int *trueratio) else if (fakeratio == 5) { fakeratio = 3; - } + } } if (vid_nowidescreen) { @@ -1702,6 +1704,11 @@ int CheckRatio (int width, int height, int *trueratio) { ratio = 4; } + // test for 21:9 (actually 64:27, 21:9 is a semi-accurate ratio used in marketing) + else if (abs (height * 64/27 - width) < 30) + { + ratio = 6; + } // Assume anything else is 4:3. (Which is probably wrong these days...) else { @@ -1724,13 +1731,15 @@ int CheckRatio (int width, int height, int *trueratio) // base_width = 240 * x / y // multiplier = 320 / base_width // base_height = 200 * multiplier -const int BaseRatioSizes[5][4] = +const int BaseRatioSizes[7][4] = { { 960, 600, 0, 48 }, // 4:3 320, 200, multiplied by three { 1280, 450, 0, 48*3/4 }, // 16:9 426.6667, 150, multiplied by three { 1152, 500, 0, 48*5/6 }, // 16:10 386, 166.6667, multiplied by three { 1224, 471, 0, 48*40/51 }, // 17:10 408, 156.8627, multiplied by three - { 960, 640, (int)(6.5*FRACUNIT), 48*15/16 } // 5:4 320, 213.3333, multiplied by three + { 960, 640, (int)(6.5*FRACUNIT), 48*15/16 }, // 5:4 320, 213.3333, multiplied by three + { 1224, 471, 0, 48*40/51 }, // 17:10 408, 156.8627, multiplied by three (REDUNDANT) + { 568, 113, 0, 48*5/8 } // 21:9 }; void IVideo::DumpAdapters () diff --git a/src/v_video.h b/src/v_video.h index 0497b607e..7e0b09258 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -503,8 +503,14 @@ extern "C" void ASM_PatchPitch (void); int CheckRatio (int width, int height, int *trueratio=NULL); static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); } -extern const int BaseRatioSizes[5][4]; +extern const int BaseRatioSizes[7][4]; +inline bool IsRatioWidescreen(int ratio) { + return (ratio & 3)!=0; +} +inline bool Is54Aspect(int ratio) { + return ratio == 4; +} #endif // __V_VIDEO_H__ diff --git a/src/win32/hardware.cpp b/src/win32/hardware.cpp index d8a4fa974..cb4250b60 100644 --- a/src/win32/hardware.cpp +++ b/src/win32/hardware.cpp @@ -338,7 +338,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CCMD (vid_listmodes) { - static const char *ratios[5] = { "", " - 16:9", " - 16:10", " - 17:10", " - 5:4" }; + static const char *ratios[6] = { "", " - 16:9", " - 16:10", " - 17:10", " - 5:4", " - 21:9" }; int width, height, bits; bool letterbox; @@ -356,7 +356,7 @@ CCMD (vid_listmodes) int ratio = CheckRatio (width, height); Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, "%s%4d x%5d x%3d%s%s\n", - thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, + thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD, width, height, bits, ratios[ratio], thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB"