mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-14 22:03:27 +01:00
Implement palettes, correct colors now
This commit is contained in:
parent
c3ed0a00b1
commit
230c0e04b8
20
palette.c
20
palette.c
@ -24,8 +24,12 @@ ULONG AddRef(void *This);
|
||||
ULONG Release(void *This);
|
||||
HRESULT null();
|
||||
|
||||
HRESULT ddraw_CreatePalette(void *This, DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR * lpDDPalette, IUnknown FAR * unkOuter)
|
||||
HRESULT ddraw_palette_SetEntries(void *_This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
||||
|
||||
HRESULT ddraw_CreatePalette(void *_This, DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR * lpDDPalette, IUnknown FAR * unkOuter)
|
||||
{
|
||||
fakeDirectDrawPaletteObject *This = (fakeDirectDrawPaletteObject *)_This;
|
||||
|
||||
printf("DirectDraw::CreatePalette(This=%p, dwFlags=%d, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, (int)dwFlags, lpDDColorArray, lpDDPalette, unkOuter);
|
||||
|
||||
fakeDirectDrawPaletteObject *Palette = (fakeDirectDrawPaletteObject *)malloc(sizeof(fakeDirectDrawPaletteObject));
|
||||
@ -34,6 +38,8 @@ HRESULT ddraw_CreatePalette(void *This, DWORD dwFlags, LPPALETTEENTRY lpDDColorA
|
||||
printf(" Palette = %p\n", Palette);
|
||||
*lpDDPalette = (LPDIRECTDRAWPALETTE)Palette;
|
||||
|
||||
ddraw_palette_SetEntries(Palette, dwFlags, 0, 256, lpDDColorArray);
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
@ -43,9 +49,19 @@ HRESULT ddraw_palette_GetEntries(void *This, DWORD dwFlags, DWORD dwBase, DWORD
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
HRESULT ddraw_palette_SetEntries(void *This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
|
||||
HRESULT ddraw_palette_SetEntries(void *_This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
|
||||
{
|
||||
int i;
|
||||
|
||||
fakeDirectDrawPaletteObject *This = (fakeDirectDrawPaletteObject *)_This;
|
||||
|
||||
printf("DirectDrawPalette::SetEntries(This=%p, dwFlags=%d, dwStartingEntry=%d, dwCount=%d, lpEntries=%p)\n", This, (int)dwFlags, (int)dwStartingEntry, (int)dwCount, lpEntries);
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
{
|
||||
This->data[i] = (lpEntries[i].peBlue<<16)|(lpEntries[i].peGreen<<8)|lpEntries[i].peRed;
|
||||
}
|
||||
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,8 @@ typedef struct
|
||||
{
|
||||
fakeDirectDrawPalette *Functions;
|
||||
|
||||
int data[256];
|
||||
|
||||
ULONG Ref;
|
||||
|
||||
} fakeDirectDrawPaletteObject;
|
||||
|
@ -75,6 +75,7 @@ HRESULT ddraw_CreateSurface(void *_This, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRE
|
||||
Surface->surface = NULL;
|
||||
Surface->glTex = NULL;
|
||||
Surface->caps = 0;
|
||||
Surface->palette = NULL;
|
||||
|
||||
if(lpDDSurfaceDesc->dwFlags & DDSD_CAPS)
|
||||
{
|
||||
@ -172,7 +173,9 @@ HRESULT ddraw_surface_GetPalette(void *_This, LPDIRECTDRAWPALETTE FAR *lplpDDPal
|
||||
|
||||
HRESULT ddraw_surface_SetPalette(void *_This, LPDIRECTDRAWPALETTE lpDDPalette)
|
||||
{
|
||||
fakeDirectDrawSurfaceObject *This = (fakeDirectDrawSurfaceObject *)_This;
|
||||
printf("DirectDrawSurface::SetPalette(This=%p, lpDDPalette=%p)\n", _This, lpDDPalette);
|
||||
This->palette = (fakeDirectDrawPaletteObject *)lpDDPalette;
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
@ -222,7 +225,7 @@ HRESULT ddraw_surface_Unlock(void *_This, LPVOID lpRect)
|
||||
printf("DirectDrawSurface::Unlock(This=%p, lpRect=%p)\n", This, lpRect);
|
||||
#endif
|
||||
|
||||
if(This->caps & DDSCAPS_PRIMARYSURFACE)
|
||||
if( (This->caps & DDSCAPS_PRIMARYSURFACE) && This->palette )
|
||||
{
|
||||
|
||||
/* FIXME: temporary grayscale palette */
|
||||
@ -237,7 +240,7 @@ HRESULT ddraw_surface_Unlock(void *_This, LPVOID lpRect)
|
||||
{
|
||||
for(j=0; j<This->width; j++)
|
||||
{
|
||||
This->glTex[i*This->width+j] = tmp_palette[((unsigned char *)This->surface)[i*This->lPitch + j*This->lXPitch]];
|
||||
This->glTex[i*This->width+j] = This->palette->data[((unsigned char *)This->surface)[i*This->lPitch + j*This->lXPitch]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include "ddraw.h"
|
||||
#include "palette.h"
|
||||
|
||||
HRESULT ddraw_CreateSurface(void *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter);
|
||||
|
||||
@ -74,6 +75,8 @@ typedef struct
|
||||
DWORD bpp;
|
||||
DWORD caps;
|
||||
|
||||
fakeDirectDrawPaletteObject *palette;
|
||||
|
||||
void *surface;
|
||||
DWORD lPitch;
|
||||
DWORD lXPitch;
|
||||
|
Loading…
x
Reference in New Issue
Block a user