make fixpitch setting working with primary surface too

This commit is contained in:
FunkyFr3sh 2022-09-09 12:57:05 +02:00
parent efad3e0fd5
commit e578df74e3
6 changed files with 24 additions and 18 deletions

View file

@ -1030,16 +1030,17 @@ HRESULT dd_CreateSurface(
if (dst_surface->width && dst_surface->height)
{
if (dst_surface->width == 71 && dst_surface->height == 24) dst_surface->width = 72; //Commandos
DWORD bmp_width = dst_surface->width;
DWORD bmp_height = dst_surface->height;
dst_surface->lx_pitch = dst_surface->bpp / 8;
dst_surface->l_pitch = dst_surface->width * dst_surface->lx_pitch;
dst_surface->l_pitch = bmp_width * dst_surface->lx_pitch;
if (g_ddraw->fixpitch && !(dst_surface->caps & (DDSCAPS_PRIMARYSURFACE | DDSCAPS_BACKBUFFER)))
if (g_ddraw->fixpitch)
{
while (dst_surface->l_pitch % 4)
{
dst_surface->l_pitch = ++dst_surface->width * dst_surface->lx_pitch;
dst_surface->l_pitch = ++bmp_width * dst_surface->lx_pitch;
}
}
@ -1047,8 +1048,8 @@ HRESULT dd_CreateSurface(
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;
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height + 200);
dst_surface->bmi->bmiHeader.biWidth = bmp_width;
dst_surface->bmi->bmiHeader.biHeight = -((int)bmp_height + 200);
dst_surface->bmi->bmiHeader.biPlanes = 1;
dst_surface->bmi->bmiHeader.biBitCount = dst_surface->bpp;
dst_surface->bmi->bmiHeader.biCompression = dst_surface->bpp == 8 ? BI_RGB : BI_BITFIELDS;
@ -1061,7 +1062,7 @@ HRESULT dd_CreateSurface(
}
dst_surface->bmi->bmiHeader.biSizeImage =
((dst_surface->width * clr_bits + 31) & ~31) / 8 * dst_surface->height;
((bmp_width * clr_bits + 31) & ~31) / 8 * bmp_height;
if (dst_surface->bpp == 8)
{
@ -1090,7 +1091,7 @@ HRESULT dd_CreateSurface(
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);
dst_surface->bmi->bmiHeader.biHeight = -((int)bmp_height);
if (!dst_surface->bitmap)
{
@ -1098,7 +1099,7 @@ HRESULT dd_CreateSurface(
HeapAlloc(
GetProcessHeap(),
HEAP_ZERO_MEMORY,
dst_surface->l_pitch * (dst_surface->height + 200) * dst_surface->lx_pitch);
dst_surface->l_pitch * (bmp_height + 200) * dst_surface->lx_pitch);
}
if (dst_surface->caps & DDSCAPS_PRIMARYSURFACE)