Skip to content

Commit

Permalink
copy from g_ddp_me_palette if there's no primary yet
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Dec 14, 2024
1 parent 1c263ca commit 82d3ec4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/winapi_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 82d3ec4

Please sign in to comment.