diff --git a/src/r_main.cpp b/src/r_main.cpp index 5af77e97d7..2b9a3e9a1e 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -160,6 +160,7 @@ fixed_t globaluclip, globaldclip; fixed_t centerxfrac; fixed_t centeryfrac; fixed_t yaspectmul; +fixed_t baseyaspectmul; // yaspectmul without a forced aspect ratio float iyaspectmulfloat; fixed_t InvZtoScale; @@ -604,7 +605,7 @@ void R_SetViewSize (int blocks) void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) { - int virtheight, virtwidth; + int virtheight, virtwidth, trueratio, virtwidth2, virtheight2; if (windowSize >= 11) { @@ -625,7 +626,7 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) } // If the screen is approximately 16:9 or 16:10, consider it widescreen. - WidescreenRatio = CheckRatio (fullWidth, fullHeight); + WidescreenRatio = CheckRatio (fullWidth, fullHeight, &trueratio); DrawFSHUD = (windowSize == 11); @@ -648,8 +649,18 @@ void R_SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight) centerxfrac = centerx<>= k; daxscale <<= (k+8); dayscale <<= (k+8); - dazscale = FixedDiv(dayscale, yaspectmul); + dazscale = FixedDiv(dayscale, baseyaspectmul); daxscale = FixedDiv(daxscale, yaspectmul); daxscale = Scale(daxscale, xdimenscale, centerxwide << 9); dayscale = Scale(dayscale, FixedMul(xdimenscale, viewingrangerecip), centerxwide << 9); diff --git a/src/v_video.cpp b/src/v_video.cpp index c2709c62fe..8de9e0de94 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1739,43 +1739,61 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) // 1: 16:9 // 2: 16:10 // 4: 5:4 -int CheckRatio (int width, int height) +int CheckRatio (int width, int height, int *trueratio) { + int fakeratio = -1; + int ratio; + if ((vid_aspect >=1) && (vid_aspect <=4)) { // [SP] User wants to force aspect ratio; let them. - return vid_aspect == 3? 0: int(vid_aspect); + fakeratio = vid_aspect == 3? 0: int(vid_aspect); } if (vid_nowidescreen) { if (!vid_tft) { - return 0; + fakeratio = 0; + } + else + { + fakeratio = (height * 5/4 == width) ? 4 : 0; } - return (height * 5/4 == width) ? 4 : 0; } // If the size is approximately 16:9, consider it so. if (abs (height * 16/9 - width) < 10) { - return 1; + ratio = 1; } // 16:10 has more variance in the pixel dimensions. Grr. - if (abs (height * 16/10 - width) < 60) + else if (abs (height * 16/10 - width) < 60) { // 320x200 and 640x400 are always 4:3, not 16:10 if ((width == 320 && height == 200) || (width == 640 && height == 400)) { - return 0; + ratio = 0; + } + else + { + ratio = 2; } - return 2; } // Unless vid_tft is set, 1280x1024 is 4:3, not 5:4. - if (height * 5/4 == width && vid_tft) + else if (height * 5/4 == width && vid_tft) { - return 4; + ratio = 4; } // Assume anything else is 4:3. - return 0; + else + { + ratio = 0; + } + + if (trueratio != NULL) + { + *trueratio = ratio; + } + return (fakeratio >= 0) ? fakeratio : ratio; } // First column: Base width (unused) diff --git a/src/v_video.h b/src/v_video.h index 684b5e36a1..399d644809 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -500,7 +500,7 @@ void V_DrawFrame (int left, int top, int width, int height); extern "C" void ASM_PatchPitch (void); #endif -int CheckRatio (int width, int height); +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];