From 8e53cdc5fa288fadbc0e9d391c6ca34fcb424ffc Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sat, 27 Oct 2018 07:43:47 +0200 Subject: [PATCH] fix palette issues on GetDC --- src/debug.c | 7 ++++++- src/surface.c | 15 +++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/debug.c b/src/debug.c index 3dde17c..c091569 100644 --- a/src/debug.c +++ b/src/debug.c @@ -43,8 +43,13 @@ void DrawFrameInfoStart() RECT debugrc = { 0, 0, ddraw->width, ddraw->height }; if (ddraw->primary && ddraw->primary->palette) - DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP); + { + if (ddraw->primary->palette->data_rgb) + SetDIBColorTable(ddraw->primary->hDC, 0, 256, ddraw->primary->palette->data_rgb); + DrawText(ddraw->primary->hDC, debugText, -1, &debugrc, DT_NOCLIP); + } + DWORD tick_start = timeGetTime(); if (tick_start >= tick_fps) { diff --git a/src/surface.c b/src/surface.c index e9bf4f8..3efb4c5 100644 --- a/src/surface.c +++ b/src/surface.c @@ -376,6 +376,15 @@ HRESULT __stdcall ddraw_surface_GetDC(IDirectDrawSurfaceImpl *This, HDC FAR *a) #if _DEBUG_X printf("IDirectDrawSurface::GetDC(This=%p, ...)\n", This); #endif + + RGBQUAD *data = + This->palette && This->palette->data_rgb ? This->palette->data_rgb : + ddraw->primary && ddraw->primary->palette ? ddraw->primary->palette->data_rgb : + NULL; + + if (data) + SetDIBColorTable(This->hDC, 0, 256, data); + *a = This->hDC; return DD_OK; } @@ -648,12 +657,6 @@ HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpD Surface->bmi->bmiColors[i].rgbReserved = 0; } -#if _DEBUG - Surface->bmi->bmiColors[255].rgbRed = 250; - Surface->bmi->bmiColors[255].rgbGreen = 250; - Surface->bmi->bmiColors[255].rgbBlue = 250; -#endif - Surface->lXPitch = Surface->bpp / 8; Surface->lPitch = Surface->width * Surface->lXPitch;