From 82d3ec46a38c8905be42ef098f9b113811878634 Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 15 Dec 2024 00:56:06 +0100 Subject: [PATCH] copy from g_ddp_me_palette if there's no primary yet --- src/winapi_hooks.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/winapi_hooks.c b/src/winapi_hooks.c index b909e10bdb..38cfbd1204 100644 --- a/src/winapi_hooks.c +++ b/src/winapi_hooks.c @@ -1351,13 +1351,24 @@ HFONT WINAPI fake_CreateFontA( UINT WINAPI fake_GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries) { - if (g_ddraw.ref && g_ddraw.bpp == 8 && WindowFromDC(hdc) == g_ddraw.hwnd) + if (g_ddraw.ref && g_ddraw.bpp == 8 && pPalEntries && WindowFromDC(hdc) == g_ddraw.hwnd) { if (g_ddraw.primary && g_ddraw.primary->palette) { + TRACE("ddp_GetEntries test\n"); ddp_GetEntries(g_ddraw.primary->palette, 0, iStart, cEntries, pPalEntries); return cEntries - iStart; } + else + { + for (int i = iStart, x = 0; i < iStart + cEntries && i < 256; i++, x++) + { + pPalEntries[x].peRed = g_ddp_me_palette[i].peRed; + pPalEntries[x].peGreen = g_ddp_me_palette[i].peGreen; + pPalEntries[x].peBlue = g_ddp_me_palette[i].peBlue; + pPalEntries[x].peFlags = g_ddp_me_palette[i].peFlags; + } + } } return real_GetSystemPaletteEntries(hdc, iStart, cEntries, pPalEntries);