2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2005-08-08 13:29:50 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2007-05-12 17:30:37 +00:00
|
|
|
* PROJECT: ReactOS DirectX
|
2015-09-27 14:00:29 +00:00
|
|
|
* FILE: dll/directx/ddraw/Ddraw/ddraw_main.c
|
2007-04-22 18:15:31 +00:00
|
|
|
* PURPOSE: IDirectDraw7 Implementation
|
2005-08-08 13:29:50 +00:00
|
|
|
* PROGRAMMER: Magnus Olsen, Maarten Bosma
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-06-16 16:42:50 +00:00
|
|
|
/* TODO
|
2007-10-19 23:21:45 +00:00
|
|
|
* add warper functions for dx 1 - 6
|
2007-06-16 16:42:50 +00:00
|
|
|
* map the DirectDraw4_Vtable, DirectDraw2_Vtable, DirectDraw_Vtable
|
|
|
|
* table to right version of the functions
|
|
|
|
*/
|
2006-07-24 18:29:02 +00:00
|
|
|
|
2007-06-23 09:57:34 +00:00
|
|
|
|
|
|
|
|
2007-05-15 16:18:30 +00:00
|
|
|
#include "rosdraw.h"
|
2006-07-24 18:29:02 +00:00
|
|
|
|
2007-06-09 17:24:32 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2007-06-23 09:57:34 +00:00
|
|
|
LPDDRAWI_DIRECTDRAW_INT
|
|
|
|
internal_directdraw_int_alloc(LPDDRAWI_DIRECTDRAW_INT This)
|
|
|
|
{
|
|
|
|
LPDDRAWI_DIRECTDRAW_INT newThis;
|
|
|
|
DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
|
|
|
|
if (newThis)
|
|
|
|
{
|
|
|
|
newThis->lpLcl = This->lpLcl;
|
|
|
|
newThis->lpLink = This;
|
|
|
|
}
|
|
|
|
|
|
|
|
return newThis;
|
|
|
|
}
|
|
|
|
|
2007-05-21 10:11:10 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_QueryInterface (LPDDRAWI_DIRECTDRAW_INT This,
|
2007-04-22 18:15:31 +00:00
|
|
|
REFIID id,
|
|
|
|
LPVOID *obj)
|
|
|
|
{
|
2007-06-07 02:23:54 +00:00
|
|
|
HRESULT retVal = DD_OK;
|
2006-11-05 21:19:53 +00:00
|
|
|
|
2006-12-13 21:28:52 +00:00
|
|
|
DX_WINDBG_trace();
|
2007-04-22 18:15:31 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-07-23 20:38:28 +00:00
|
|
|
{
|
2007-06-07 02:23:54 +00:00
|
|
|
/* FIXME
|
2016-11-12 21:53:33 +00:00
|
|
|
the D3D object can be obtained from here
|
2007-06-07 02:23:54 +00:00
|
|
|
Direct3D7
|
|
|
|
*/
|
|
|
|
if (IsEqualGUID(&IID_IDirectDraw7, id))
|
|
|
|
{
|
2007-06-16 22:05:16 +00:00
|
|
|
if (This->lpVtbl != &DirectDraw7_Vtable)
|
2007-06-16 19:38:20 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
This = internal_directdraw_int_alloc(This);
|
|
|
|
if (!This)
|
2007-06-16 22:05:16 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
retVal = DDERR_OUTOFVIDEOMEMORY;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-16 22:05:16 +00:00
|
|
|
}
|
2007-06-16 19:38:20 +00:00
|
|
|
}
|
2007-06-23 09:57:34 +00:00
|
|
|
|
|
|
|
This->lpVtbl = &DirectDraw7_Vtable;
|
|
|
|
*obj = This;
|
|
|
|
Main_DirectDraw_AddRef(This);
|
2007-06-07 02:23:54 +00:00
|
|
|
}
|
2007-06-16 16:42:50 +00:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw4, id))
|
|
|
|
{
|
2007-06-16 22:05:16 +00:00
|
|
|
if (This->lpVtbl != &DirectDraw4_Vtable)
|
2007-06-16 19:38:20 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
This = internal_directdraw_int_alloc(This);
|
|
|
|
if (!This)
|
2007-06-16 22:05:16 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
retVal = DDERR_OUTOFVIDEOMEMORY;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-16 22:05:16 +00:00
|
|
|
}
|
2007-06-16 19:38:20 +00:00
|
|
|
}
|
2007-06-23 09:57:34 +00:00
|
|
|
|
2007-12-10 20:29:51 +00:00
|
|
|
This->lpVtbl = &DirectDraw4_Vtable;
|
2007-06-23 09:57:34 +00:00
|
|
|
*obj = This;
|
|
|
|
Main_DirectDraw_AddRef(This);
|
2007-06-16 16:42:50 +00:00
|
|
|
}
|
2007-06-23 09:57:34 +00:00
|
|
|
|
2007-12-10 20:29:51 +00:00
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw2, id))
|
2007-06-16 16:42:50 +00:00
|
|
|
{
|
2007-12-10 20:29:51 +00:00
|
|
|
if (This->lpVtbl != &DirectDraw2_Vtable)
|
2007-06-16 19:38:20 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
This = internal_directdraw_int_alloc(This);
|
|
|
|
if (!This)
|
2007-06-16 22:05:16 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
retVal = DDERR_OUTOFVIDEOMEMORY;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-16 22:05:16 +00:00
|
|
|
}
|
2007-06-16 19:38:20 +00:00
|
|
|
}
|
2007-06-23 09:57:34 +00:00
|
|
|
|
|
|
|
This->lpVtbl = &DirectDraw2_Vtable;
|
|
|
|
*obj = This;
|
|
|
|
Main_DirectDraw_AddRef(This);
|
2007-06-16 16:42:50 +00:00
|
|
|
}
|
|
|
|
else if (IsEqualGUID(&IID_IDirectDraw, id))
|
|
|
|
{
|
2007-06-16 22:05:16 +00:00
|
|
|
if (This->lpVtbl != &DirectDraw_Vtable)
|
2007-06-16 19:38:20 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
This = internal_directdraw_int_alloc(This);
|
|
|
|
if (!This)
|
2007-06-16 22:05:16 +00:00
|
|
|
{
|
2007-06-23 09:57:34 +00:00
|
|
|
retVal = DDERR_OUTOFVIDEOMEMORY;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-16 22:05:16 +00:00
|
|
|
}
|
2007-06-16 19:38:20 +00:00
|
|
|
}
|
2007-06-23 09:57:34 +00:00
|
|
|
|
|
|
|
This->lpVtbl = &DirectDraw_Vtable;
|
|
|
|
*obj = This;
|
|
|
|
Main_DirectDraw_AddRef(This);
|
2007-06-16 16:42:50 +00:00
|
|
|
}
|
2007-06-07 02:23:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
*obj = NULL;
|
|
|
|
DX_STUB_str("E_NOINTERFACE");
|
|
|
|
retVal = E_NOINTERFACE;
|
|
|
|
}
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2006-07-23 20:38:28 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2006-12-13 21:28:52 +00:00
|
|
|
|
2007-06-07 02:23:54 +00:00
|
|
|
return retVal;
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
2006-12-13 21:28:52 +00:00
|
|
|
|
2009-10-24 14:09:48 +00:00
|
|
|
/*++
|
|
|
|
* @name DDraw->AddRef
|
|
|
|
* @implemented
|
|
|
|
*
|
|
|
|
* The function DDraw->AddRef manages all ref counters in the COM object DDraw->
|
|
|
|
|
|
|
|
* @return
|
|
|
|
* Returns the local Ref counter value for the COM object
|
|
|
|
*
|
|
|
|
* @remarks.
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
*--*/
|
2007-05-21 10:11:10 +00:00
|
|
|
ULONG WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_AddRef (LPDDRAWI_DIRECTDRAW_INT This)
|
2007-04-22 18:15:31 +00:00
|
|
|
{
|
2007-05-30 18:46:59 +00:00
|
|
|
ULONG retValue = 0;
|
2006-11-05 21:19:53 +00:00
|
|
|
|
2006-12-13 21:28:52 +00:00
|
|
|
DX_WINDBG_trace();
|
|
|
|
|
2009-10-24 14:09:48 +00:00
|
|
|
/* Lock the thread */
|
|
|
|
AcquireDDThreadLock();
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-12-13 21:28:52 +00:00
|
|
|
{
|
2009-10-24 14:09:48 +00:00
|
|
|
/* Increment the internal ref counter */
|
2006-12-13 21:28:52 +00:00
|
|
|
This->dwIntRefCnt++;
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/* Increment the local internal ref counter */
|
2006-12-13 21:28:52 +00:00
|
|
|
This->lpLcl->dwLocalRefCnt++;
|
|
|
|
|
|
|
|
if (This->lpLcl->lpGbl != NULL)
|
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
/* Increment the global internal ref counter */
|
2006-12-13 21:28:52 +00:00
|
|
|
This->lpLcl->lpGbl->dwRefCnt++;
|
|
|
|
}
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-30 18:46:59 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-05-30 18:46:59 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-30 18:46:59 +00:00
|
|
|
{
|
|
|
|
retValue = This->dwIntRefCnt;
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-30 18:46:59 +00:00
|
|
|
{
|
|
|
|
retValue = 0;
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-05-30 18:46:59 +00:00
|
|
|
|
2009-10-24 14:09:48 +00:00
|
|
|
/* Release the thread lock */
|
|
|
|
ReleaseDDThreadLock();
|
|
|
|
|
|
|
|
/* Return the local Ref counter */
|
2007-05-30 18:46:59 +00:00
|
|
|
return retValue;
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
|
|
|
|
2007-05-30 18:46:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-05-21 10:11:10 +00:00
|
|
|
ULONG WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_Release (LPDDRAWI_DIRECTDRAW_INT This)
|
2007-04-22 18:15:31 +00:00
|
|
|
{
|
2007-06-07 02:23:54 +00:00
|
|
|
ULONG Counter = 0;
|
2006-11-05 21:19:53 +00:00
|
|
|
|
2006-12-13 21:28:52 +00:00
|
|
|
DX_WINDBG_trace();
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/* Lock the thread */
|
|
|
|
AcquireDDThreadLock();
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2006-12-13 21:28:52 +00:00
|
|
|
{
|
2007-06-22 20:03:04 +00:00
|
|
|
if (This!=NULL)
|
2006-12-13 21:28:52 +00:00
|
|
|
{
|
2007-06-07 02:23:54 +00:00
|
|
|
This->lpLcl->dwLocalRefCnt--;
|
|
|
|
This->dwIntRefCnt--;
|
2006-12-13 21:28:52 +00:00
|
|
|
|
2007-06-07 02:23:54 +00:00
|
|
|
if (This->lpLcl->lpGbl != NULL)
|
|
|
|
{
|
|
|
|
This->lpLcl->lpGbl->dwRefCnt--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( This->lpLcl->lpGbl->dwRefCnt == 0)
|
2006-12-13 21:28:52 +00:00
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
// set resolution back to the one in registry
|
2007-06-07 02:23:54 +00:00
|
|
|
/*if(This->cooperative_level & DDSCL_EXCLUSIVE)
|
|
|
|
{
|
|
|
|
ChangeDisplaySettings(NULL, 0);
|
|
|
|
}*/
|
|
|
|
|
2007-06-22 20:03:04 +00:00
|
|
|
Cleanup(This);
|
2007-06-07 02:23:54 +00:00
|
|
|
}
|
2007-04-22 18:15:31 +00:00
|
|
|
|
2007-06-07 02:23:54 +00:00
|
|
|
/* FIXME cleanup being not call why ?? */
|
|
|
|
Counter = This->dwIntRefCnt;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Counter = This->dwIntRefCnt;
|
2006-12-13 21:28:52 +00:00
|
|
|
}
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-06-07 02:23:54 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/* Release the thread lock */
|
|
|
|
ReleaseDDThreadLock();
|
|
|
|
|
2007-06-07 02:23:54 +00:00
|
|
|
return Counter;
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
2006-07-24 18:29:02 +00:00
|
|
|
|
2009-10-24 14:09:48 +00:00
|
|
|
|
2007-05-21 10:11:10 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_Initialize (LPDDRAWI_DIRECTDRAW_INT This, LPGUID lpGUID)
|
2006-07-23 20:38:28 +00:00
|
|
|
{
|
2007-05-21 10:11:10 +00:00
|
|
|
return DDERR_ALREADYINITIALIZED;
|
2006-07-23 20:38:28 +00:00
|
|
|
}
|
|
|
|
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/*++
|
|
|
|
* @name DDraw->Compact
|
|
|
|
* @implemented
|
|
|
|
*
|
2016-11-12 21:53:33 +00:00
|
|
|
* In exclusive mode the function DDraw->Compact returns DERR_NOEXCLUSIVEMODE, otherwise it returns DD_OK
|
2009-10-24 14:09:48 +00:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* Returns only error code DD_OK or DERR_NOEXCLUSIVEMODE
|
|
|
|
*
|
|
|
|
* @remarks.
|
|
|
|
* Microsoft says Compact is not implemented in ddraw.dll, but it returns DDERR_NOEXCLUSIVEMODE or DD_OK
|
|
|
|
*
|
|
|
|
*--*/
|
2007-05-15 16:18:30 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_Compact(LPDDRAWI_DIRECTDRAW_INT This)
|
2007-05-15 16:18:30 +00:00
|
|
|
{
|
2007-05-30 18:26:56 +00:00
|
|
|
HRESULT retVal = DD_OK;
|
|
|
|
|
|
|
|
DX_WINDBG_trace();
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/* Lock the thread */
|
|
|
|
AcquireDDThreadLock();
|
2007-05-30 18:26:56 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-30 18:26:56 +00:00
|
|
|
{
|
2009-10-24 14:09:48 +00:00
|
|
|
/* Check if Exclusive mode has been activated */
|
2007-06-14 22:04:32 +00:00
|
|
|
if (This->lpLcl->lpGbl->lpExclusiveOwner != This->lpLcl)
|
2007-06-07 01:27:38 +00:00
|
|
|
{
|
|
|
|
retVal = DDERR_NOEXCLUSIVEMODE;
|
|
|
|
}
|
2007-05-30 18:26:56 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-06-07 01:27:38 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2009-10-24 14:09:48 +00:00
|
|
|
|
|
|
|
/* Release the thread lock */
|
|
|
|
ReleaseDDThreadLock();
|
|
|
|
|
2007-05-30 18:26:56 +00:00
|
|
|
return retVal;
|
2007-05-15 16:18:30 +00:00
|
|
|
}
|
2006-07-24 21:51:31 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_GetAvailableVidMem(LPDDRAWI_DIRECTDRAW_INT This, LPDDSCAPS ddscaps, LPDWORD dwTotal, LPDWORD dwFree)
|
2007-06-08 20:55:48 +00:00
|
|
|
{
|
|
|
|
DDSCAPS2 myddscaps;
|
|
|
|
HRESULT retValue = DD_OK;
|
|
|
|
|
|
|
|
ZeroMemory(&myddscaps, sizeof(DDSCAPS2));
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-06-08 20:55:48 +00:00
|
|
|
{
|
|
|
|
myddscaps.dwCaps = ddscaps->dwCaps;
|
2007-06-22 20:03:04 +00:00
|
|
|
retValue = Main_DirectDraw_GetAvailableVidMem4(This, &myddscaps, dwTotal, dwFree);
|
2007-06-08 20:55:48 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-06-08 20:55:48 +00:00
|
|
|
{
|
|
|
|
retValue = DDERR_INVALIDPARAMS;
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-06-08 20:55:48 +00:00
|
|
|
|
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_GetAvailableVidMem4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSCAPS2 ddscaps,
|
2007-05-20 22:48:19 +00:00
|
|
|
LPDWORD dwTotal, LPDWORD dwFree)
|
|
|
|
{
|
2007-06-07 01:00:52 +00:00
|
|
|
HRESULT retVal = DD_OK;
|
|
|
|
DDHAL_GETAVAILDRIVERMEMORYDATA memdata;
|
2007-06-22 20:03:04 +00:00
|
|
|
|
2007-05-20 22:48:19 +00:00
|
|
|
DX_WINDBG_trace();
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-20 22:48:19 +00:00
|
|
|
{
|
2016-11-12 21:53:33 +00:00
|
|
|
// There is no HEL implementation of this api
|
2007-06-08 17:12:05 +00:00
|
|
|
if (!(This->lpLcl->lpDDCB->HALDDMiscellaneous.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY) ||
|
|
|
|
(This->lpLcl->lpGbl->dwFlags & DDRAWI_NOHARDWARE) )
|
2007-06-07 01:00:52 +00:00
|
|
|
{
|
|
|
|
retVal = DDERR_NODIRECTDRAWHW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ((!dwTotal && !dwFree) || !ddscaps)
|
|
|
|
{
|
|
|
|
retVal = DDERR_INVALIDPARAMS;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-07 01:00:52 +00:00
|
|
|
}
|
2007-06-08 17:12:05 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if ( ddscaps->dwCaps & (DDSCAPS_BACKBUFFER | DDSCAPS_COMPLEX | DDSCAPS_FLIP |
|
2007-06-08 17:12:05 +00:00
|
|
|
DDSCAPS_FRONTBUFFER | DDSCAPS_PALETTE | DDSCAPS_SYSTEMMEMORY |
|
|
|
|
DDSCAPS_VISIBLE | DDSCAPS_WRITEONLY | DDSCAPS_OWNDC))
|
2007-06-07 01:00:52 +00:00
|
|
|
{
|
2007-06-08 17:12:05 +00:00
|
|
|
retVal = DDERR_INVALIDPARAMS;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-08 17:12:05 +00:00
|
|
|
}
|
2007-06-07 01:00:52 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-06-08 19:25:39 +00:00
|
|
|
/* ddscaps->dwCaps2 & 0x01
|
2007-10-19 23:21:45 +00:00
|
|
|
this flag is outdate and are
|
|
|
|
set to 0 in ms dxsdk the name of
|
2007-06-08 19:25:39 +00:00
|
|
|
this flag is DDSCAPS2_HARDWAREDEINTERLACE
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ddscaps->dwCaps2 & 0x01)
|
2007-06-08 17:12:05 +00:00
|
|
|
{
|
2007-06-08 19:25:39 +00:00
|
|
|
retVal = DDERR_INVALIDCAPS;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-08 17:12:05 +00:00
|
|
|
}
|
2007-06-08 12:57:00 +00:00
|
|
|
|
2007-06-08 20:55:48 +00:00
|
|
|
if ( ddscaps->dwCaps3 & ~( DDSCAPS3_MULTISAMPLE_QUALITY_MASK | DDSCAPS3_MULTISAMPLE_MASK |
|
|
|
|
DDSCAPS3_RESERVED1 | DDSCAPS3_RESERVED2 |
|
|
|
|
DDSCAPS3_LIGHTWEIGHTMIPMAP | DDSCAPS3_AUTOGENMIPMAP |
|
|
|
|
DDSCAPS3_DMAP))
|
2007-06-08 17:12:05 +00:00
|
|
|
{
|
2007-06-08 20:55:48 +00:00
|
|
|
retVal = DDERR_INVALIDCAPS;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-08 17:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( ddscaps->dwCaps4)
|
|
|
|
{
|
|
|
|
retVal = DDERR_INVALIDCAPS;
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_LEAVE;
|
2007-06-08 17:12:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ZeroMemory(&memdata, sizeof(DDHAL_GETAVAILDRIVERMEMORYDATA));
|
|
|
|
memdata.lpDD = This->lpLcl->lpGbl;
|
|
|
|
memdata.ddRVal = DDERR_INVALIDPARAMS;
|
|
|
|
|
|
|
|
memdata.ddsCapsEx.dwCaps2 = ddscaps->dwCaps2;
|
|
|
|
memdata.ddsCapsEx.dwCaps3 = ddscaps->dwCaps3;
|
|
|
|
|
|
|
|
This->lpLcl->lpGbl->hDD = This->lpLcl->hDD;
|
|
|
|
|
|
|
|
if (This->lpLcl->lpDDCB->HALDDMiscellaneous.GetAvailDriverMemory(&memdata) == DDHAL_DRIVER_NOTHANDLED)
|
|
|
|
{
|
|
|
|
retVal = DDERR_NODIRECTDRAWHW;
|
2007-06-08 20:55:48 +00:00
|
|
|
|
|
|
|
if (dwTotal)
|
|
|
|
*dwTotal = 0;
|
|
|
|
|
|
|
|
if (dwFree)
|
|
|
|
*dwFree = 0;
|
2007-06-08 17:12:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (dwTotal)
|
|
|
|
*dwTotal = memdata.dwTotal;
|
2007-06-07 01:00:52 +00:00
|
|
|
|
2007-06-08 17:12:05 +00:00
|
|
|
if (dwFree)
|
|
|
|
*dwFree = memdata.dwFree;
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-06-08 17:12:05 +00:00
|
|
|
retVal = memdata.ddRVal;
|
2007-06-07 01:00:52 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-20 22:48:19 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-20 22:48:19 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-05-20 22:48:19 +00:00
|
|
|
|
2007-06-07 13:19:56 +00:00
|
|
|
return retVal;
|
2007-05-20 22:48:19 +00:00
|
|
|
}
|
|
|
|
|
2007-05-21 15:47:39 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_GetFourCCCodes(LPDDRAWI_DIRECTDRAW_INT This, LPDWORD lpNumCodes, LPDWORD lpCodes)
|
2007-05-21 15:47:39 +00:00
|
|
|
{
|
2007-05-21 20:51:55 +00:00
|
|
|
HRESULT retVal = DD_OK;
|
|
|
|
|
2007-05-21 15:47:39 +00:00
|
|
|
DX_WINDBG_trace();
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-05-22 10:46:17 +00:00
|
|
|
// EnterCriticalSection(&ddcs);
|
2007-05-21 16:23:43 +00:00
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-21 20:51:55 +00:00
|
|
|
{
|
2007-05-22 10:46:17 +00:00
|
|
|
if(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD)))
|
|
|
|
{
|
|
|
|
retVal = DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-07 01:00:52 +00:00
|
|
|
if(!(IsBadWritePtr(lpNumCodes,sizeof(LPDWORD))))
|
2007-05-22 10:46:17 +00:00
|
|
|
{
|
2007-06-07 01:00:52 +00:00
|
|
|
DWORD size;
|
|
|
|
|
|
|
|
if (*lpNumCodes > This->lpLcl->lpGbl->dwNumFourCC)
|
|
|
|
{
|
|
|
|
*lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = *lpNumCodes * sizeof(DWORD);
|
|
|
|
|
|
|
|
if(!IsBadWritePtr(lpCodes, size ))
|
|
|
|
{
|
|
|
|
memcpy(lpCodes, This->lpLcl->lpGbl->lpdwFourCC, size );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*lpNumCodes = This->lpLcl->lpGbl->dwNumFourCC;
|
|
|
|
}
|
2007-05-22 10:46:17 +00:00
|
|
|
}
|
|
|
|
}
|
2007-05-21 20:51:55 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-21 20:51:55 +00:00
|
|
|
{
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-05-21 16:23:43 +00:00
|
|
|
|
2007-05-22 10:46:17 +00:00
|
|
|
//LeaveCriticalSection(&ddcs);
|
2007-05-21 20:51:55 +00:00
|
|
|
return retVal;
|
2007-05-21 15:47:39 +00:00
|
|
|
}
|
|
|
|
|
2007-05-28 17:53:02 +00:00
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
/*
|
2016-11-12 21:53:33 +00:00
|
|
|
* We can obtain the version of the directdraw object by compare the
|
2007-10-19 23:21:45 +00:00
|
|
|
* vtl table pointer from iface we do not need pass which version
|
2007-05-28 17:53:02 +00:00
|
|
|
* we whant to use
|
|
|
|
*
|
|
|
|
* Main_DirectDraw_CreateSurface is dead at moment we do only support
|
2007-10-19 23:21:45 +00:00
|
|
|
* directdraw 7 at moment
|
2007-05-28 17:53:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* For DirectDraw 1 - 3 */
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_CreateSurface (LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC pDDSD,
|
2007-12-13 02:02:15 +00:00
|
|
|
LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
|
2007-05-12 15:50:26 +00:00
|
|
|
{
|
2007-05-28 17:53:02 +00:00
|
|
|
HRESULT ret = DDERR_GENERIC;
|
2007-05-12 17:23:48 +00:00
|
|
|
DDSURFACEDESC2 dd_desc_v2;
|
|
|
|
|
|
|
|
DX_WINDBG_trace();
|
|
|
|
|
2007-12-27 18:51:27 +00:00
|
|
|
EnterCriticalSection(&ddcs);
|
2007-12-15 21:25:39 +00:00
|
|
|
*ppSurf = NULL;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2007-05-29 13:36:03 +00:00
|
|
|
if (pDDSD->dwSize == sizeof(DDSURFACEDESC))
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2007-05-29 13:36:03 +00:00
|
|
|
CopyDDSurfDescToDDSurfDesc2(&dd_desc_v2, (LPDDSURFACEDESC)pDDSD);
|
2007-06-22 20:03:04 +00:00
|
|
|
ret = Internal_CreateSurface(This,
|
2007-05-29 13:36:03 +00:00
|
|
|
&dd_desc_v2,
|
2007-12-13 02:02:15 +00:00
|
|
|
ppSurf,
|
2007-05-29 13:36:03 +00:00
|
|
|
pUnkOuter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = DDERR_INVALIDPARAMS;
|
2007-05-28 17:53:02 +00:00
|
|
|
}
|
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2007-06-18 14:58:44 +00:00
|
|
|
ret = DDERR_INVALIDPARAMS;
|
2007-05-28 17:53:02 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-12-27 18:51:27 +00:00
|
|
|
LeaveCriticalSection(&ddcs);
|
|
|
|
return ret;
|
2007-05-12 15:50:26 +00:00
|
|
|
}
|
|
|
|
|
2007-05-12 18:33:28 +00:00
|
|
|
|
2007-05-28 17:53:02 +00:00
|
|
|
/* For DirectDraw 4 - 7 */
|
2007-10-19 23:21:45 +00:00
|
|
|
HRESULT WINAPI
|
2007-06-22 20:03:04 +00:00
|
|
|
Main_DirectDraw_CreateSurface4(LPDDRAWI_DIRECTDRAW_INT This, LPDDSURFACEDESC2 pDDSD,
|
2007-12-13 02:02:15 +00:00
|
|
|
LPDDRAWI_DDRAWSURFACE_INT *ppSurf, IUnknown *pUnkOuter)
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2008-01-24 20:40:57 +00:00
|
|
|
HRESULT ret = DD_OK;
|
2007-05-28 17:53:02 +00:00
|
|
|
DX_WINDBG_trace();
|
2007-12-27 18:51:27 +00:00
|
|
|
|
|
|
|
EnterCriticalSection(&ddcs);
|
2007-12-15 21:25:39 +00:00
|
|
|
*ppSurf = NULL;
|
|
|
|
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_TRY
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2007-12-13 02:02:15 +00:00
|
|
|
ret = Internal_CreateSurface(This, pDDSD, ppSurf, pUnkOuter);
|
2007-05-29 13:36:03 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
2007-05-28 17:53:02 +00:00
|
|
|
{
|
2007-06-18 14:58:44 +00:00
|
|
|
ret = DDERR_INVALIDPARAMS;
|
2007-05-28 17:53:02 +00:00
|
|
|
}
|
2008-11-30 19:28:11 +00:00
|
|
|
_SEH2_END;
|
2007-05-28 17:53:02 +00:00
|
|
|
|
2010-11-30 16:29:49 +00:00
|
|
|
if(*ppSurf != NULL)
|
|
|
|
Main_DirectDraw_AddRef(This);
|
|
|
|
|
2007-12-27 18:51:27 +00:00
|
|
|
LeaveCriticalSection(&ddcs);
|
2007-05-28 17:53:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2007-06-08 23:32:13 +00:00
|
|
|
|
2016-11-12 21:53:33 +00:00
|
|
|
/* 5 of 31 DirectDraw7_Vtable api are working similar to windows */
|
2007-06-08 23:32:13 +00:00
|
|
|
/* 8 of 31 DirectDraw7_Vtable api are under devloping / testing */
|
|
|
|
|
2010-11-30 16:29:49 +00:00
|
|
|
HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDDRAWI_DIRECTDRAW_INT This, DWORD dwFlags,
|
|
|
|
LPPALETTEENTRY palent, LPDIRECTDRAWPALETTE* ppPalette, LPUNKNOWN pUnkOuter)
|
|
|
|
{
|
|
|
|
HRESULT ret = DD_OK;
|
|
|
|
DX_WINDBG_trace();
|
|
|
|
|
|
|
|
EnterCriticalSection(&ddcs);
|
|
|
|
*ppPalette = NULL;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ret = Internal_CreatePalette(This, dwFlags, palent, ppPalette, pUnkOuter);
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
ret = DDERR_INVALIDPARAMS;
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
|
|
|
|
//Versions 7 and 4 are addref'ed
|
|
|
|
if((This->lpVtbl == &DirectDraw7_Vtable || This->lpVtbl == &DirectDraw4_Vtable) && *ppPalette != NULL)
|
|
|
|
Main_DirectDraw_AddRef(This) ;
|
2007-06-22 19:34:06 +00:00
|
|
|
|
2010-11-30 16:29:49 +00:00
|
|
|
LeaveCriticalSection(&ddcs);
|
|
|
|
return ret;
|
|
|
|
}
|
2007-06-22 19:34:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-06-16 16:42:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-12-13 02:02:15 +00:00
|
|
|
|