From f10aad6ffb6388afd8ef81fcd906e189b9771514 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Sat, 16 Oct 2010 21:14:26 +0300 Subject: [PATCH] Implement palette and surface with null methods --- main.c | 18 ++++++++++++++++-- palette.c | 19 +++++++++++++++++++ palette.h | 2 ++ surface.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ surface.h | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 123 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index f74d213..dc131af 100644 --- a/main.c +++ b/main.c @@ -62,12 +62,26 @@ typedef struct 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; } HRESULT ddraw_CreateSurface(void *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter) { printf("DirectDraw::CreateSurface(This=%p, DDSurfaceDesc=%p, DDSurface=%p, unkOuter=%p)\n", This, DDSurfaceDesc, DDSurface, unkOuter); + + fakeDirectDrawSurfaceObject *Surface = (fakeDirectDrawSurfaceObject *)malloc(sizeof(fakeDirectDrawSurfaceObject)); + Surface->Ref = 1; + Surface->Functions = &siface; + printf(" Surface = %p\n", Surface); + *DDSurface = (LPDIRECTDRAWSURFACE)Surface; + return DD_OK; } @@ -111,9 +125,9 @@ ULONG Release(void *This) return ((fakeDirectDrawObject *)This)->Ref; } -HRESULT null() +HRESULT null(void *This) { - printf("Warning: null method called!\n"); + printf("Warning: null method called for instance %p!\n", This); return DD_OK; } diff --git a/palette.c b/palette.c index e0b30f2..c6bc985 100644 --- a/palette.c +++ b/palette.c @@ -16,3 +16,22 @@ #include #include "palette.h" + +/* from main */ +HRESULT QueryInterface(void *This, REFIID riid, void **obj); +ULONG AddRef(void *This); +ULONG Release(void *This); +HRESULT null(); + +fakeDirectDrawPalette piface = +{ + /* IUnknown */ + QueryInterface, + AddRef, + Release, + /* IDirectDrawPalette */ + null, // ddraw_palette_GetCaps + null, // ddraw_palette_GetEntries + null, // ddraw_palette_Initialize + null // ddraw_palette_SetEntries +}; diff --git a/palette.h b/palette.h index 51eed07..662906c 100644 --- a/palette.h +++ b/palette.h @@ -42,4 +42,6 @@ typedef struct } fakeDirectDrawPaletteObject; +extern fakeDirectDrawPalette piface; + #endif diff --git a/surface.c b/surface.c index 0e8b4d6..525963d 100644 --- a/surface.c +++ b/surface.c @@ -16,3 +16,51 @@ #include #include "surface.h" + +/* from main */ +HRESULT QueryInterface(void *This, REFIID riid, void **obj); +ULONG AddRef(void *This); +ULONG Release(void *This); +HRESULT null(); + +fakeDirectDrawSurface siface = +{ + /* IUnknown */ + QueryInterface, + AddRef, + Release, + /* IDirectDrawSurface */ + null, // AddAttachedSurface + null, // AddOverlayDirtyRect + null, // Blt + null, // BltBatch + null, // BltFast + null, // DeleteAttachedSurface + null, // EnumAttachedSurfaces + null, // EnumOverlayZOrders + null, // Flip + null, // GetAttachedSurface + null, // GetBltStatus + null, // GetCaps + null, // GetClipper + null, // GetColorKey + null, // GetDC + null, // GetFlipStatus + null, // GetOverlayPosition + null, // GetPalette + null, // GetPixelFormat + null, // GetSurfaceDesc + null, // Initialize + null, // IsLost + null, // Lock + null, // ReleaseDC + null, // Restore + null, // SetClipper + null, // SetColorKey + null, // SetOverlayPosition + null, // SetPalette + null, // Unlock + null, // UpdateOverlay + null, // UpdateOverlayDisplay + null // UpdateOverlayZOrder +}; diff --git a/surface.h b/surface.h index 1591cf9..319e0b9 100644 --- a/surface.h +++ b/surface.h @@ -28,8 +28,44 @@ typedef struct ULONG (*Release)(void *); /* IDirectDrawSurface */ + HRESULT (*AddAttachedSurface)(void *, LPDIRECTDRAWSURFACE); + HRESULT (*AddOverlayDirtyRect)(void *, LPRECT); + HRESULT (*Blt)(void *, LPRECT,LPDIRECTDRAWSURFACE, LPRECT,DWORD, LPDDBLTFX); + HRESULT (*BltBatch)(void *, LPDDBLTBATCH, DWORD, DWORD ); + HRESULT (*BltFast)(void *, DWORD,DWORD,LPDIRECTDRAWSURFACE, LPRECT,DWORD); + HRESULT (*DeleteAttachedSurface)(void *, DWORD,LPDIRECTDRAWSURFACE); + HRESULT (*EnumAttachedSurfaces)(void *, LPVOID,LPDDENUMSURFACESCALLBACK); + HRESULT (*EnumOverlayZOrders)(void *, DWORD,LPVOID,LPDDENUMSURFACESCALLBACK); + HRESULT (*Flip)(void *, LPDIRECTDRAWSURFACE, DWORD); + HRESULT (*GetAttachedSurface)(void *, LPDDSCAPS, LPDIRECTDRAWSURFACE FAR *); + HRESULT (*GetBltStatus)(void *, DWORD); + HRESULT (*GetCaps)(void *, LPDDSCAPS); + HRESULT (*GetClipper)(void *, LPDIRECTDRAWCLIPPER FAR*); + HRESULT (*GetColorKey)(void *, DWORD, LPDDCOLORKEY); + HRESULT (*GetDC)(void *, HDC FAR *); + HRESULT (*GetFlipStatus)(void *, DWORD); + HRESULT (*GetOverlayPosition)(void *, LPLONG, LPLONG ); + HRESULT (*GetPalette)(void *, LPDIRECTDRAWPALETTE FAR*); + HRESULT (*GetPixelFormat)(void *, LPDDPIXELFORMAT); + HRESULT (*GetSurfaceDesc)(void *, LPDDSURFACEDESC); + HRESULT (*Initialize)(void *, LPDIRECTDRAW, LPDDSURFACEDESC); + HRESULT (*IsLost)(void *); + HRESULT (*Lock)(void *, LPRECT,LPDDSURFACEDESC,DWORD,HANDLE); + HRESULT (*ReleaseDC)(void *, HDC); + HRESULT (*Restore)(void *); + HRESULT (*SetClipper)(void *, LPDIRECTDRAWCLIPPER); + HRESULT (*SetColorKey)(void *, DWORD, LPDDCOLORKEY); + HRESULT (*SetOverlayPosition)(void *, LONG, LONG ); + HRESULT (*SetPalette)(void *, LPDIRECTDRAWPALETTE); + HRESULT (*Unlock)(void *, LPVOID); + HRESULT (*UpdateOverlay)(void *, LPRECT, LPDIRECTDRAWSURFACE,LPRECT,DWORD, LPDDOVERLAYFX); + HRESULT (*UpdateOverlayDisplay)(void *, DWORD); + HRESULT (*UpdateOverlayZOrder)(void *, DWORD, LPDIRECTDRAWSURFACE); } fakeDirectDrawSurface; +/* +*/ + typedef struct { fakeDirectDrawSurface *Functions; @@ -38,4 +74,6 @@ typedef struct } fakeDirectDrawSurfaceObject; +extern fakeDirectDrawSurface siface; + #endif