1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

add new "fixpitch" setting

This commit is contained in:
FunkyFr3sh 2021-05-23 06:16:58 +02:00
parent 7b2c6616a1
commit 793ed44b44
3 changed files with 20 additions and 6 deletions

View File

@ -108,6 +108,7 @@ typedef struct cnc_ddraw
BOOL resizable;
BOOL sierrahack;
BOOL nonexclusive;
BOOL fixpitch;
BOOL fixchildwindows;
BOOL d3d9linear;
BOOL backbuffer;

View File

@ -48,6 +48,7 @@ void cfg_load()
g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE);
g_ddraw->resizable = cfg_get_bool("resizable", TRUE);
g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE);
g_ddraw->fixpitch = cfg_get_bool("fixpitch", FALSE);
g_ddraw->fixchildwindows = cfg_get_bool("fixchildwindows", TRUE);
g_ddraw->d3d9linear = cfg_get_bool("d3d9linear", TRUE);
g_ddraw->backbuffer = cfg_get_bool("backbuffer", TRUE);
@ -319,6 +320,10 @@ static void cfg_create_ini()
"; Note: Can be used in case some GUI elements like buttons/textboxes/videos/etc.. are invisible\n"
"nonexclusive=false\n"
"\n"
"; Fixes issues where the pitch of a surface is not a multiple of 4\n"
"; Note: Enable this if some parts of the screen are being displayed diagonally\n"
"fixpitch=false\n"
"\n"
"; Force CPU0 affinity, avoids crashes/freezing, *might* have a performance impact\n"
"singlecpu=true\n"
"\n"

View File

@ -1052,7 +1052,7 @@ HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FA
dst_surface->flags = lpDDSurfaceDesc->dwFlags;
dst_surface->caps = lpDDSurfaceDesc->ddsCaps.dwCaps;
if (lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
if (dst_surface->caps & DDSCAPS_PRIMARYSURFACE)
{
dst_surface->width = g_ddraw->width;
dst_surface->height = g_ddraw->height;
@ -1069,6 +1069,17 @@ HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FA
if (dst_surface->width == 71 && dst_surface->height == 24) dst_surface->width = 72; //Commandos
if (dst_surface->width == 343 && g_ddraw->bpp == 16) dst_surface->width = 344; //Blade & Sword
dst_surface->lx_pitch = dst_surface->bpp / 8;
dst_surface->l_pitch = dst_surface->width * dst_surface->lx_pitch;
if (g_ddraw->fixpitch && !(dst_surface->caps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER)))
{
while (dst_surface->l_pitch % 4)
{
dst_surface->l_pitch = ++dst_surface->width * dst_surface->lx_pitch;
}
}
dst_surface->bmi = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
dst_surface->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
dst_surface->bmi->bmiHeader.biWidth = dst_surface->width;
@ -1103,9 +1114,6 @@ HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FA
((DWORD *)dst_surface->bmi->bmiColors)[2] = 0x001F;
}
dst_surface->lx_pitch = dst_surface->bpp / 8;
dst_surface->l_pitch = dst_surface->width * dst_surface->lx_pitch;
dst_surface->hdc = CreateCompatibleDC(g_ddraw->render.hdc);
dst_surface->bitmap = CreateDIBSection(dst_surface->hdc, dst_surface->bmi, DIB_RGB_COLORS, (void **)&dst_surface->surface, NULL, 0);
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height);
@ -1119,7 +1127,7 @@ HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FA
dst_surface->l_pitch * (dst_surface->height + 200) * dst_surface->lx_pitch);
}
if (lpDDSurfaceDesc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
if (dst_surface->caps & DDSCAPS_PRIMARYSURFACE)
{
g_ddraw->primary = dst_surface;
FakePrimarySurface = dst_surface->surface;
@ -1128,7 +1136,7 @@ HRESULT dd_CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FA
SelectObject(dst_surface->hdc, dst_surface->bitmap);
}
if (lpDDSurfaceDesc->dwFlags & DDSD_BACKBUFFERCOUNT)
if (dst_surface->flags & DDSD_BACKBUFFERCOUNT)
{
dprintf(" dwBackBufferCount=%d\n", lpDDSurfaceDesc->dwBackBufferCount);