Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2017 William Feely
|
| 3 | +// Copyright (C) 2011-2018 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -1729,7 +1729,9 @@ |
1730 | 1730 | TRACE_ENTER(1, 14, This);
|
1731 | 1731 | if (This->currmode.dmSize != 0)
|
1732 | 1732 | {
|
1733 | | - ChangeDisplaySettingsEx(NULL, &This->currmode, NULL, CDS_FULLSCREEN, NULL);
|
| 1733 | + if((This->currmode.dmPelsWidth == 640) && (This->currmode.dmPelsHeight == 480)
|
| 1734 | + && dxglcfg.HackCrop640480to640400) Try640400Mode(NULL, &This->currmode, CDS_FULLSCREEN, NULL);
|
| 1735 | + else ChangeDisplaySettingsEx(NULL, &This->currmode, NULL, CDS_FULLSCREEN, NULL);
|
1734 | 1736 | }
|
1735 | 1737 | TRACE_EXIT(0, 0);
|
1736 | 1738 | }
|
— | — | @@ -1741,6 +1743,8 @@ |
1742 | 1744 | {
|
1743 | 1745 | glDD7->internalx = glDD7->screenx = dwWidth;
|
1744 | 1746 | glDD7->internaly = glDD7->screeny = dwHeight;
|
| 1747 | + if ((glDD7->primaryx == 640) && (glDD7->primaryy == 480) && dxglcfg.HackCrop640480to640400)
|
| 1748 | + glDD7->internaly *= 1.2f;
|
1745 | 1749 | if (glDD7->renderer && glDD7->primary) glRenderer_DrawScreen(glDD7->renderer, glDD7->primary->texture,
|
1746 | 1750 | glDD7->primary->texture->palette, 0, NULL);
|
1747 | 1751 | }
|
— | — | @@ -1919,6 +1923,26 @@ |
1920 | 1924 | else return 0;
|
1921 | 1925 | }
|
1922 | 1926 |
|
| 1927 | +LONG Try640400Mode(LPCWSTR devname, DEVMODE *mode, DWORD flags, BOOL *crop400)
|
| 1928 | +{
|
| 1929 | + LONG error;
|
| 1930 | + DEVMODE newmode = *mode;
|
| 1931 | + newmode.dmPelsHeight = 400;
|
| 1932 | + error = ChangeDisplaySettingsEx(devname, &newmode, NULL, flags, NULL);
|
| 1933 | + if (error == DISP_CHANGE_SUCCESSFUL) return error;
|
| 1934 | + // Try setting refresh to 70
|
| 1935 | + newmode.dmDisplayFrequency = 70;
|
| 1936 | + error = ChangeDisplaySettingsEx(devname, &newmode, NULL, flags, NULL);
|
| 1937 | + if (error == DISP_CHANGE_SUCCESSFUL) return error;
|
| 1938 | + // Try without refresh
|
| 1939 | + newmode.dmFields &= (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFLAGS | DM_POSITION);
|
| 1940 | + error = ChangeDisplaySettingsEx(devname, &newmode, NULL, flags, NULL);
|
| 1941 | + if (error == DISP_CHANGE_SUCCESSFUL) return error;
|
| 1942 | + // Finally try the original mode
|
| 1943 | + if(crop400) *crop400 = FALSE;
|
| 1944 | + return ChangeDisplaySettingsEx(devname, mode, NULL, flags, NULL);
|
| 1945 | +}
|
| 1946 | +
|
1923 | 1947 | HRESULT WINAPI glDirectDraw7::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
|
1924 | 1948 | {
|
1925 | 1949 | TRACE_ENTER(6,14,this,8,dwWidth,8,dwHeight,8,dwBPP,8,dwRefreshRate,9,dwFlags);
|
— | — | @@ -1940,7 +1964,9 @@ |
1941 | 1965 | float aspect,xmul,ymul,xscale,yscale;
|
1942 | 1966 | LONG error;
|
1943 | 1967 | DWORD flags;
|
| 1968 | + BOOL crop400 = FALSE;
|
1944 | 1969 | int stretchmode;
|
| 1970 | + if ((dwWidth == 640) && (dwHeight == 480) && dxglcfg.HackCrop640480to640400) crop400 = TRUE;
|
1945 | 1971 | if ((dxglcfg.AddColorDepths & 2) && !(dxglcfg.AddColorDepths & 4) && (dwBPP == 16))
|
1946 | 1972 | dwBPP = 15;
|
1947 | 1973 | if(!oldmode.dmSize)
|
— | — | @@ -1995,7 +2021,8 @@ |
1996 | 2022 | else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
1997 | 2023 | flags = 0;
|
1998 | 2024 | if (fullscreen) flags |= CDS_FULLSCREEN;
|
1999 | | - error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
| 2025 | + if (crop400) error = Try640400Mode(NULL, &newmode, flags, &crop400);
|
| 2026 | + else error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
2000 | 2027 | switch (error)
|
2001 | 2028 | {
|
2002 | 2029 | case DISP_CHANGE_SUCCESSFUL:
|
— | — | @@ -2011,7 +2038,8 @@ |
2012 | 2039 | primaryy = newmode.dmPelsHeight / yscale;
|
2013 | 2040 | }
|
2014 | 2041 | screenx = newmode.dmPelsWidth;
|
2015 | | - screeny = newmode.dmPelsHeight;
|
| 2042 | + if (crop400) screeny = 400;
|
| 2043 | + else screeny = newmode.dmPelsHeight;
|
2016 | 2044 | internalx = newmode.dmPelsWidth;
|
2017 | 2045 | internaly = newmode.dmPelsHeight;
|
2018 | 2046 | internalbpp = screenbpp = newmode.dmBitsPerPel;
|
— | — | @@ -2047,6 +2075,7 @@ |
2048 | 2076 | internalx = screenx = currmode.dmPelsWidth;
|
2049 | 2077 | primaryy = dwHeight;
|
2050 | 2078 | internaly = screeny = currmode.dmPelsHeight;
|
| 2079 | + if (crop400) internaly *= 1.2f;
|
2051 | 2080 | if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
2052 | 2081 | else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
2053 | 2082 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
— | — | @@ -2093,15 +2122,18 @@ |
2094 | 2123 | else
|
2095 | 2124 | {
|
2096 | 2125 | xmul = (float)screenx / (float)dwWidth;
|
2097 | | - ymul = (float)screeny / (float)dwHeight;
|
| 2126 | + if (crop400) ymul = (float)screeny / 400.0f;
|
| 2127 | + else ymul = (float)screeny / (float)dwHeight;
|
2098 | 2128 | if ((float)dwWidth*(float)ymul > (float)screenx)
|
2099 | 2129 | {
|
2100 | 2130 | internalx = (DWORD)((float)dwWidth * (float)xmul);
|
2101 | | - internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 2131 | + if(crop400) internaly = (DWORD)(400.0f * (float)xmul);
|
| 2132 | + else internaly = (DWORD)((float)dwHeight * (float)xmul);
|
2102 | 2133 | }
|
2103 | 2134 | else
|
2104 | 2135 | {
|
2105 | 2136 | internalx = (DWORD)((float)dwWidth * (float)ymul);
|
| 2137 | + if(crop400) internaly = (DWORD)(400.0f * (float)ymul);
|
2106 | 2138 | internaly = (DWORD)((float)dwHeight * (float)ymul);
|
2107 | 2139 | }
|
2108 | 2140 | }
|
— | — | @@ -2163,13 +2195,16 @@ |
2164 | 2196 | else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
2165 | 2197 | flags = 0;
|
2166 | 2198 | if (fullscreen) flags |= CDS_FULLSCREEN;
|
2167 | | - error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
| 2199 | + if (crop400) error = Try640400Mode(NULL, &newmode, flags, &crop400);
|
| 2200 | + else error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
2168 | 2201 | if (error != DISP_CHANGE_SUCCESSFUL)
|
2169 | 2202 | {
|
2170 | 2203 | newmode2 = FindClosestMode(newmode);
|
2171 | | - error = ChangeDisplaySettingsEx(NULL, &newmode2, NULL, flags, NULL);
|
| 2204 | + if (crop400) error = Try640400Mode(NULL, &newmode2, flags, &crop400);
|
| 2205 | + else error = ChangeDisplaySettingsEx(NULL, &newmode2, NULL, flags, NULL);
|
2172 | 2206 | }
|
2173 | 2207 | else newmode2 = newmode;
|
| 2208 | + if (crop400) newmode2.dmPelsHeight = 400;
|
2174 | 2209 | if (error == DISP_CHANGE_SUCCESSFUL) this->currmode = newmode2;
|
2175 | 2210 | switch (dxglcfg.scaler)
|
2176 | 2211 | {
|
— | — | @@ -2178,6 +2213,7 @@ |
2179 | 2214 | internalx = screenx = newmode2.dmPelsWidth;
|
2180 | 2215 | primaryy = dwHeight;
|
2181 | 2216 | internaly = screeny = newmode2.dmPelsHeight;
|
| 2217 | + if (crop400) internaly *= 1.2f;
|
2182 | 2218 | if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
2183 | 2219 | else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
2184 | 2220 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
— | — | @@ -2224,15 +2260,18 @@ |
2225 | 2261 | else
|
2226 | 2262 | {
|
2227 | 2263 | xmul = (float)screenx / (float)dwWidth;
|
2228 | | - ymul = (float)screeny / (float)dwHeight;
|
| 2264 | + if (crop400) ymul = (float)screeny / 400.0f;
|
| 2265 | + else ymul = (float)screeny / (float)dwHeight;
|
2229 | 2266 | if ((float)dwWidth*(float)ymul > (float)screenx)
|
2230 | 2267 | {
|
2231 | 2268 | internalx = (DWORD)((float)dwWidth * (float)xmul);
|
2232 | | - internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 2269 | + if (crop400) internaly = (DWORD)(400.0f * (float)xmul);
|
| 2270 | + else internaly = (DWORD)((float)dwHeight * (float)xmul);
|
2233 | 2271 | }
|
2234 | 2272 | else
|
2235 | 2273 | {
|
2236 | 2274 | internalx = (DWORD)((float)dwWidth * (float)ymul);
|
| 2275 | + if (crop400) internaly = (DWORD)(400.0f * (float)ymul);
|
2237 | 2276 | internaly = (DWORD)((float)dwHeight * (float)ymul);
|
2238 | 2277 | }
|
2239 | 2278 | }
|
— | — | @@ -2362,7 +2401,12 @@ |
2363 | 2402 | primaryx = dwWidth;
|
2364 | 2403 | internalx = screenx = dwWidth * xscale;
|
2365 | 2404 | primaryy = dwHeight;
|
2366 | | - internaly = screeny = dwHeight * yscale;
|
| 2405 | + if (crop400)
|
| 2406 | + {
|
| 2407 | + screeny = 400 * yscale;
|
| 2408 | + internaly = dwHeight * yscale;
|
| 2409 | + }
|
| 2410 | + else internaly = screeny = dwHeight * yscale;
|
2367 | 2411 | internalbpp = screenbpp = dwBPP;
|
2368 | 2412 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
2369 | 2413 | else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2016 William Feely
|
| 3 | +// Copyright (C) 2011-2018 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -144,6 +144,7 @@ |
145 | 145 | extern "C" void glDirectDraw7_UnrestoreDisplayMode(glDirectDraw7 *This);
|
146 | 146 | extern "C" void glDirectDraw7_GetSizes(glDirectDraw7 *glDD7, LONG *sizes);
|
147 | 147 | extern "C" void glDirectDraw7_SetWindowSize(glDirectDraw7 *glDD7, DWORD dwWidth, DWORD dwHeight);
|
| 148 | +LONG Try640400Mode(LPCWSTR devname, DEVMODE *mode, DWORD flags, BOOL *crop400);
|
148 | 149 |
|
149 | 150 | class glDirectDraw1 : public IDirectDraw
|
150 | 151 | {
|
Index: dxglcfg/dxglcfg.rc |
— | — | @@ -132,7 +132,8 @@ |
133 | 133 | AUTOCHECKBOX "Don't auto-size window in resizable window mode", IDC_NOAUTOSIZE, 7, 101, 171, 8, 0, WS_EX_LEFT
|
134 | 134 | LTEXT "Installation path", IDC_PATHLABEL, 7, 124, 51, 9, SS_LEFT, WS_EX_LEFT
|
135 | 135 | EDITTEXT IDC_PROFILEPATH, 7, 135, 331, 14, NOT WS_BORDER | NOT WS_TABSTOP | ES_AUTOHSCROLL | ES_READONLY, WS_EX_LEFT
|
136 | | - PUSHBUTTON "Write INI file...", IDC_WRITEINI, 262, 150, 73, 14, 0, WS_EX_LEFT
|
| 136 | + // Removed for DXGL 0.5.13 release
|
| 137 | + // PUSHBUTTON "Write INI file...", IDC_WRITEINI, 262, 150, 73, 14, 0, WS_EX_LEFT
|
137 | 138 | }
|
138 | 139 |
|
139 | 140 |
|