1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-25 01:57:47 +01:00

Implement all IDirectDraw stubs, C&C now starts up on Wine

This commit is contained in:
Toni Spets 2010-10-23 19:25:02 +03:00
parent 023794ae97
commit e07abb7e18
5 changed files with 106 additions and 22 deletions

View File

@ -70,10 +70,8 @@ fakeDirectDrawClipper ciface =
null // ddraw_clipper_SetHwnd null // ddraw_clipper_SetHwnd
}; };
HRESULT ddraw_CreateClipper(void *_This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ) HRESULT __stdcall ddraw_CreateClipper(IDirectDrawImpl *This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter )
{ {
fakeDirectDrawClipperObject *This = (fakeDirectDrawClipperObject *)_This;
printf("DirectDraw::CreateClipper(This=%p, dwFlags=%d, DDClipper=%p, unkOuter=%p)\n", This, (int)dwFlags, lplpDDClipper, pUnkOuter); printf("DirectDraw::CreateClipper(This=%p, dwFlags=%d, DDClipper=%p, unkOuter=%p)\n", This, (int)dwFlags, lplpDDClipper, pUnkOuter);
fakeDirectDrawClipperObject *Clipper = (fakeDirectDrawClipperObject *)malloc(sizeof(fakeDirectDrawClipperObject)); fakeDirectDrawClipperObject *Clipper = (fakeDirectDrawClipperObject *)malloc(sizeof(fakeDirectDrawClipperObject));

View File

@ -19,6 +19,7 @@
#include <windows.h> #include <windows.h>
#include "ddraw.h" #include "ddraw.h"
#include "main.h"
typedef struct typedef struct
{ {
@ -46,6 +47,6 @@ typedef struct
extern fakeDirectDrawClipper ciface; extern fakeDirectDrawClipper ciface;
HRESULT ddraw_CreateClipper(void *_This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter ); HRESULT __stdcall ddraw_CreateClipper(IDirectDrawImpl *This, DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter );
#endif #endif

113
main.c
View File

@ -23,6 +23,38 @@
#include "surface.h" #include "surface.h"
#include "clipper.h" #include "clipper.h"
HRESULT __stdcall ddraw_Compact(IDirectDrawImpl *This)
{
printf("DirectDraw::Compact(This=%p)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_DuplicateSurface(IDirectDrawImpl *This, LPDIRECTDRAWSURFACE src, LPDIRECTDRAWSURFACE *dest)
{
printf("DirectDraw::DuplicateSurface(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_EnumDisplayModes(IDirectDrawImpl *This, DWORD a, LPDDSURFACEDESC b, LPVOID c, LPDDENUMMODESCALLBACK d)
{
printf("DirectDraw::EnumDisplayModes(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_EnumSurfaces(IDirectDrawImpl *This, DWORD a, LPDDSURFACEDESC b, LPVOID c, LPDDENUMSURFACESCALLBACK d)
{
printf("DirectDraw::EnumSurfaces(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_FlipToGDISurface(IDirectDrawImpl *This)
{
printf("DirectDraw::FlipToGDISurface(This=%p)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetCaps(IDirectDrawImpl *This, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDEmulCaps) HRESULT __stdcall ddraw_GetCaps(IDirectDrawImpl *This, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDEmulCaps)
{ {
printf("DirectDraw::GetCaps(This=%p, lpDDDriverCaps=%p, lpDDEmulCaps=%p)\n", This, lpDDDriverCaps, lpDDEmulCaps); printf("DirectDraw::GetCaps(This=%p, lpDDDriverCaps=%p, lpDDEmulCaps=%p)\n", This, lpDDDriverCaps, lpDDEmulCaps);
@ -52,10 +84,51 @@ HRESULT __stdcall ddraw_GetCaps(IDirectDrawImpl *This, LPDDCAPS lpDDDriverCaps,
return DD_OK; return DD_OK;
} }
HRESULT __stdcall ddraw_GetDisplayMode(IDirectDrawImpl *This, LPDDSURFACEDESC a)
{
printf("DirectDraw::GetDisplayMode(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetFourCCCodes(IDirectDrawImpl *This, LPDWORD a, LPDWORD b)
{
printf("DirectDraw::GetFourCCCodes(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetGDISurface(IDirectDrawImpl *This, LPDIRECTDRAWSURFACE *a)
{
printf("DirectDraw::GetGDISurface(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetMonitorFrequency(IDirectDrawImpl *This, LPDWORD a)
{
printf("DirectDraw::GetMonitorFrequency(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetScanLine(IDirectDrawImpl *This, LPDWORD a)
{
printf("DirectDraw::GetScanLine(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_GetVerticalBlankStatus(IDirectDrawImpl *This, LPBOOL a)
{
printf("DirectDraw::GetVerticalBlankStatus(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_Initialize(IDirectDrawImpl *This, GUID *a)
{
printf("DirectDraw::Initialize(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_RestoreDisplayMode(IDirectDrawImpl *This) HRESULT __stdcall ddraw_RestoreDisplayMode(IDirectDrawImpl *This)
{ {
printf("DirectDraw::RestoreDisplayMode(This=%p)\n", This); printf("DirectDraw::RestoreDisplayMode(This=%p)\n", This);
return DD_OK; return DD_OK;
} }
@ -71,11 +144,13 @@ HRESULT __stdcall ddraw_SetCooperativeLevel(IDirectDrawImpl *This, HWND hWnd, DW
This->hWnd = hWnd; This->hWnd = hWnd;
#ifndef USE_OPENGL
if(IDirectDraw_SetCooperativeLevel(This->real_ddraw, hWnd, DDSCL_NORMAL) != DD_OK) if(IDirectDraw_SetCooperativeLevel(This->real_ddraw, hWnd, DDSCL_NORMAL) != DD_OK)
{ {
printf(" internal SetCooperativeLevel failed\n"); printf(" internal SetCooperativeLevel failed\n");
return DDERR_GENERIC; return DDERR_GENERIC;
} }
#endif
return DD_OK; return DD_OK;
} }
@ -93,6 +168,12 @@ HRESULT __stdcall ddraw_SetDisplayMode(IDirectDrawImpl *This, DWORD width, DWORD
return DD_OK; return DD_OK;
} }
HRESULT __stdcall ddraw_WaitForVerticalBlank(IDirectDrawImpl *This, DWORD a, HANDLE b)
{
printf("DirectDraw::WaitForVerticalBlank(This=%p, ...)\n", This);
return DD_OK;
}
HRESULT __stdcall ddraw_QueryInterface(IDirectDrawImpl *This, REFIID riid, void **obj) HRESULT __stdcall ddraw_QueryInterface(IDirectDrawImpl *This, REFIID riid, void **obj)
{ {
printf("DirectDraw::QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj); printf("DirectDraw::QueryInterface(This=%p, riid=%08X, obj=%p)\n", This, (unsigned int)riid, obj);
@ -116,7 +197,9 @@ ULONG __stdcall ddraw_Release(IDirectDrawImpl *This)
if(This->Ref == 0) if(This->Ref == 0)
{ {
#ifndef USE_OPENGL
IDirectDraw_Release(This->real_ddraw); IDirectDraw_Release(This->real_ddraw);
#endif
free(This); free(This);
return 0; return 0;
} }
@ -138,26 +221,26 @@ struct IDirectDrawImplVtbl iface =
ddraw_AddRef, ddraw_AddRef,
ddraw_Release, ddraw_Release,
/* IDirectDrawImpl */ /* IDirectDrawImpl */
null, //Compact, ddraw_Compact,
ddraw_CreateClipper, ddraw_CreateClipper,
ddraw_CreatePalette, ddraw_CreatePalette,
ddraw_CreateSurface, ddraw_CreateSurface,
null, //DuplicateSurface, ddraw_DuplicateSurface,
null, //EnumDisplayModes, ddraw_EnumDisplayModes,
null, //EnumSurfaces, ddraw_EnumSurfaces,
null, //FlipToGDISurface, ddraw_FlipToGDISurface,
ddraw_GetCaps, ddraw_GetCaps,
null, //GetDisplayMode, ddraw_GetDisplayMode,
null, //GetFourCCCodes, ddraw_GetFourCCCodes,
null, //GetGDISurface, ddraw_GetGDISurface,
null, //GetMonitorFrequency, ddraw_GetMonitorFrequency,
null, //GetScanLine, ddraw_GetScanLine,
null, //GetVerticalBlankStatus, ddraw_GetVerticalBlankStatus,
null, //Initialize, ddraw_Initialize,
ddraw_RestoreDisplayMode, ddraw_RestoreDisplayMode,
ddraw_SetCooperativeLevel, ddraw_SetCooperativeLevel,
ddraw_SetDisplayMode, ddraw_SetDisplayMode,
null //WaitForVerticalBlank ddraw_WaitForVerticalBlank
}; };
int stdout_open = 0; int stdout_open = 0;
@ -180,6 +263,7 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
printf(" This = %p\n", This); printf(" This = %p\n", This);
*lplpDD = (LPDIRECTDRAW)This; *lplpDD = (LPDIRECTDRAW)This;
#ifndef USE_OPENGL
This->real_dll = LoadLibrary("system32\\ddraw.dll"); This->real_dll = LoadLibrary("system32\\ddraw.dll");
if(!This->real_dll) if(!This->real_dll)
{ {
@ -191,6 +275,7 @@ HRESULT WINAPI DirectDrawCreate(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnk
{ {
return DDERR_UNSUPPORTED; return DDERR_UNSUPPORTED;
} }
#endif
This->Ref = 0; This->Ref = 0;
ddraw_AddRef(This); ddraw_AddRef(This);

View File

@ -23,7 +23,7 @@
/* from main */ /* from main */
HRESULT null(); HRESULT null();
DWORD WINAPI ogl_Thread(void *_This); DWORD WINAPI ogl_Thread(IDirectDrawSurfaceImpl *This);
DWORD WINAPI dd_Thread(IDirectDrawSurfaceImpl *This); DWORD WINAPI dd_Thread(IDirectDrawSurfaceImpl *This);
void dump_ddsd(DWORD); void dump_ddsd(DWORD);
void dump_ddscaps(DWORD); void dump_ddscaps(DWORD);
@ -246,7 +246,7 @@ struct IDirectDrawSurfaceImplVtbl siface =
null // ddraw_surface_UpdateOverlayZOrder null // ddraw_surface_UpdateOverlayZOrder
}; };
HRESULT ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lpDDSurface, IUnknown FAR * unkOuter) HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lpDDSurface, IUnknown FAR * unkOuter)
{ {
printf("DirectDraw::CreateSurface(This=%p, lpDDSurfaceDesc=%p, lpDDSurface=%p, unkOuter=%p)\n", This, lpDDSurfaceDesc, lpDDSurface, unkOuter); printf("DirectDraw::CreateSurface(This=%p, lpDDSurfaceDesc=%p, lpDDSurface=%p, unkOuter=%p)\n", This, lpDDSurfaceDesc, lpDDSurface, unkOuter);
@ -277,7 +277,7 @@ HRESULT ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC lpDDSurfaceDe
Surface->height = This->height; Surface->height = This->height;
Surface->hWnd = This->hWnd; Surface->hWnd = This->hWnd;
#if USE_OPENGL #if USE_OPENGL
Surface->dThread = CreateThread(NULL, 0, ogl_Thread, (void *)Surface, 0, NULL); Surface->dThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ogl_Thread, (void *)Surface, 0, NULL);
#else #else
Surface->dThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)dd_Thread, (void *)Surface, 0, NULL); Surface->dThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)dd_Thread, (void *)Surface, 0, NULL);
#endif #endif

View File

@ -21,7 +21,7 @@
#include "ddraw.h" #include "ddraw.h"
#include "palette.h" #include "palette.h"
HRESULT ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter); HRESULT __stdcall ddraw_CreateSurface(IDirectDrawImpl *This, LPDDSURFACEDESC DDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *DDSurface, IUnknown FAR * unkOuter);
struct IDirectDrawSurfaceImpl; struct IDirectDrawSurfaceImpl;
struct IDirectDrawSurfaceImplVtbl; struct IDirectDrawSurfaceImplVtbl;