2010-02-26 11:43:19 +00:00
|
|
|
#pragma once
|
2005-08-08 13:29:50 +00:00
|
|
|
|
|
|
|
/********* Includes *********/
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <ddraw.h>
|
2005-12-01 21:37:19 +00:00
|
|
|
#include <ddrawi.h>
|
|
|
|
#include <d3dhal.h>
|
2005-08-08 13:29:50 +00:00
|
|
|
#include <ddrawgdi.h>
|
2009-10-24 14:09:48 +00:00
|
|
|
#include <pseh/pseh.h>
|
2005-10-23 15:24:56 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
#include <pseh/pseh2.h>
|
2008-11-24 13:00:20 +00:00
|
|
|
|
2007-05-13 08:38:22 +00:00
|
|
|
#include "Ddraw/ddraw.h"
|
|
|
|
#include "Surface/surface.h"
|
2007-06-07 11:49:43 +00:00
|
|
|
#include "Clipper/clipper.h"
|
2006-11-19 19:13:35 +00:00
|
|
|
|
2007-11-27 21:32:59 +00:00
|
|
|
#include "resource.h"
|
|
|
|
|
2006-07-23 10:21:30 +00:00
|
|
|
/* DirectDraw startup code only internal use */
|
2006-11-19 19:13:35 +00:00
|
|
|
extern DDRAWI_DIRECTDRAW_GBL ddgbl;
|
|
|
|
extern DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
|
2007-04-22 18:15:31 +00:00
|
|
|
extern WCHAR classname[128];
|
|
|
|
extern WNDCLASSW wnd_class;
|
2007-05-12 15:52:09 +00:00
|
|
|
extern CRITICAL_SECTION ddcs;
|
2007-05-13 16:51:15 +00:00
|
|
|
extern IDirectDraw7Vtbl DirectDraw7_Vtable;
|
2007-06-22 19:34:06 +00:00
|
|
|
extern IDirectDraw4Vtbl DirectDraw4_Vtable;
|
|
|
|
extern IDirectDraw2Vtbl DirectDraw2_Vtable;
|
|
|
|
extern IDirectDrawVtbl DirectDraw_Vtable;
|
2006-11-19 19:13:35 +00:00
|
|
|
|
2007-06-22 19:34:06 +00:00
|
|
|
|
|
|
|
extern IDirectDrawSurface7Vtbl DirectDrawSurface7_Vtable;
|
2007-12-12 15:01:25 +00:00
|
|
|
extern IDirectDrawSurface4Vtbl DirectDrawSurface4_Vtable;
|
|
|
|
extern IDirectDrawSurface3Vtbl DirectDrawSurface3_Vtable;
|
|
|
|
extern IDirectDrawSurface2Vtbl DirectDrawSurface2_Vtable;
|
|
|
|
extern IDirectDrawSurfaceVtbl DirectDrawSurface_Vtable;
|
2010-11-30 16:29:49 +00:00
|
|
|
extern const IDirectDrawPaletteVtbl DirectDrawPalette_Vtable;
|
2007-06-22 19:34:06 +00:00
|
|
|
extern IDirectDrawClipperVtbl DirectDrawClipper_Vtable;
|
|
|
|
extern IDirectDrawColorControlVtbl DirectDrawColorControl_Vtable;
|
|
|
|
extern IDirectDrawGammaControlVtbl DirectDrawGammaControl_Vtable;
|
|
|
|
extern IDirectDrawKernelVtbl DirectDrawKernel_Vtable;
|
|
|
|
extern IDirectDrawSurfaceKernelVtbl DirectDrawSurfaceKernel_Vtable;
|
|
|
|
|
2007-12-13 12:31:05 +00:00
|
|
|
extern IDirect3DVtbl IDirect3D_Vtbl;
|
|
|
|
extern IDirect3D2Vtbl IDirect3D2_Vtbl;
|
|
|
|
extern IDirect3D3Vtbl IDirect3D3_Vtbl;
|
|
|
|
extern IDirect3D7Vtbl IDirect3D7_Vtbl;
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/* Start up direct hal or hel
|
|
|
|
* iface = a pointer to the com object
|
2016-11-12 21:53:33 +00:00
|
|
|
* pGUID = guid hardware accelerations or software acceleration this can be NULL
|
2007-10-19 23:21:45 +00:00
|
|
|
* reenable = FALSE if we whant create a new directdraw com
|
2007-06-22 19:34:06 +00:00
|
|
|
* = TRUE if we really whant rebuild the whole com interface (not in use)
|
|
|
|
*/
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 19:34:06 +00:00
|
|
|
StartDirectDraw(
|
|
|
|
LPDIRECTDRAW iface,
|
|
|
|
LPGUID pGUID,
|
|
|
|
BOOL reenable);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/* iface = a pointer to the com object
|
|
|
|
* reenable = FALSE / TRUE rebuld dx hal interface, this is need if we doing a mode change
|
2007-06-22 19:34:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
StartDirectDrawHal(
|
|
|
|
LPDIRECTDRAW iface,
|
|
|
|
BOOL reenable);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/* iface = a pointer to the com object
|
|
|
|
* reenable = FALSE / TRUE rebuld dx hel interface, this is need if we doing a mode change
|
2007-06-22 19:34:06 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
StartDirectDrawHel(
|
|
|
|
LPDIRECTDRAW iface,
|
|
|
|
BOOL reenable);
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
Create_DirectDraw (
|
|
|
|
LPGUID pGUID,
|
|
|
|
LPDIRECTDRAW* pIface,
|
|
|
|
REFIID id,
|
|
|
|
BOOL ex);
|
|
|
|
|
|
|
|
HRESULT WINAPI
|
|
|
|
ReCreateDirectDraw(LPDIRECTDRAW iface);
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT
|
2007-06-22 19:34:06 +00:00
|
|
|
Internal_CreateSurface(
|
|
|
|
LPDDRAWI_DIRECTDRAW_INT pDDraw,
|
2007-10-19 23:21:45 +00:00
|
|
|
LPDDSURFACEDESC2 pDDSD,
|
2007-12-13 02:02:15 +00:00
|
|
|
LPDDRAWI_DDRAWSURFACE_INT *ppSurf,
|
2007-06-22 19:34:06 +00:00
|
|
|
IUnknown *pUnkOuter);
|
2006-12-03 21:11:40 +00:00
|
|
|
|
2010-11-30 16:29:49 +00:00
|
|
|
HRESULT
|
|
|
|
Internal_CreatePalette( LPDDRAWI_DIRECTDRAW_INT pDDraw, DWORD dwFlags,
|
|
|
|
LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter);
|
|
|
|
|
2007-05-12 17:48:27 +00:00
|
|
|
/* convert DDSURFACEDESC to DDSURFACEDESC2 */
|
|
|
|
void CopyDDSurfDescToDDSurfDesc2(LPDDSURFACEDESC2 dst_pDesc, LPDDSURFACEDESC src_pDesc);
|
|
|
|
|
2006-07-23 15:37:57 +00:00
|
|
|
/* DirectDraw Cleanup code only internal use */
|
2007-06-22 20:03:04 +00:00
|
|
|
VOID Cleanup(LPDDRAWI_DIRECTDRAW_INT iface);
|
2006-07-23 15:37:57 +00:00
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
/* own macro to alloc memory */
|
2007-06-02 14:42:43 +00:00
|
|
|
|
|
|
|
/*
|
2007-04-22 13:54:34 +00:00
|
|
|
#define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m)
|
2006-12-14 09:20:00 +00:00
|
|
|
#define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); \
|
|
|
|
p = NULL;
|
2007-06-02 14:42:43 +00:00
|
|
|
*/
|
2007-06-02 15:09:52 +00:00
|
|
|
#define DxHeapMemAlloc(p, m) { \
|
2007-06-07 10:33:04 +00:00
|
|
|
p = malloc(m); \
|
|
|
|
if (p != NULL) \
|
|
|
|
{ \
|
|
|
|
ZeroMemory(p,m); \
|
|
|
|
} \
|
2007-06-02 15:09:52 +00:00
|
|
|
}
|
|
|
|
#define DxHeapMemFree(p) { \
|
|
|
|
free(p); \
|
|
|
|
p = NULL; \
|
|
|
|
}
|
2006-12-14 09:20:00 +00:00
|
|
|
|
2005-08-08 13:29:50 +00:00
|
|
|
/******** Main Object ********/
|
|
|
|
|
2006-07-23 19:57:36 +00:00
|
|
|
/* Public interface */
|
2011-03-13 20:56:27 +00:00
|
|
|
VOID WINAPI AcquireDDThreadLock(VOID);
|
|
|
|
VOID WINAPI ReleaseDDThreadLock(VOID);
|
2006-11-05 21:19:53 +00:00
|
|
|
|
2006-11-19 19:13:35 +00:00
|
|
|
ULONG WINAPI DirectDrawClipper_AddRef (LPDIRECTDRAWCLIPPER iface);
|
|
|
|
HRESULT WINAPI DirectDrawClipper_Initialize( LPDIRECTDRAWCLIPPER iface, LPDIRECTDRAW lpDD, DWORD dwFlags);
|
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
typedef struct DDRAWI_DDCOLORCONTROL_INT
|
2006-05-01 10:04:59 +00:00
|
|
|
{
|
2006-11-19 19:13:35 +00:00
|
|
|
LPVOID lpVtbl;
|
|
|
|
LPVOID lpLcl;
|
|
|
|
LPVOID lpLink;
|
|
|
|
DWORD dwIntRefCnt;
|
|
|
|
} DDRAWI_DDCOLORCONTROL_INT, *LPDDRAWI_DDCOLORCONTROL_INT;
|
2006-05-01 10:04:59 +00:00
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
typedef struct _DDRAWI_DDGAMMACONTROL_INT
|
2006-05-01 10:04:59 +00:00
|
|
|
{
|
2006-11-19 19:13:35 +00:00
|
|
|
LPVOID lpVtbl;
|
|
|
|
LPVOID lpLcl;
|
|
|
|
LPVOID lpLink;
|
|
|
|
DWORD dwIntRefCnt;
|
|
|
|
} DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT;
|
2006-05-01 10:04:59 +00:00
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
typedef struct _DDRAWI_DDKERNEL_INT
|
2006-11-19 19:13:35 +00:00
|
|
|
{
|
|
|
|
LPVOID lpVtbl;
|
|
|
|
LPVOID lpLcl;
|
|
|
|
LPVOID lpLink;
|
|
|
|
DWORD dwIntRefCnt;
|
|
|
|
} DDRAWI_KERNEL_INT, *LPDDRAWI_KERNEL_INT;
|
2006-05-01 10:04:59 +00:00
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
typedef struct _DDRAWI_DDKERNELSURFACE_INT
|
2006-05-01 10:04:59 +00:00
|
|
|
{
|
2006-11-19 19:13:35 +00:00
|
|
|
LPVOID lpVtbl;
|
|
|
|
LPVOID lpLcl;
|
|
|
|
LPVOID lpLink;
|
|
|
|
DWORD dwIntRefCnt;
|
|
|
|
} _DDRAWI_DDKERNELSURFACE_INT, *LPDDRAWI_DDKERNELSURFACE_INT;
|
|
|
|
|
|
|
|
/* now to real info that are for private use and are our own */
|
2006-05-01 10:04:59 +00:00
|
|
|
|
|
|
|
|
2006-11-19 19:13:35 +00:00
|
|
|
|
2005-10-24 16:29:36 +00:00
|
|
|
|
|
|
|
|
2007-06-22 19:34:06 +00:00
|
|
|
|
|
|
|
|
2005-08-08 13:29:50 +00:00
|
|
|
|
|
|
|
/********* Prototypes **********/
|
2007-05-12 16:21:50 +00:00
|
|
|
VOID Hal_DirectDraw_Release (LPDIRECTDRAW7);
|
2006-04-09 11:53:23 +00:00
|
|
|
|
2006-04-04 11:49:55 +00:00
|
|
|
/* Setting for HEL should be move to ros special reg key ? */
|
|
|
|
|
|
|
|
/* setup how much graphic memory should hel be limit, set it now to 64MB */
|
|
|
|
#define HEL_GRAPHIC_MEMORY_MAX 67108864
|
2005-10-30 01:06:56 +00:00
|
|
|
|
2005-10-23 17:53:19 +00:00
|
|
|
/*********** Macros ***********/
|
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
/*
|
|
|
|
use this macro to close
|
2016-11-12 21:53:33 +00:00
|
|
|
down the debugger text complete
|
2006-12-02 08:30:16 +00:00
|
|
|
no debuging at all, it will
|
2016-11-12 21:53:33 +00:00
|
|
|
crash ms debugger in VS
|
2006-12-02 08:30:16 +00:00
|
|
|
*/
|
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
//#define DX_WINDBG_trace()
|
2006-12-02 08:30:16 +00:00
|
|
|
//#define DX_STUB
|
2007-04-22 13:54:34 +00:00
|
|
|
//#define DX_STUB_DD_OK return DD_OK;
|
|
|
|
//#define DX_STUB_str(x)
|
2006-12-02 08:30:16 +00:00
|
|
|
//#define DX_WINDBG_trace_res
|
|
|
|
|
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
/*
|
2016-11-12 21:53:33 +00:00
|
|
|
Use this macro if you want debug in visual studio or
|
2006-12-02 08:30:16 +00:00
|
|
|
if you have a program to look at the _INT struct from
|
|
|
|
ReactOS ddraw.dll or ms ddraw.dll, so you can see what
|
|
|
|
value ms are being setup.
|
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
This macro will create allot warnings and can not be help when you compile
|
2006-12-02 08:30:16 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
//#define DX_WINDBG_trace()
|
2006-12-02 10:27:56 +00:00
|
|
|
//#define DX_STUB
|
2007-04-22 13:54:34 +00:00
|
|
|
//#define DX_STUB_DD_OK return DD_OK;
|
2006-12-02 10:27:56 +00:00
|
|
|
//#define DX_STUB_str(x) printf("%s",x);
|
|
|
|
//#define DX_WINDBG_trace_res
|
2006-12-02 08:30:16 +00:00
|
|
|
|
2007-04-22 13:54:34 +00:00
|
|
|
/*
|
2006-12-02 08:30:16 +00:00
|
|
|
use this if want doing a trace from a program
|
|
|
|
like a game and ReactOS ddraw.dll in windows
|
2007-04-22 13:54:34 +00:00
|
|
|
so you can figout what going wrong and what
|
2006-12-02 08:30:16 +00:00
|
|
|
api are being call or if it hel or is it hal
|
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
This marco does not create warnings when you compile
|
2006-12-02 08:30:16 +00:00
|
|
|
*/
|
|
|
|
|
2006-12-02 10:27:56 +00:00
|
|
|
#define DX_STUB \
|
|
|
|
{ \
|
|
|
|
static BOOL firstcall = TRUE; \
|
|
|
|
if (firstcall) \
|
|
|
|
{ \
|
|
|
|
char buffer[1024]; \
|
|
|
|
sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
|
|
|
|
OutputDebugStringA(buffer); \
|
|
|
|
firstcall = FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
2007-04-22 13:54:34 +00:00
|
|
|
return DDERR_UNSUPPORTED;
|
|
|
|
|
2006-12-13 21:48:35 +00:00
|
|
|
|
|
|
|
|
2006-12-02 10:27:56 +00:00
|
|
|
#define DX_STUB_DD_OK \
|
|
|
|
{ \
|
|
|
|
static BOOL firstcall = TRUE; \
|
|
|
|
if (firstcall) \
|
|
|
|
{ \
|
|
|
|
char buffer[1024]; \
|
|
|
|
sprintf ( buffer, "Function %s is not implemented yet (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
|
|
|
|
OutputDebugStringA(buffer); \
|
|
|
|
firstcall = FALSE; \
|
|
|
|
} \
|
|
|
|
} \
|
2007-04-22 13:54:34 +00:00
|
|
|
return DD_OK;
|
|
|
|
|
2007-06-22 19:34:06 +00:00
|
|
|
|
2007-11-27 21:32:59 +00:00
|
|
|
#if 1
|
2007-06-22 19:34:06 +00:00
|
|
|
#define DX_STUB_str(x) \
|
|
|
|
{ \
|
2006-12-02 10:27:56 +00:00
|
|
|
char buffer[1024]; \
|
2007-06-22 19:34:06 +00:00
|
|
|
sprintf ( buffer, "Function %s %s (%s:%d)\n", __FUNCTION__,x,__FILE__,__LINE__ ); \
|
|
|
|
OutputDebugStringA(buffer); \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define DX_WINDBG_trace() \
|
|
|
|
static BOOL firstcallx = TRUE; \
|
|
|
|
if (firstcallx) \
|
|
|
|
{ \
|
|
|
|
char buffer[1024]; \
|
|
|
|
sprintf ( buffer, "Enter Function %s (%s:%d)\n", __FUNCTION__,__FILE__,__LINE__ ); \
|
|
|
|
OutputDebugStringA(buffer); \
|
|
|
|
firstcallx = TRUE; \
|
2006-12-02 10:27:56 +00:00
|
|
|
}
|
|
|
|
|
2007-06-15 10:21:54 +00:00
|
|
|
|
2007-06-24 17:29:03 +00:00
|
|
|
#define DX_WINDBG_trace_res(width,height,bpp, freq) \
|
2007-12-08 13:40:07 +00:00
|
|
|
static BOOL firstcallxx = TRUE; \
|
|
|
|
if (firstcallxx) \
|
|
|
|
{ \
|
|
|
|
char buffer[1024]; \
|
2008-01-24 20:40:57 +00:00
|
|
|
sprintf ( buffer, "Setmode have been req width=%ld, height=%ld bpp=%ld freq = %ld\n",width,height,bpp, freq); \
|
2007-12-08 13:40:07 +00:00
|
|
|
OutputDebugStringA(buffer); \
|
|
|
|
firstcallxx = TRUE; \
|
|
|
|
}
|
2007-06-24 17:29:03 +00:00
|
|
|
#else
|
2007-06-15 10:21:54 +00:00
|
|
|
#define DX_WINDBG_trace() //
|
2007-06-24 17:29:03 +00:00
|
|
|
#define DX_WINDBG_trace_res(width,height,bpp, freq) \\
|
2007-06-22 19:34:06 +00:00
|
|
|
|
2007-06-24 17:29:03 +00:00
|
|
|
#define DX_STUB_str(x) //
|
2007-06-22 19:34:06 +00:00
|
|
|
|
2007-06-24 17:29:03 +00:00
|
|
|
#endif
|