21:9 aspect ratio support

- vid_aspect 6 forces 21:9
This commit is contained in:
Michael Labbe 2016-03-02 02:31:12 -08:00 committed by Randy Heit
parent e3d35f4fe8
commit 97821a3036
8 changed files with 31 additions and 16 deletions

View file

@ -1058,7 +1058,7 @@ void DBaseStatusBar::RefreshBackground () const
int x, x2, y, ratio; int x, x2, y, ratio;
ratio = CheckRatio (SCREENWIDTH, SCREENHEIGHT); 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; y = x == ST_X && x > 0 ? ST_Y : ::ST_Y;
if(!CompleteBorder) if(!CompleteBorder)
@ -1078,7 +1078,7 @@ void DBaseStatusBar::RefreshBackground () const
{ {
if(!CompleteBorder) 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); SCREENWIDTH - (SCREENWIDTH*(48-BaseRatioSizes[ratio][3])+48*2-1)/(48*2);
} }
else else

View file

@ -308,7 +308,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CCMD (vid_listmodes) 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; int width, height, bits;
bool letterbox; bool letterbox;
@ -325,7 +325,7 @@ CCMD (vid_listmodes)
int ratio = CheckRatio (width, height); int ratio = CheckRatio (width, height);
Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, Printf (thisMode ? PRINT_BOLD : PRINT_HIGH,
"%s%4d x%5d x%3d%s%s\n", "%s%4d x%5d x%3d%s%s\n",
thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD,
width, height, bits, width, height, bits,
ratios[ratio], ratios[ratio],
thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB" thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB"

View file

@ -363,7 +363,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight,
virtwidth = virtwidth2 = fullWidth; virtwidth = virtwidth2 = fullWidth;
virtheight = virtheight2 = fullHeight; virtheight = virtheight2 = fullHeight;
if (trueratio & 4) if (Is54Aspect(trueratio))
{ {
virtheight2 = virtheight2 * BaseRatioSizes[trueratio][3] / 48; 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; virtwidth2 = virtwidth2 * BaseRatioSizes[trueratio][3] / 48;
} }
if (WidescreenRatio & 4) if (Is54Aspect(WidescreenRatio))
{ {
virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48; virtheight = virtheight * BaseRatioSizes[WidescreenRatio][3] / 48;
} }

View file

@ -434,7 +434,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight)
centery = viewheight/2; centery = viewheight/2;
centerx = viewwidth/2; centerx = viewwidth/2;
if (WidescreenRatio & 4) if (Is54Aspect(WidescreenRatio))
{ {
centerxwide = centerx; centerxwide = centerx;
} }

View file

@ -816,7 +816,7 @@ void DCanvas::FillBorder (FTexture *img)
return; return;
} }
int bordtop, bordbottom, bordleft, bordright, bord; int bordtop, bordbottom, bordleft, bordright, bord;
if (myratio & 4) if (Is54Aspect(myratio))
{ // Screen is taller than it is wide { // Screen is taller than it is wide
bordleft = bordright = 0; bordleft = bordright = 0;
bord = Height - Height * BaseRatioSizes[myratio][3] / 48; bord = Height - Height * BaseRatioSizes[myratio][3] / 48;

View file

@ -1397,7 +1397,7 @@ void V_CalcCleanFacs (int designwidth, int designheight, int realwidth, int real
int cx1, cy1, cx2, cy2; int cx1, cy1, cx2, cy2;
ratio = CheckRatio(realwidth, realheight); ratio = CheckRatio(realwidth, realheight);
if (ratio & 4) if (Is54Aspect(ratio))
{ {
cwidth = realwidth; cwidth = realwidth;
cheight = realheight * BaseRatioSizes[ratio][3] / 48; cheight = realheight * BaseRatioSizes[ratio][3] / 48;
@ -1645,12 +1645,14 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
// 2: 16:10 // 2: 16:10
// 3: 17:10 // 3: 17:10
// 4: 5:4 // 4: 5:4
// 5: 17:10 (redundant)
// 6: 21:9
int CheckRatio (int width, int height, int *trueratio) int CheckRatio (int width, int height, int *trueratio)
{ {
int fakeratio = -1; int fakeratio = -1;
int ratio; 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. // [SP] User wants to force aspect ratio; let them.
fakeratio = int(vid_aspect); fakeratio = int(vid_aspect);
@ -1661,7 +1663,7 @@ int CheckRatio (int width, int height, int *trueratio)
else if (fakeratio == 5) else if (fakeratio == 5)
{ {
fakeratio = 3; fakeratio = 3;
} }
} }
if (vid_nowidescreen) if (vid_nowidescreen)
{ {
@ -1702,6 +1704,11 @@ int CheckRatio (int width, int height, int *trueratio)
{ {
ratio = 4; 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...) // Assume anything else is 4:3. (Which is probably wrong these days...)
else else
{ {
@ -1724,13 +1731,15 @@ int CheckRatio (int width, int height, int *trueratio)
// base_width = 240 * x / y // base_width = 240 * x / y
// multiplier = 320 / base_width // multiplier = 320 / base_width
// base_height = 200 * multiplier // 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 { 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 { 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 { 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 { 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 () void IVideo::DumpAdapters ()

View file

@ -503,8 +503,14 @@ extern "C" void ASM_PatchPitch (void);
int CheckRatio (int width, int height, int *trueratio=NULL); int CheckRatio (int width, int height, int *trueratio=NULL);
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); } 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__ #endif // __V_VIDEO_H__

View file

@ -338,7 +338,7 @@ CUSTOM_CVAR (Float, vid_winscale, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CCMD (vid_listmodes) 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; int width, height, bits;
bool letterbox; bool letterbox;
@ -356,7 +356,7 @@ CCMD (vid_listmodes)
int ratio = CheckRatio (width, height); int ratio = CheckRatio (width, height);
Printf (thisMode ? PRINT_BOLD : PRINT_HIGH, Printf (thisMode ? PRINT_BOLD : PRINT_HIGH,
"%s%4d x%5d x%3d%s%s\n", "%s%4d x%5d x%3d%s%s\n",
thisMode || !(ratio & 3) ? "" : TEXTCOLOR_GOLD, thisMode || !IsRatioWidescreen(ratio) ? "" : TEXTCOLOR_GOLD,
width, height, bits, width, height, bits,
ratios[ratio], ratios[ratio],
thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB" thisMode || !letterbox ? "" : TEXTCOLOR_BROWN " LB"