DXGL r710 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r709‎ | r710 | r711 >
Date:06:58, 31 May 2017
Author:admin
Status:new
Tags:
Comment:
Adjust aspect for specific pixel-doubled modes automatically.
Does not affect the custom aspect override.
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -1744,6 +1744,16 @@
17451745 return newmode;
17461746 }
17471747
 1748+int IsStretchedMode(DWORD width, DWORD height)
 1749+{
 1750+ if ((width == 320) || (width == 360))
 1751+ {
 1752+ if ((height == 400) || (height == 480)) return 1;
 1753+ }
 1754+ else if ((width == 640) && (height == 200)) return 2;
 1755+ else return 0;
 1756+}
 1757+
17481758 HRESULT WINAPI glDirectDraw7::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
17491759 {
17501760 TRACE_ENTER(6,14,this,8,dwWidth,8,dwHeight,8,dwBPP,8,dwRefreshRate,9,dwFlags);
@@ -1765,6 +1775,7 @@
17661776 float aspect,xmul,ymul,xscale,yscale;
17671777 LONG error;
17681778 DWORD flags;
 1779+ int stretchmode;
17691780 if(!oldmode.dmSize)
17701781 {
17711782 oldmode.dmSize = sizeof(DEVMODE);
@@ -1871,17 +1882,44 @@
18721883 if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
18731884 {
18741885 aspect = (float)dwWidth / (float)dwHeight;
1875 - xmul = (float)screenx / (float)dwWidth;
1876 - ymul = (float)screeny / (float)dwHeight;
1877 - if ((float)dwWidth*(float)ymul > (float)screenx)
 1886+ switch (stretchmode = IsStretchedMode(dwWidth, dwHeight))
18781887 {
1879 - internalx = (DWORD)((float)dwWidth * (float)xmul);
1880 - internaly = (DWORD)((float)dwHeight * (float)xmul);
 1888+ case 1:
 1889+ aspect *= 2.0f;
 1890+ break;
 1891+ case 2:
 1892+ aspect /= 2.0f;
 1893+ break;
 1894+ default:
 1895+ break;
18811896 }
 1897+ if (stretchmode)
 1898+ {
 1899+ if (screenx / aspect > screeny)
 1900+ {
 1901+ internalx = (DWORD)((float)screeny * (float)aspect);
 1902+ internaly = screeny;
 1903+ }
 1904+ else
 1905+ {
 1906+ internalx = screenx;
 1907+ internaly = (DWORD)((float)screenx / (float)aspect);
 1908+ }
 1909+ }
18821910 else
18831911 {
1884 - internalx = (DWORD)((float)dwWidth * (float)ymul);
1885 - internaly = (DWORD)((float)dwHeight * (float)ymul);
 1912+ xmul = (float)screenx / (float)dwWidth;
 1913+ ymul = (float)screeny / (float)dwHeight;
 1914+ if ((float)dwWidth*(float)ymul > (float)screenx)
 1915+ {
 1916+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 1917+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 1918+ }
 1919+ else
 1920+ {
 1921+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 1922+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 1923+ }
18861924 }
18871925 }
18881926 else
@@ -1973,17 +2011,44 @@
19742012 if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
19752013 {
19762014 aspect = (float)dwWidth / (float)dwHeight;
1977 - xmul = (float)screenx / (float)dwWidth;
1978 - ymul = (float)screeny / (float)dwHeight;
1979 - if ((float)dwWidth*(float)ymul > (float)screenx)
 2015+ switch (stretchmode = IsStretchedMode(dwWidth, dwHeight))
19802016 {
1981 - internalx = (DWORD)((float)dwWidth * (float)xmul);
1982 - internaly = (DWORD)((float)dwHeight * (float)xmul);
 2017+ case 1:
 2018+ aspect *= 2.0f;
 2019+ break;
 2020+ case 2:
 2021+ aspect /= 2.0f;
 2022+ break;
 2023+ default:
 2024+ break;
19832025 }
 2026+ if (stretchmode)
 2027+ {
 2028+ if (screenx / aspect > screeny)
 2029+ {
 2030+ internalx = (DWORD)((float)screeny * (float)aspect);
 2031+ internaly = screeny;
 2032+ }
 2033+ else
 2034+ {
 2035+ internalx = screenx;
 2036+ internaly = (DWORD)((float)screenx / (float)aspect);
 2037+ }
 2038+ }
19842039 else
19852040 {
1986 - internalx = (DWORD)((float)dwWidth * (float)ymul);
1987 - internaly = (DWORD)((float)dwHeight * (float)ymul);
 2041+ xmul = (float)screenx / (float)dwWidth;
 2042+ ymul = (float)screeny / (float)dwHeight;
 2043+ if ((float)dwWidth*(float)ymul > (float)screenx)
 2044+ {
 2045+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 2046+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 2047+ }
 2048+ else
 2049+ {
 2050+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 2051+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 2052+ }
19882053 }
19892054 }
19902055 else
@@ -2038,17 +2103,44 @@
20392104 if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
20402105 {
20412106 aspect = (float)dwWidth / (float)dwHeight;
2042 - xmul = (float)screenx / (float)dwWidth;
2043 - ymul = (float)screeny / (float)dwHeight;
2044 - if ((float)dwWidth*(float)ymul < (float)screenx)
 2107+ switch (stretchmode = IsStretchedMode(dwWidth, dwHeight))
20452108 {
2046 - internalx = (DWORD)((float)dwWidth * (float)xmul);
2047 - internaly = (DWORD)((float)dwHeight * (float)xmul);
 2109+ case 1:
 2110+ aspect *= 2.0f;
 2111+ break;
 2112+ case 2:
 2113+ aspect /= 2.0f;
 2114+ break;
 2115+ default:
 2116+ break;
20482117 }
 2118+ if (stretchmode)
 2119+ {
 2120+ if (screenx / aspect < screeny)
 2121+ {
 2122+ internalx = (DWORD)((float)screeny * (float)aspect);
 2123+ internaly = screeny;
 2124+ }
 2125+ else
 2126+ {
 2127+ internalx = screenx;
 2128+ internaly = (DWORD)((float)screenx / (float)aspect);
 2129+ }
 2130+ }
20492131 else
20502132 {
2051 - internalx = (DWORD)((float)dwWidth * (float)ymul);
2052 - internaly = (DWORD)((float)dwHeight * (float)ymul);
 2133+ xmul = (float)screenx / (float)dwWidth;
 2134+ ymul = (float)screeny / (float)dwHeight;
 2135+ if ((float)dwWidth*(float)ymul < (float)screenx)
 2136+ {
 2137+ internalx = (DWORD)((float)dwWidth * (float)xmul);
 2138+ internaly = (DWORD)((float)dwHeight * (float)xmul);
 2139+ }
 2140+ else
 2141+ {
 2142+ internalx = (DWORD)((float)dwWidth * (float)ymul);
 2143+ internaly = (DWORD)((float)dwHeight * (float)ymul);
 2144+ }
20532145 }
20542146 }
20552147 else