1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-24 17:49:52 +01:00

add .ini setting to return a full list of available resolutions

This commit is contained in:
FunkyFr3sh 2021-06-10 03:48:26 +02:00
parent a8edc2a465
commit 19b43e8988
3 changed files with 74 additions and 37 deletions

View File

@ -22,6 +22,10 @@ HRESULT dd_GetAvailableVidMem(void* lpDDCaps, LPDWORD lpdwTotal, LPDWORD lpdwFre
HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB); HRESULT dd_GetVerticalBlankStatus(LPBOOL lpbIsInVB);
HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOuter); HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOuter);
#define RESLIST_NORMAL 0
#define RESLIST_MINI 1
#define RESLIST_FULL 2
typedef struct speed_limiter typedef struct speed_limiter
{ {
DWORD tick_length; DWORD tick_length;
@ -115,6 +119,7 @@ typedef struct cnc_ddraw
BOOL gdilinear; BOOL gdilinear;
BOOL backbuffer; BOOL backbuffer;
BOOL passthrough; BOOL passthrough;
int resolutions;
BOOL armadahack; BOOL armadahack;
int maxgameticks; int maxgameticks;
BOOL alt_key_down; BOOL alt_key_down;

View File

@ -55,6 +55,7 @@ void cfg_load()
g_ddraw->gdilinear = cfg_get_bool("gdilinear", FALSE); g_ddraw->gdilinear = cfg_get_bool("gdilinear", FALSE);
g_ddraw->backbuffer = cfg_get_bool("backbuffer", TRUE); g_ddraw->backbuffer = cfg_get_bool("backbuffer", TRUE);
g_ddraw->passthrough = cfg_get_bool("passthrough", TRUE); g_ddraw->passthrough = cfg_get_bool("passthrough", TRUE);
g_ddraw->resolutions = cfg_get_int("resolutions", RESLIST_NORMAL);
g_ddraw->armadahack = cfg_get_bool("armadahack", FALSE); g_ddraw->armadahack = cfg_get_bool("armadahack", FALSE);

105
src/dd.c
View File

@ -21,13 +21,28 @@ HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVO
DWORD i = 0; DWORD i = 0;
DDSURFACEDESC s; DDSURFACEDESC s;
// Some games crash when you feed them with too many resolutions... /* Some games crash when you feed them with too many resolutions... */
if (g_ddraw->bpp) SIZE resolutions[] =
{
{ 320, 200 },
{ 320, 240 },
{ 512, 384 },
{ 640, 400 },
{ 640, 480 },
{ 800, 600 },
{ 1024, 768 },
{ 1280, 1024 },
{ 1600, 1200 },
{ 1280, 720 },
{ 1920, 1080 },
};
if (g_ddraw->bpp || g_ddraw->resolutions == RESLIST_FULL)
{ {
dprintf(" g_ddraw->bpp=%u\n", g_ddraw->bpp); dprintf(" g_ddraw->bpp=%u\n", g_ddraw->bpp);
//set up some filters to keep the list short /* set up some filters to keep the list short */
DWORD refresh_rate = 0; DWORD refresh_rate = 0;
DWORD bpp = 0; DWORD bpp = 0;
DWORD flags = 99998; DWORD flags = 99998;
@ -81,31 +96,55 @@ HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVO
s.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB; s.ddpfPixelFormat.dwFlags = DDPF_PALETTEINDEXED8 | DDPF_RGB;
s.ddpfPixelFormat.dwRGBBitCount = 8; s.ddpfPixelFormat.dwRGBBitCount = 8;
if (g_ddraw->bpp == 16) if (g_ddraw->bpp == 8 || g_ddraw->resolutions == RESLIST_FULL)
{ {
s.lPitch = s.dwWidth * 2; if (lpEnumModesCallback(&s, lpContext) == DDENUMRET_CANCEL)
s.ddpfPixelFormat.dwFlags = DDPF_RGB; {
s.ddpfPixelFormat.dwRGBBitCount = 16; dprintf(" DDENUMRET_CANCEL returned, stopping\n");
s.ddpfPixelFormat.dwRBitMask = 0xF800; break;
s.ddpfPixelFormat.dwGBitMask = 0x07E0; }
s.ddpfPixelFormat.dwBBitMask = 0x001F;
} }
if (g_ddraw->bpp == 32) s.lPitch = s.dwWidth * 2;
s.ddpfPixelFormat.dwFlags = DDPF_RGB;
s.ddpfPixelFormat.dwRGBBitCount = 16;
s.ddpfPixelFormat.dwRBitMask = 0xF800;
s.ddpfPixelFormat.dwGBitMask = 0x07E0;
s.ddpfPixelFormat.dwBBitMask = 0x001F;
if (g_ddraw->bpp == 16 || g_ddraw->resolutions == RESLIST_FULL)
{ {
s.lPitch = s.dwWidth * 4; if (lpEnumModesCallback(&s, lpContext) == DDENUMRET_CANCEL)
s.ddpfPixelFormat.dwFlags = DDPF_RGB; {
s.ddpfPixelFormat.dwRGBBitCount = 32; dprintf(" DDENUMRET_CANCEL returned, stopping\n");
s.ddpfPixelFormat.dwRBitMask = 0xFF0000; break;
s.ddpfPixelFormat.dwGBitMask = 0x00FF00; }
s.ddpfPixelFormat.dwBBitMask = 0x0000FF;
} }
if (lpEnumModesCallback(&s, lpContext) == DDENUMRET_CANCEL) s.lPitch = s.dwWidth * 4;
s.ddpfPixelFormat.dwFlags = DDPF_RGB;
s.ddpfPixelFormat.dwRGBBitCount = 32;
s.ddpfPixelFormat.dwRBitMask = 0xFF0000;
s.ddpfPixelFormat.dwGBitMask = 0x00FF00;
s.ddpfPixelFormat.dwBBitMask = 0x0000FF;
if (g_ddraw->bpp == 32 || g_ddraw->resolutions == RESLIST_FULL)
{ {
dprintf(" DDENUMRET_CANCEL returned, stopping\n"); if (lpEnumModesCallback(&s, lpContext) == DDENUMRET_CANCEL)
break; {
dprintf(" DDENUMRET_CANCEL returned, stopping\n");
break;
}
}
for (int x = 0; x < sizeof(resolutions) / sizeof(resolutions[0]); x++)
{
if (resolutions[x].cx == m.dmPelsWidth && resolutions[x].cy == m.dmPelsHeight)
{
resolutions[x].cx = 0;
resolutions[x].cy = 0;
}
} }
} }
@ -114,23 +153,9 @@ HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVO
i++; i++;
} }
} }
else
{
SIZE resolutions[] =
{
{ 320, 200 },
{ 320, 240 },
{ 512, 384 },
{ 640, 400 },
{ 640, 480 },
{ 800, 600 },
{ 1024, 768 },
{ 1280, 1024 },
{ 1600, 1200 },
{ 1280, 720 },
{ 1920, 1080 },
};
if (!g_ddraw->bpp || g_ddraw->resolutions == RESLIST_FULL)
{
DWORD max_w = 0; DWORD max_w = 0;
DWORD max_h = 0; DWORD max_h = 0;
DEVMODE m; DEVMODE m;
@ -146,6 +171,9 @@ HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVO
for (i = 0; i < sizeof(resolutions) / sizeof(resolutions[0]); i++) for (i = 0; i < sizeof(resolutions) / sizeof(resolutions[0]); i++)
{ {
if (!resolutions[i].cx || !resolutions[i].cy)
continue;
if ((max_w && resolutions[i].cx > max_w) || (max_h && resolutions[i].cy > max_h)) if ((max_w && resolutions[i].cx > max_w) || (max_h && resolutions[i].cy > max_h))
{ {
memset(&m, 0, sizeof(DEVMODE)); memset(&m, 0, sizeof(DEVMODE));
@ -190,6 +218,9 @@ HRESULT dd_EnumDisplayModes(DWORD dwFlags, LPDDSURFACEDESC lpDDSurfaceDesc, LPVO
break; break;
} }
if (g_ddraw->resolutions == RESLIST_MINI)
continue;
s.lPitch = s.dwWidth * 4; s.lPitch = s.dwWidth * 4;
s.ddpfPixelFormat.dwFlags = DDPF_RGB; s.ddpfPixelFormat.dwFlags = DDPF_RGB;
s.ddpfPixelFormat.dwRGBBitCount = 32; s.ddpfPixelFormat.dwRGBBitCount = 32;