Minor palette corrections (#122)

This commit is contained in:
Anders Jenbo 2025-05-19 05:31:37 +02:00 committed by GitHub
parent cd047211cf
commit a19827e10f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 12 deletions

View File

@ -17,7 +17,7 @@
#define FAR
#define WINAPI
#define HWND_NOTOPMOST -2
#define RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
#define RGB(r, g, b) (((BYTE) (r) | ((BYTE) (g) << 8) | ((BYTE) (b) << 16)))
#define S_OK ((HRESULT) 0)
#define E_NOINTERFACE (0x80004002)
#define VOID void
@ -49,8 +49,8 @@
#define ETO_OPAQUE 0x0002
#define FF_DONTCARE 0x00000000
#define RASTERCAPS 0x00000000
#define RC_PALETTE 0x00000000
#define SIZEPALETTE 256
#define RC_PALETTE 0x0100
#define SIZEPALETTE 104
#define FW_NORMAL 400
#define OPAQUE 2
#define OUT_DEFAULT_PRECIS 0
@ -163,6 +163,13 @@ inline int WINAPI ReleaseDC(HWND hWnd, HDC hDC)
inline int WINAPI GetDeviceCaps(HDC hdc, int index)
{
if (index == RASTERCAPS) {
return 0;
}
if (index == SIZEPALETTE) {
return 256;
}
return 0;
}

View File

@ -381,7 +381,14 @@ HRESULT DirectDrawEnumerate(LPDDENUMCALLBACKA cb, void* context);
inline UINT WINAPI GetSystemPaletteEntries(HDC hdc, UINT iStart, UINT cEntries, LPPALETTEENTRY pPalEntries)
{
return 0;
for (UINT i = 0; i < cEntries; i++) {
UINT val = iStart + i;
pPalEntries[i].peRed = val;
pPalEntries[i].peGreen = val;
pPalEntries[i].peBlue = val;
pPalEntries[i].peFlags = PC_NONE;
}
return cEntries;
}
inline HPALETTE CreatePalette(LPLOGPALETTE lpLogPalette)

View File

@ -16,10 +16,10 @@ DirectDrawPaletteImpl::~DirectDrawPaletteImpl()
HRESULT DirectDrawPaletteImpl::GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
{
for (int i = dwBase; i < dwNumEntries; i++) {
lpEntries[i].peRed = m_palette->colors[i].r;
lpEntries[i].peGreen = m_palette->colors[i].g;
lpEntries[i].peBlue = m_palette->colors[i].b;
for (DWORD i = 0; i < dwNumEntries; i++) {
lpEntries[i].peRed = m_palette->colors[dwBase + i].r;
lpEntries[i].peGreen = m_palette->colors[dwBase + i].g;
lpEntries[i].peBlue = m_palette->colors[dwBase + i].b;
lpEntries[i].peFlags = PC_NONE;
}
return DD_OK;
@ -28,10 +28,10 @@ HRESULT DirectDrawPaletteImpl::GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwN
HRESULT DirectDrawPaletteImpl::SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
{
SDL_Color colors[256];
for (int i = 0; i < dwCount; i++) {
colors[i].r = lpEntries[i].peRed;
colors[i].g = lpEntries[i].peGreen;
colors[i].b = lpEntries[i].peBlue;
for (DWORD i = 0; i < dwCount; i++) {
colors[i].r = lpEntries[dwStartingEntry + i].peRed;
colors[i].g = lpEntries[dwStartingEntry + i].peGreen;
colors[i].b = lpEntries[dwStartingEntry + i].peBlue;
colors[i].a = SDL_ALPHA_OPAQUE;
}