1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-14 22:03:27 +01:00

assign default palette to primary surface

This commit is contained in:
FunkyFr3sh 2024-12-15 00:05:51 +01:00
parent ac19dec2c4
commit 806924f86e
3 changed files with 277 additions and 3 deletions

View File

@ -11,4 +11,265 @@ HRESULT ddp_GetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwBase
HRESULT ddp_SetEntries(IDirectDrawPaletteImpl* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
HRESULT dd_CreatePalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, IDirectDrawPaletteImpl** lpDDPalette, IUnknown FAR* unkOuter);
// Original palette copied from Windows ME
static PALETTEENTRY g_ddp_me_palette[] =
{
{ 0, 0, 0, 0 },
{ 128, 0, 0, 0 },
{ 0, 128, 0, 0 },
{ 128, 128, 0, 0 },
{ 0, 0, 128, 0 },
{ 128, 0, 128, 0 },
{ 0, 128, 128, 0 },
{ 192, 192, 192, 0 },
{ 192, 220, 192, 0 },
{ 166, 202, 240, 0 },
{ 95, 63, 63, 0 },
{ 127, 63, 63, 0 },
{ 159, 63, 63, 0 },
{ 191, 63, 63, 0 },
{ 223, 63, 63, 0 },
{ 255, 63, 63, 0 },
{ 63, 95, 63, 0 },
{ 95, 95, 63, 0 },
{ 127, 95, 63, 0 },
{ 159, 95, 63, 0 },
{ 191, 95, 63, 0 },
{ 223, 95, 63, 0 },
{ 255, 95, 63, 0 },
{ 63, 127, 63, 0 },
{ 95, 127, 63, 0 },
{ 127, 127, 63, 0 },
{ 159, 127, 63, 0 },
{ 191, 127, 63, 0 },
{ 223, 127, 63, 0 },
{ 255, 127, 63, 0 },
{ 63, 159, 63, 0 },
{ 95, 159, 63, 0 },
{ 127, 159, 63, 0 },
{ 159, 159, 63, 0 },
{ 191, 159, 63, 0 },
{ 223, 159, 63, 0 },
{ 255, 159, 63, 0 },
{ 63, 191, 63, 0 },
{ 95, 191, 63, 0 },
{ 127, 191, 63, 0 },
{ 159, 191, 63, 0 },
{ 191, 191, 63, 0 },
{ 223, 191, 63, 0 },
{ 255, 191, 63, 0 },
{ 63, 223, 63, 0 },
{ 95, 223, 63, 0 },
{ 127, 223, 63, 0 },
{ 159, 223, 63, 0 },
{ 191, 223, 63, 0 },
{ 223, 223, 63, 0 },
{ 255, 223, 63, 0 },
{ 63, 255, 63, 0 },
{ 95, 255, 63, 0 },
{ 127, 255, 63, 0 },
{ 159, 255, 63, 0 },
{ 191, 255, 63, 0 },
{ 223, 255, 63, 0 },
{ 255, 255, 63, 0 },
{ 63, 63, 95, 0 },
{ 95, 63, 95, 0 },
{ 127, 63, 95, 0 },
{ 159, 63, 95, 0 },
{ 191, 63, 95, 0 },
{ 223, 63, 95, 0 },
{ 255, 63, 95, 0 },
{ 63, 95, 95, 0 },
{ 95, 95, 95, 0 },
{ 127, 95, 95, 0 },
{ 159, 95, 95, 0 },
{ 191, 95, 95, 0 },
{ 223, 95, 95, 0 },
{ 255, 95, 95, 0 },
{ 63, 127, 95, 0 },
{ 95, 127, 95, 0 },
{ 127, 127, 95, 0 },
{ 159, 127, 95, 0 },
{ 191, 127, 95, 0 },
{ 223, 127, 95, 0 },
{ 255, 127, 95, 0 },
{ 63, 159, 95, 0 },
{ 95, 159, 95, 0 },
{ 127, 159, 95, 0 },
{ 159, 159, 95, 0 },
{ 191, 159, 95, 0 },
{ 223, 159, 95, 0 },
{ 255, 159, 95, 0 },
{ 63, 191, 95, 0 },
{ 95, 191, 95, 0 },
{ 127, 191, 95, 0 },
{ 159, 191, 95, 0 },
{ 191, 191, 95, 0 },
{ 223, 191, 95, 0 },
{ 255, 191, 95, 0 },
{ 63, 223, 95, 0 },
{ 95, 223, 95, 0 },
{ 127, 223, 95, 0 },
{ 159, 223, 95, 0 },
{ 191, 223, 95, 0 },
{ 223, 223, 95, 0 },
{ 255, 223, 95, 0 },
{ 63, 255, 95, 0 },
{ 95, 255, 95, 0 },
{ 127, 255, 95, 0 },
{ 159, 255, 95, 0 },
{ 191, 255, 95, 0 },
{ 223, 255, 95, 0 },
{ 255, 255, 95, 0 },
{ 63, 63, 127, 0 },
{ 95, 63, 127, 0 },
{ 127, 63, 127, 0 },
{ 159, 63, 127, 0 },
{ 191, 63, 127, 0 },
{ 223, 63, 127, 0 },
{ 255, 63, 127, 0 },
{ 63, 95, 127, 0 },
{ 95, 95, 127, 0 },
{ 127, 95, 127, 0 },
{ 159, 95, 127, 0 },
{ 191, 95, 127, 0 },
{ 223, 95, 127, 0 },
{ 255, 95, 127, 0 },
{ 63, 127, 127, 0 },
{ 95, 127, 127, 0 },
{ 127, 127, 127, 0 },
{ 159, 127, 127, 0 },
{ 191, 127, 127, 0 },
{ 223, 127, 127, 0 },
{ 255, 127, 127, 0 },
{ 63, 159, 127, 0 },
{ 95, 159, 127, 0 },
{ 127, 159, 127, 0 },
{ 159, 159, 127, 0 },
{ 191, 159, 127, 0 },
{ 223, 159, 127, 0 },
{ 255, 159, 127, 0 },
{ 63, 191, 127, 0 },
{ 95, 191, 127, 0 },
{ 127, 191, 127, 0 },
{ 159, 191, 127, 0 },
{ 191, 191, 127, 0 },
{ 223, 191, 127, 0 },
{ 255, 191, 127, 0 },
{ 63, 223, 127, 0 },
{ 95, 223, 127, 0 },
{ 127, 223, 127, 0 },
{ 159, 223, 127, 0 },
{ 191, 223, 127, 0 },
{ 223, 223, 127, 0 },
{ 255, 223, 127, 0 },
{ 63, 255, 127, 0 },
{ 95, 255, 127, 0 },
{ 127, 255, 127, 0 },
{ 159, 255, 127, 0 },
{ 191, 255, 127, 0 },
{ 223, 255, 127, 0 },
{ 255, 255, 127, 0 },
{ 63, 63, 159, 0 },
{ 95, 63, 159, 0 },
{ 127, 63, 159, 0 },
{ 159, 63, 159, 0 },
{ 191, 63, 159, 0 },
{ 223, 63, 159, 0 },
{ 255, 63, 159, 0 },
{ 63, 95, 159, 0 },
{ 95, 95, 159, 0 },
{ 127, 95, 159, 0 },
{ 159, 95, 159, 0 },
{ 191, 95, 159, 0 },
{ 223, 95, 159, 0 },
{ 255, 95, 159, 0 },
{ 63, 127, 159, 0 },
{ 95, 127, 159, 0 },
{ 127, 127, 159, 0 },
{ 159, 127, 159, 0 },
{ 191, 127, 159, 0 },
{ 223, 127, 159, 0 },
{ 255, 127, 159, 0 },
{ 63, 159, 159, 0 },
{ 95, 159, 159, 0 },
{ 127, 159, 159, 0 },
{ 159, 159, 159, 0 },
{ 191, 159, 159, 0 },
{ 223, 159, 159, 0 },
{ 255, 159, 159, 0 },
{ 63, 191, 159, 0 },
{ 95, 191, 159, 0 },
{ 127, 191, 159, 0 },
{ 159, 191, 159, 0 },
{ 191, 191, 159, 0 },
{ 223, 191, 159, 0 },
{ 255, 191, 159, 0 },
{ 63, 223, 159, 0 },
{ 95, 223, 159, 0 },
{ 127, 223, 159, 0 },
{ 159, 223, 159, 0 },
{ 191, 223, 159, 0 },
{ 223, 223, 159, 0 },
{ 255, 223, 159, 0 },
{ 63, 255, 159, 0 },
{ 95, 255, 159, 0 },
{ 127, 255, 159, 0 },
{ 159, 255, 159, 0 },
{ 191, 255, 159, 0 },
{ 223, 255, 159, 0 },
{ 255, 255, 159, 0 },
{ 63, 63, 191, 0 },
{ 95, 63, 191, 0 },
{ 127, 63, 191, 0 },
{ 159, 63, 191, 0 },
{ 191, 63, 191, 0 },
{ 223, 63, 191, 0 },
{ 255, 63, 191, 0 },
{ 63, 95, 191, 0 },
{ 95, 95, 191, 0 },
{ 127, 95, 191, 0 },
{ 159, 95, 191, 0 },
{ 191, 95, 191, 0 },
{ 223, 95, 191, 0 },
{ 255, 95, 191, 0 },
{ 63, 127, 191, 0 },
{ 95, 127, 191, 0 },
{ 127, 127, 191, 0 },
{ 159, 127, 191, 0 },
{ 191, 127, 191, 0 },
{ 223, 127, 191, 0 },
{ 255, 127, 191, 0 },
{ 63, 159, 191, 0 },
{ 95, 159, 191, 0 },
{ 127, 159, 191, 0 },
{ 159, 159, 191, 0 },
{ 191, 159, 191, 0 },
{ 223, 159, 191, 0 },
{ 255, 159, 191, 0 },
{ 63, 191, 191, 0 },
{ 95, 191, 191, 0 },
{ 127, 191, 191, 0 },
{ 159, 191, 191, 0 },
{ 191, 191, 191, 0 },
{ 223, 191, 191, 0 },
{ 255, 191, 191, 0 },
{ 63, 223, 191, 0 },
{ 95, 223, 191, 0 },
{ 127, 223, 191, 0 },
{ 159, 223, 191, 0 },
{ 191, 223, 191, 0 },
{ 223, 223, 191, 0 },
{ 255, 251, 240, 0 },
{ 58, 109, 165, 0 },
{ 128, 128, 128, 0 },
{ 255, 0, 0, 0 },
{ 0, 255, 0, 0 },
{ 255, 255, 0, 0 },
{ 0, 0, 255, 0 },
{ 255, 0, 255, 0 },
{ 0, 255, 255, 0 },
{ 255, 255, 255, 0 }
};
#endif

