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

support TargetOverride parameter

This commit is contained in:
FunkyFr3sh 2021-05-31 18:54:32 +02:00
parent ddd647438f
commit 061f078f73

View File

@ -683,7 +683,6 @@ HRESULT dds_GetSurfaceDesc(IDirectDrawSurfaceImpl *This, LPDDSURFACEDESC lpDDSur
HRESULT dds_EnumAttachedSurfaces(IDirectDrawSurfaceImpl *This, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback) HRESULT dds_EnumAttachedSurfaces(IDirectDrawSurfaceImpl *This, LPVOID lpContext, LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)
{ {
/* this is not actually complete, but Carmageddon seems to call EnumAttachedSurfaces instead of GetSurfaceDesc to get the main surface description */
static DDSURFACEDESC dd_surface_desc; static DDSURFACEDESC dd_surface_desc;
memset(&dd_surface_desc, 0, sizeof(DDSURFACEDESC)); memset(&dd_surface_desc, 0, sizeof(DDSURFACEDESC));
@ -713,13 +712,15 @@ HRESULT dds_Flip(IDirectDrawSurfaceImpl *This, LPDIRECTDRAWSURFACE surface, DWOR
if (This->backbuffer) if (This->backbuffer)
{ {
EnterCriticalSection(&g_ddraw->cs); EnterCriticalSection(&g_ddraw->cs);
void* surface = InterlockedExchangePointer(&This->surface, This->backbuffer->surface); IDirectDrawSurfaceImpl* backbuffer = surface ? (IDirectDrawSurfaceImpl*)surface : This->backbuffer;
HBITMAP bitmap = (HBITMAP)InterlockedExchangePointer(&This->bitmap, This->backbuffer->bitmap);
HDC hdc = (HDC)InterlockedExchangePointer(&This->hdc, This->backbuffer->hdc);
InterlockedExchangePointer(&This->backbuffer->surface, surface); void* buf = InterlockedExchangePointer(&This->surface, backbuffer->surface);
InterlockedExchangePointer(&This->backbuffer->bitmap, bitmap); HBITMAP bitmap = (HBITMAP)InterlockedExchangePointer(&This->bitmap, backbuffer->bitmap);
InterlockedExchangePointer(&This->backbuffer->hdc, hdc); HDC dc = (HDC)InterlockedExchangePointer(&This->hdc, backbuffer->hdc);
InterlockedExchangePointer(&backbuffer->surface, buf);
InterlockedExchangePointer(&backbuffer->bitmap, bitmap);
InterlockedExchangePointer(&backbuffer->hdc, dc);
LeaveCriticalSection(&g_ddraw->cs); LeaveCriticalSection(&g_ddraw->cs);
} }
@ -1179,6 +1180,12 @@ HRESULT dd_CreateSurface(IDirectDrawImpl* This, LPDDSURFACEDESC lpDDSurfaceDesc,
DDSURFACEDESC desc; DDSURFACEDESC desc;
memset(&desc, 0, sizeof(DDSURFACEDESC)); memset(&desc, 0, sizeof(DDSURFACEDESC));
if (lpDDSurfaceDesc->dwBackBufferCount > 1)
{
desc.dwBackBufferCount = lpDDSurfaceDesc->dwBackBufferCount - 1;
desc.dwFlags |= DDSD_BACKBUFFERCOUNT;
}
desc.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER; desc.ddsCaps.dwCaps |= DDSCAPS_BACKBUFFER;
desc.dwWidth = dst_surface->width; desc.dwWidth = dst_surface->width;