From 15ff8f8e2a2168eb280fe6f9e998a37ac726e5e7 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Sat, 16 Oct 2010 23:22:43 +0300 Subject: [PATCH] Implement GetCaps for ddraw and surface, GetPalette and SetPalette for surface --- main.c | 33 ++++++++++++++++++++++++--------- palette.c | 14 ++++++++++++++ palette.h | 2 ++ surface.c | 34 ++++++++++++++++++++++++++++------ 4 files changed, 68 insertions(+), 15 deletions(-) diff --git a/main.c b/main.c index 6fc994c..b7e9bae 100644 --- a/main.c +++ b/main.c @@ -37,7 +37,7 @@ typedef struct HRESULT (*EnumDisplayModes)(void *); HRESULT (*EnumSurfaces)(void *); HRESULT (*FlipToGDISurface)(void *); - HRESULT (*GetCaps)(void *); + HRESULT (*GetCaps)(void *, LPDDCAPS, LPDDCAPS); HRESULT (*GetDisplayMode)(void *); HRESULT (*GetFourCCCodes)(void *); HRESULT (*GetGDISurface)(void *); @@ -59,15 +59,30 @@ typedef struct } fakeDirectDrawObject; -HRESULT ddraw_CreatePalette(void *This, LPPALETTEENTRY DDColorArray, LPDIRECTDRAWPALETTE FAR * DDPalette, IUnknown FAR * unkOuter) +HRESULT ddraw_GetCaps(void *This, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDEmulCaps) { - printf("DirectDraw::CreatePalette(This=%p, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, DDColorArray, DDPalette, unkOuter); + printf("DirectDraw::GetCaps(This=%p, lpDDDriverCaps=%p, lpDDEmulCaps=%p)\n", This, lpDDDriverCaps, lpDDEmulCaps); - fakeDirectDrawPaletteObject *Palette = (fakeDirectDrawPaletteObject *)malloc(sizeof(fakeDirectDrawPaletteObject)); - Palette->Ref = 1; - Palette->Functions = &piface; - printf(" Palette = %p\n", Palette); - *DDPalette = (LPDIRECTDRAWPALETTE)Palette; + if(lpDDDriverCaps) + { + lpDDDriverCaps->dwSize = sizeof(DDCAPS); + lpDDDriverCaps->dwCKeyCaps = 0; + lpDDDriverCaps->dwPalCaps = DDPCAPS_8BIT|DDPCAPS_PRIMARYSURFACE; + lpDDDriverCaps->dwVidMemTotal = 16777216; + lpDDDriverCaps->dwVidMemFree = 16777216; + lpDDDriverCaps->dwMaxVisibleOverlays = 0; + lpDDDriverCaps->dwCurrVisibleOverlays = 0; + lpDDDriverCaps->dwNumFourCCCodes = 0; + lpDDDriverCaps->dwAlignBoundarySrc = 0; + lpDDDriverCaps->dwAlignSizeSrc = 0; + lpDDDriverCaps->dwAlignBoundaryDest = 0; + lpDDDriverCaps->dwAlignSizeDest = 0; + } + + if(lpDDEmulCaps) + { + lpDDEmulCaps->dwSize = 0; + } return DD_OK; } @@ -133,7 +148,7 @@ fakeDirectDraw iface = null, //EnumDisplayModes, null, //EnumSurfaces, null, //FlipToGDISurface, - null, //GetCaps, + ddraw_GetCaps, null, //GetDisplayMode, null, //GetFourCCCodes, null, //GetGDISurface, diff --git a/palette.c b/palette.c index c6bc985..84fc007 100644 --- a/palette.c +++ b/palette.c @@ -15,6 +15,7 @@ */ #include +#include #include "palette.h" /* from main */ @@ -23,6 +24,19 @@ ULONG AddRef(void *This); ULONG Release(void *This); HRESULT null(); +HRESULT ddraw_CreatePalette(void *This, LPPALETTEENTRY DDColorArray, LPDIRECTDRAWPALETTE FAR * DDPalette, IUnknown FAR * unkOuter) +{ + printf("DirectDraw::CreatePalette(This=%p, DDColorArray=%p, DDPalette=%p, unkOuter=%p)\n", This, DDColorArray, DDPalette, unkOuter); + + fakeDirectDrawPaletteObject *Palette = (fakeDirectDrawPaletteObject *)malloc(sizeof(fakeDirectDrawPaletteObject)); + Palette->Ref = 1; + Palette->Functions = &piface; + printf(" Palette = %p\n", Palette); + *DDPalette = (LPDIRECTDRAWPALETTE)Palette; + + return DD_OK; +} + fakeDirectDrawPalette piface = { /* IUnknown */ diff --git a/palette.h b/palette.h index 662906c..95a3116 100644 --- a/palette.h +++ b/palette.h @@ -44,4 +44,6 @@ typedef struct extern fakeDirectDrawPalette piface; +HRESULT ddraw_CreatePalette(void *This, LPPALETTEENTRY DDColorArray, LPDIRECTDRAWPALETTE FAR * DDPalette, IUnknown FAR * unkOuter); + #endif diff --git a/surface.c b/surface.c index f409dd4..98d24b1 100644 --- a/surface.c +++ b/surface.c @@ -38,7 +38,7 @@ ULONG ddraw_surface_Release(void *_This) { fakeDirectDrawSurfaceObject *This = (fakeDirectDrawSurfaceObject *)_This; - printf("DirectDrawSurface::Release(((fakeDirectDrawSurfaceObject *)This)=%p)\n", ((fakeDirectDrawSurfaceObject *)This)); + printf("DirectDrawSurface::Release(This=%p)\n", ((fakeDirectDrawSurfaceObject *)This)); This->Ref--; @@ -71,6 +71,11 @@ HRESULT ddraw_CreateSurface(void *This, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIREC Surface->height = lpDDSurfaceDesc->dwHeight; Surface->surface = NULL; + if(Surface->width && Surface->height) + { + Surface->surface = malloc(Surface->width * Surface->height); + } + printf(" Surface = %p\n", Surface); Surface->Ref = 0; @@ -87,6 +92,25 @@ HRESULT ddraw_surface_Blt(void *This, LPRECT lpDestRect, LPDIRECTDRAWSURFACE lpD return DD_OK; } +HRESULT ddraw_surface_GetCaps(void *_This, LPDDSCAPS lpDDSCaps) +{ + printf("DirectDrawSurface::GetCaps(This=%p, lpDDSCaps=%p)\n", _This, lpDDSCaps); + lpDDSCaps->dwCaps = 0; + return DD_OK; +} + +HRESULT ddraw_surface_GetPalette(void *_This, LPDIRECTDRAWPALETTE FAR *lplpDDPalette) +{ + printf("DirectDrawSurface::GetPalette(This=%p, lplpDDPalette=%p)\n", _This, lplpDDPalette); + return DD_OK; +} + +HRESULT ddraw_surface_SetPalette(void *_This, LPDIRECTDRAWPALETTE lpDDPalette) +{ + printf("DirectDrawSurface::SetPalette(This=%p, lpDDPalette=%p)\n", _This, lpDDPalette); + return DD_OK; +} + HRESULT ddraw_surface_Lock(void *_This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent) { fakeDirectDrawSurfaceObject *This = (fakeDirectDrawSurfaceObject *)_This; @@ -114,8 +138,6 @@ HRESULT ddraw_surface_Lock(void *_This, LPRECT lpDestRect, LPDDSURFACEDESC lpDDS printf(" dwFlags: DDLOCK_WRITEONLY\n"); } - This->surface = malloc(This->width * This->height); - lpDDSurfaceDesc->dwSize = sizeof(DDSURFACEDESC); lpDDSurfaceDesc->dwFlags = DDSD_LPSURFACE; lpDDSurfaceDesc->lpSurface = This->surface; @@ -147,13 +169,13 @@ fakeDirectDrawSurface siface = null, // ddraw_surface_Flip null, // ddraw_surface_GetAttachedSurface null, // ddraw_surface_GetBltStatus - null, // ddraw_surface_GetCaps + ddraw_surface_GetCaps, null, // ddraw_surface_GetClipper null, // ddraw_surface_GetColorKey null, // ddraw_surface_GetDC null, // ddraw_surface_GetFlipStatus null, // ddraw_surface_GetOverlayPosition - null, // ddraw_surface_GetPalette + ddraw_surface_GetPalette, null, // ddraw_surface_GetPixelFormat null, // ddraw_surface_GetSurfaceDesc null, // ddraw_surface_Initialize @@ -164,7 +186,7 @@ fakeDirectDrawSurface siface = null, // ddraw_surface_SetClipper null, // ddraw_surface_SetColorKey null, // ddraw_surface_SetOverlayPosition - null, // ddraw_surface_SetPalette + ddraw_surface_SetPalette, ddraw_surface_Unlock, null, // ddraw_surface_UpdateOverlay null, // ddraw_surface_UpdateOverlayDisplay