View File

@ -84,7 +84,7 @@ HRESULT dd_CreatePalette(
p->lpVtbl = &g_ddp_vtbl;
p->flags = dwFlags;
ddp_SetEntries(p, dwFlags, 0, 256, lpDDColorArray);
ddp_SetEntries(p, dwFlags, 0, 256, lpDDColorArray);
IDirectDrawPalette_AddRef(p);
*lpDDPalette = p;

View File

@ -14,6 +14,7 @@
#include "ddclipper.h"
#include "utils.h"
#include "versionhelpers.h"
#include "ddpalette.h"
LONG g_dds_gdi_handles;
@ -1093,8 +1094,7 @@ HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpD
if (lpDDPalette)
IDirectDrawPalette_AddRef(lpDDPalette);
if (This->palette)
IDirectDrawPalette_Release(This->palette);
IDirectDrawPaletteImpl* old_palette = This->palette;
if ((This->caps & DDSCAPS_PRIMARYSURFACE) && g_ddraw.ref)
{
@ -1113,6 +1113,9 @@ HRESULT dds_SetPalette(IDirectDrawSurfaceImpl* This, IDirectDrawPaletteImpl* lpD
This->palette = lpDDPalette;
}
if (old_palette)
IDirectDrawPalette_Release(old_palette);
return DD_OK;
}
@ -1574,6 +1577,16 @@ HRESULT dd_CreateSurface(
{
g_ddraw.primary = dst_surface;
FakePrimarySurface = dst_surface->surface;
if (dst_surface->bpp == 8)
{
IDirectDrawPaletteImpl* lpDDPalette;
dd_CreatePalette(DDPCAPS_ALLOW256, g_ddp_me_palette, &lpDDPalette, NULL);
dds_SetPalette(dst_surface, lpDDPalette);
// Make sure temp palette will be released once replaced
IDirectDrawPalette_Release(lpDDPalette);
}
}
}