Author: greatlrd Date: Sun Apr 22 17:54:34 2007 New Revision: 26461
URL: http://svn.reactos.org/svn/reactos?rev=26461&view=rev Log: This commit break ddraw.dll it does not working any longer can not execlute a program. it is part of cleanup of the startup process of dx interface.
Modified: trunk/reactos/dll/directx/ddraw/iface_clipper.c trunk/reactos/dll/directx/ddraw/iface_color.c trunk/reactos/dll/directx/ddraw/iface_gamma.c trunk/reactos/dll/directx/ddraw/iface_kernel.c trunk/reactos/dll/directx/ddraw/iface_palette.c trunk/reactos/dll/directx/ddraw/iface_videoport.c trunk/reactos/dll/directx/ddraw/main.c trunk/reactos/dll/directx/ddraw/main/ddraw_main.c trunk/reactos/dll/directx/ddraw/rosdraw.h trunk/reactos/dll/directx/ddraw/startup.c
Modified: trunk/reactos/dll/directx/ddraw/iface_clipper.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_cli... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_clipper.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_clipper.c Sun Apr 22 17:54:34 2007 @@ -14,34 +14,17 @@ ULONG WINAPI DirectDrawClipper_Release(LPDIRECTDRAWCLIPPER iface) { - LPDDRAWI_DDRAWCLIPPER_INT This = (LPDDRAWI_DDRAWCLIPPER_INT)iface; - - DX_WINDBG_trace(); - /* FIXME - This is not right exiame how it should be done - */ - DX_STUB_str("FIXME This is not right exiame how it should be done\n"); - return This->dwIntRefCnt; + DX_WINDBG_trace(); + + DX_STUB; }
ULONG WINAPI DirectDrawClipper_AddRef (LPDIRECTDRAWCLIPPER iface) { - LPDDRAWI_DDRAWCLIPPER_INT This = (LPDDRAWI_DDRAWCLIPPER_INT)iface; + DX_WINDBG_trace();
- DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt++; - This->lpLcl->dwLocalRefCnt++; - - if (This->lpLcl->lpGbl != NULL) - { - This->lpLcl->lpGbl->dwRefCnt++; - } - } - return This->dwIntRefCnt; + DX_STUB; }
HRESULT WINAPI
Modified: trunk/reactos/dll/directx/ddraw/iface_color.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_col... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_color.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_color.c Sun Apr 22 17:54:34 2007 @@ -13,22 +13,9 @@ ULONG WINAPI DirectDrawColorControl_AddRef( LPDIRECTDRAWCOLORCONTROL iface) { - LPDDRAWI_DDCOLORCONTROL_INT This = (LPDDRAWI_DDCOLORCONTROL_INT)iface; + DX_WINDBG_trace();
- DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt++; - // This->lpLcl->dwLocalRefCnt++; - - - //if (This->lpLcl->lpGbl != NULL) - //{ - // This->lpLcl->lpGbl->dwRefCnt++; - //} - } - return This->dwIntRefCnt; + DX_STUB; }
ULONG WINAPI
Modified: trunk/reactos/dll/directx/ddraw/iface_gamma.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_gam... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_gamma.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_gamma.c Sun Apr 22 17:54:34 2007 @@ -13,21 +13,9 @@ ULONG WINAPI DirectDrawGammaControl_AddRef( LPDIRECTDRAWGAMMACONTROL iface) { - LPDDRAWI_DDGAMMACONTROL_INT This = (LPDDRAWI_DDGAMMACONTROL_INT)iface; - - DX_WINDBG_trace(); + DX_WINDBG_trace();
- if (iface!=NULL) - { - This->dwIntRefCnt++; - //This->lpLcl->dwLocalRefCnt++; - - //if (This->lpLcl->lpGbl != NULL) - //{ - // This->lpLcl->lpGbl->dwRefCnt++; - //} - } - return This->dwIntRefCnt; + DX_STUB; }
ULONG WINAPI
Modified: trunk/reactos/dll/directx/ddraw/iface_kernel.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_ker... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_kernel.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_kernel.c Sun Apr 22 17:54:34 2007 @@ -16,47 +16,17 @@ ULONG WINAPI DirectDrawKernel_AddRef ( LPDIRECTDRAWKERNEL iface) { - - LPDDRAWI_KERNEL_INT This = (LPDDRAWI_KERNEL_INT)iface; - - ULONG ref=0; - DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt++; - ref = This->dwIntRefCnt; - } - return ref; + DX_WINDBG_trace(); + + DX_STUB; }
ULONG WINAPI DirectDrawKernel_Release ( LPDIRECTDRAWKERNEL iface) { - LPDDRAWI_KERNEL_INT This = (LPDDRAWI_KERNEL_INT)iface; - ULONG ref=0; + DX_WINDBG_trace();
- DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt--; - - if (This->dwIntRefCnt == 0) - { - /* Add here if we need releae some memory pointer before - * exists - */ - - if (This!=NULL) - { - HeapFree(GetProcessHeap(), 0, This); - } - } - - ref = This->dwIntRefCnt; - } - return ref; + DX_STUB; }
HRESULT WINAPI
Modified: trunk/reactos/dll/directx/ddraw/iface_palette.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_pal... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_palette.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_palette.c Sun Apr 22 17:54:34 2007 @@ -13,34 +13,17 @@ ULONG WINAPI DirectDrawPalette_Release( LPDIRECTDRAWPALETTE iface) { - LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; + DX_WINDBG_trace();
- DX_WINDBG_trace(); - /* FIXME - This is not right exiame how it should be done - */ - DX_STUB_str("FIXME This is not right exiame how it should be done\n"); - return This->dwIntRefCnt; + DX_STUB; }
ULONG WINAPI DirectDrawPalette_AddRef( LPDIRECTDRAWPALETTE iface) { - LPDDRAWI_DDRAWPALETTE_INT This = (LPDDRAWI_DDRAWPALETTE_INT)iface; + DX_WINDBG_trace();
- DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt++; - This->lpLcl->dwLocalRefCnt++; - - if (This->lpLcl->lpGbl != NULL) - { - This->lpLcl->lpGbl->dwRefCnt++; - } - } - return This->dwIntRefCnt; + DX_STUB; }
HRESULT WINAPI
Modified: trunk/reactos/dll/directx/ddraw/iface_videoport.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/iface_vid... ============================================================================== --- trunk/reactos/dll/directx/ddraw/iface_videoport.c (original) +++ trunk/reactos/dll/directx/ddraw/iface_videoport.c Sun Apr 22 17:54:34 2007 @@ -24,40 +24,24 @@ ULONG WINAPI Main_DirectDrawVideoPort_AddRef (LPDIRECTDRAWVIDEOPORT iface) { - LPDDRAWI_DDVIDEOPORT_INT This = (LPDDRAWI_DDVIDEOPORT_INT)iface; - - DX_WINDBG_trace(); - - if (iface!=NULL) - { - This->dwIntRefCnt++; - //This->lpLcl->dwLocalRefCnt++; - - //if (This->lpLcl->lpGbl != NULL) - //{ - // This->lpLcl->lpGbl->dwRefCnt++; - //} - } - return This->dwIntRefCnt; + DX_WINDBG_trace(); + + DX_STUB; }
ULONG WINAPI Main_DirectDrawVideoPort_Release (LPDIRECTDRAWVIDEOPORT iface) { - LPDDRAWI_DDVIDEOPORT_INT This = (LPDDRAWI_DDVIDEOPORT_INT)iface; - - DX_WINDBG_trace(); - /* FIXME - This is not right exiame how it should be done - */ - DX_STUB_str("FIXME This is not right exiame how it should be done\n"); - return This->dwIntRefCnt; + DX_WINDBG_trace(); + + DX_STUB; }
HRESULT WINAPI Main_DirectDrawVideoPort_Flip (LPDIRECTDRAWVIDEOPORT iface, LPDIRECTDRAWSURFACE lpDDSurface, DWORD dwFlags) { - DX_WINDBG_trace(); + DX_WINDBG_trace(); + DX_STUB; }
Modified: trunk/reactos/dll/directx/ddraw/main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main.c?re... ============================================================================== --- trunk/reactos/dll/directx/ddraw/main.c (original) +++ trunk/reactos/dll/directx/ddraw/main.c Sun Apr 22 17:54:34 2007 @@ -31,30 +31,30 @@ HRESULT WINAPI DirectDrawCreate (LPGUID lpGUID, - LPDIRECTDRAW* lplpDD, - LPUNKNOWN pUnkOuter) -{ - /* - remove this when UML digram are in place - this api is finish and is working as it should - */ - DX_WINDBG_trace(); - - /* check the pointer if it vaild to read from */ - if (IsBadWritePtr( lplpDD, sizeof( LPVOID )) ) - { - return DDERR_INVALIDPARAMS; - } - - /* check see if pUnkOuter is null or not */ - if (pUnkOuter) - { - /* we are using same error code as MS*/ - return CLASS_E_NOAGGREGATION; - } - - /* Create our DirectDraw interface */ - return Create_DirectDraw (lpGUID, lplpDD, &IID_IDirectDraw7, FALSE); + LPDIRECTDRAW* lplpDD, + LPUNKNOWN pUnkOuter) +{ + /* + remove this when UML digram are in place + this api is finish and is working as it should + */ + DX_WINDBG_trace(); + + /* check the pointer if it vaild to read from */ + if (IsBadWritePtr( lplpDD, sizeof( LPVOID )) ) + { + return DDERR_INVALIDPARAMS; + } + + /* check see if pUnkOuter is null or not */ + if (pUnkOuter) + { + /* we are using same error code as MS*/ + return CLASS_E_NOAGGREGATION; + } + + /* Create our DirectDraw interface */ + return Create_DirectDraw (lpGUID, lplpDD, &IID_IDirectDraw7, FALSE); }
/* @@ -64,37 +64,37 @@
HRESULT WINAPI -DirectDrawCreateEx(LPGUID lpGUID, - LPVOID* lplpDD, - REFIID id, - LPUNKNOWN pUnkOuter) -{ - /* - remove this when UML digram are in place - this api is finish and is working as it should - */ - DX_WINDBG_trace(); - - /* check the pointer if it vaild to read from */ - if (IsBadWritePtr( lplpDD, sizeof( LPVOID )) ) - { - return DDERR_INVALIDPARAMS; - } - - /* check see if pUnkOuter is null or not */ - if (pUnkOuter) - { - /* we are using same error code as MS*/ - return CLASS_E_NOAGGREGATION; - } - - /* Is it a DirectDraw 7 Request or not */ - if (!IsEqualGUID(id, &IID_IDirectDraw7)) - { - return DDERR_INVALIDPARAMS; - } - - /* Create our DirectDraw interface */ +DirectDrawCreateEx(LPGUID lpGUID, + LPVOID* lplpDD, + REFIID id, + LPUNKNOWN pUnkOuter) +{ + /* + remove this when UML digram are in place + this api is finish and is working as it should + */ + DX_WINDBG_trace(); + + /* check the pointer if it vaild to read from */ + if (IsBadWritePtr( lplpDD, sizeof( LPVOID )) ) + { + return DDERR_INVALIDPARAMS; + } + + /* check see if pUnkOuter is null or not */ + if (pUnkOuter) + { + /* we are using same error code as MS*/ + return CLASS_E_NOAGGREGATION; + } + + /* Is it a DirectDraw 7 Request or not */ + if (!IsEqualGUID(id, &IID_IDirectDraw7)) + { + return DDERR_INVALIDPARAMS; + } + + /* Create our DirectDraw interface */ return Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, id, TRUE); }
@@ -231,15 +231,15 @@ VOID WINAPI AcquireDDThreadLock() -{ - EnterCriticalSection(&ddcs); +{ + EnterCriticalSection(&ddcs); }
VOID WINAPI ReleaseDDThreadLock() { - LeaveCriticalSection(&ddcs); + LeaveCriticalSection(&ddcs); }
BOOL APIENTRY @@ -248,21 +248,21 @@ BOOL retStatus; switch(ul_reason_for_call) { - case DLL_PROCESS_DETACH: - DeleteCriticalSection( &ddcs ); - retStatus = TRUE; + case DLL_PROCESS_DETACH: + DeleteCriticalSection( &ddcs ); + retStatus = TRUE; break;
case DLL_PROCESS_ATTACH: - DisableThreadLibraryCalls( hModule ); - InitializeCriticalSection( &ddcs ); - EnterCriticalSection( &ddcs ); - LeaveCriticalSection( &ddcs ); - retStatus = FALSE; - break; - - default: - retStatus = TRUE; + DisableThreadLibraryCalls( hModule ); + InitializeCriticalSection( &ddcs ); + EnterCriticalSection( &ddcs ); + LeaveCriticalSection( &ddcs ); + retStatus = FALSE; + break; + + default: + retStatus = TRUE; break; } return retStatus;
Modified: trunk/reactos/dll/directx/ddraw/main/ddraw_main.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/main/ddra... ============================================================================== --- trunk/reactos/dll/directx/ddraw/main/ddraw_main.c (original) +++ trunk/reactos/dll/directx/ddraw/main/ddraw_main.c Sun Apr 22 17:54:34 2007 @@ -124,29 +124,9 @@ LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter) { - //LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - LPDDRAWI_DDRAWCLIPPER_INT That; - - DX_WINDBG_trace(); - - if (pUnkOuter!=NULL) - { - return CLASS_E_NOAGGREGATION; - } - - That = (LPDDRAWI_DDRAWCLIPPER_INT) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWCLIPPER_INT)); - if (That == NULL) - { - return DDERR_OUTOFMEMORY; //E_OUTOFMEMORY; - } - - That->lpVtbl = &DirectDrawClipper_Vtable; - - *ppClipper = (LPDIRECTDRAWCLIPPER)That; - - DirectDrawClipper_AddRef((LPDIRECTDRAWCLIPPER)That); - - return DirectDrawClipper_Initialize((LPDIRECTDRAWCLIPPER)That, (LPDIRECTDRAW)iface, dwFlags); + DX_WINDBG_trace(); + + DX_STUB; }
HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDIRECTDRAW7 iface, DWORD dwFlags, @@ -166,182 +146,9 @@ LPDIRECTDRAWSURFACE7 *ppSurf, IUnknown *pUnkOuter) {
- LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - LPDDRAWI_DDRAWSURFACE_INT *That = NULL; - LPDDRAWI_DDRAWSURFACE_LCL *lpLcl; - DWORD dwHowManySurface = 1; - DWORD i; - //LPDDRAWI_DDRAWSURFACE_LCL *xlpLcl; - - if (pUnkOuter!=NULL) - { - return CLASS_E_NOAGGREGATION; - } - if (IsBadWritePtr( ppSurf, sizeof( LPDIRECTDRAWSURFACE7 )) ) - { - return DDERR_INVALIDPARAMS; - } - if (IsBadWritePtr( pDDSD, sizeof( LPDDSURFACEDESC2 )) ) - { - return DDERR_INVALIDPARAMS; - } - if (IsBadReadPtr(pDDSD, sizeof( LPDDSURFACEDESC2 )) ) - { - return DDERR_INVALIDPARAMS; - } - if (sizeof(DDSURFACEDESC2)!=pDDSD->dwSize) - { - return DDERR_UNSUPPORTED; - } - if( (pDDSD->ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY) && - (pDDSD->ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY ) ) - { - return DDERR_INVALIDCAPS; - } - - - /* this two line should be move to startup code */ - ddSurfGbl.lpDD = &ddgbl; - ddSurfGbl.lpDDHandle = &ddgbl; - - /* Detecte if we are in fullscreen or not and extract thuse data */ - if (This->lpLcl->dwLocalFlags & DDRAWILCL_ISFULLSCREEN) - { - ddSurfGbl.wWidth = This->lpLcl->lpGbl->vmiData.dwDisplayWidth; - ddSurfGbl.wHeight = This->lpLcl->lpGbl->vmiData.dwDisplayHeight; - ddSurfGbl.lPitch = This->lpLcl->lpGbl->vmiData.lDisplayPitch; - } - else - { - RECT rect; - if(GetWindowRect((HWND)This->lpLcl->hWnd, &rect)) - { - ddSurfGbl.wWidth = rect.right - rect.left; - ddSurfGbl.wHeight = rect.bottom - rect.top; - ddSurfGbl.lPitch = This->lpLcl->lpGbl->vmiData.lDisplayPitch; - } - } - - /* setup diffent pixel format */ - if (pDDSD->dwFlags & DDSD_PIXELFORMAT) - { - if (pDDSD->ddpfPixelFormat.dwSize != sizeof(DDPIXELFORMAT)) - { - return DDERR_INVALIDPIXELFORMAT; - } - memcpy(&ddSurfGbl.ddpfSurface,&pDDSD->ddpfPixelFormat, sizeof(DDPIXELFORMAT)); - } - - /* Calc how many surface we need setup */ - if (pDDSD->ddsCaps.dwCaps & DDSD_BACKBUFFERCOUNT) - { - /* One primary + xx backbuffer */ - dwHowManySurface |= pDDSD->dwBackBufferCount; - } - - /* Alloc all memory we need for all createsurface here */ - lpLcl = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_LCL) * dwHowManySurface); - if (lpLcl == NULL) - { - return DDERR_OUTOFMEMORY; - } - - That = DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_INT) * dwHowManySurface); - if (That == NULL) - { - return DDERR_OUTOFMEMORY; - } - - for (i=0;i<dwHowManySurface+1;i++) - { - That[i] = (LPDDRAWI_DDRAWSURFACE_INT) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_INT)); - lpLcl[i] = (LPDDRAWI_DDRAWSURFACE_LCL) DxHeapMemAlloc(sizeof(DDRAWI_DDRAWSURFACE_LCL)); - if ( (lpLcl[i] == NULL) || - (That[i] == NULL)) - { - return DDERR_OUTOFMEMORY; - } - That[i]->lpLcl = lpLcl[i]; - - That[i]->lpLcl->lpGbl = &ddSurfGbl; - //That[i]->lpLcl->lpGbl = (LPDDRAWI_DDRAWSURFACE_GBL) DxHeapMemAlloc(sizeof(LPDDRAWI_DDRAWSURFACE_GBL)); - //if (That[i]->lpLcl->lpGbl == NULL) - //{ - // return DDERR_OUTOFMEMORY; - //} - - //That[i]->lpLcl->lpGbl->lpDD = &ddgbl; - //That[i]->lpLcl->lpGbl->lpDDHandle = This->lpLcl->lpGbl; - //memmove(That[i]->lpLcl->lpGbl,&ddSurfGbl,sizeof(LPDDRAWI_DDRAWSURFACE_GBL)); - } - - - - /* here we need start fixing bugs - * the code above is 100% correct behovir - * checked how ms ddraw behivor - */ - - - - /* Create the surface */ - if (((pDDSD->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) - && (!(pDDSD->ddsCaps.dwCaps & DDSCAPS_BACKBUFFER))) - { - CreatePrimarySurface(This,That,lpLcl,pDDSD); - } - if (pDDSD->ddsCaps.dwCaps & DDSCAPS_OVERLAY) - { - CreateOverlaySurface(This, That, pDDSD); - } - if (pDDSD->ddsCaps.dwCaps & DDSCAPS_BACKBUFFER) - { - This->lpLcl->lpGbl->dsList = NULL; - DX_STUB_str( "ok"); - - if (pDDSD->dwFlags & DDSD_BACKBUFFERCOUNT) - { - HRESULT retValue; - DX_STUB_str( "ok"); - - if (! pDDSD->ddsCaps.dwCaps & (DDSCAPS_FLIP | DDSCAPS_COMPLEX)) - { - return DDERR_INVALIDPARAMS; - } - - if (pDDSD->dwBackBufferCount != 0) - { - This->lpLcl->lpGbl->dsList = This->lpLcl->lpPrimary; - } - else - { - return DDERR_INVALIDSURFACETYPE; - } - retValue = CreateBackBufferSurface(This,That,lpLcl,pDDSD); - //CreatePrimarySurface(This,That,lpLcl,pDDSD); - if (retValue != DD_OK) - { - DX_STUB_str( "Fail to create backbuffer surface"); - return retValue; - } - } - } - - if (pDDSD->ddsCaps.dwCaps & DDSCAPS_TEXTURE) - { - DX_STUB_str( "Can not create texture surface"); - } - if (pDDSD->ddsCaps.dwCaps & DDSCAPS_ZBUFFER) - { - DX_STUB_str( "Can not create zbuffer surface"); - } - if (pDDSD->ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN) - { - DX_STUB_str( "Can not create offscreenplain surface"); - } - - *ppSurf = (LPDIRECTDRAWSURFACE7)That[0]; - return DD_OK; + DX_WINDBG_trace(); + + DX_STUB;
}
@@ -365,150 +172,9 @@ LPDDSURFACEDESC2 pDDSD, LPVOID context, LPDDENUMMODESCALLBACK2 callback) {
- DX_STUB_DD_OK; - - // IDirectDrawImpl* This = (IDirectDrawImpl*)iface; - // DDSURFACEDESC2 desc_callback; - // DEVMODE DevMode; - // int iMode=0; - // - //RtlZeroMemory(&desc_callback, sizeof(DDSURFACEDESC2)); - // - // desc_callback.dwSize = sizeof(DDSURFACEDESC2); - - // desc_callback.dwFlags = DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT|DDSD_PITCH; - - // if (dwFlags & DDEDM_REFRESHRATES) - // { - // desc_callback.dwFlags |= DDSD_REFRESHRATE; - // desc_callback.dwRefreshRate = This->lpLcl->lpGbl->dwMonitorFrequency; - // } - - // - // /* FIXME check if the mode are suppretd before sending it back */ - - //memset(&DevMode,0,sizeof(DEVMODE)); - //DevMode.dmSize = (WORD)sizeof(DEVMODE); - //DevMode.dmDriverExtra = 0; - - // while (EnumDisplaySettingsEx(NULL, iMode, &DevMode, 0)) - // { - // - // if (pDDSD) - // { - // if ((pDDSD->dwFlags & DDSD_WIDTH) && (pDDSD->dwWidth != DevMode.dmPelsWidth)) - // continue; - // if ((pDDSD->dwFlags & DDSD_HEIGHT) && (pDDSD->dwHeight != DevMode.dmPelsHeight)) - // continue; - // if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->ddpfPixelFormat.dwFlags & DDPF_RGB) && - // (pDDSD->ddpfPixelFormat.dwRGBBitCount != DevMode.dmBitsPerPel)) - // continue; - // } - // - // desc_callback.dwHeight = DevMode.dmPelsHeight; - // desc_callback.dwWidth = DevMode.dmPelsWidth; - // - // if (DevMode.dmFields & DM_DISPLAYFREQUENCY) - // { - // desc_callback.dwRefreshRate = DevMode.dmDisplayFrequency; - // } - - // if (desc_callback.dwRefreshRate == 0) - // { - // DX_STUB_str("dwRefreshRate = 0, we hard code it to value 60"); - // desc_callback.dwRefreshRate = 60; /* Maybe the valye should be biger */ - // } - - // /* above same as wine */ - // if ((pDDSD->dwFlags & DDSD_PIXELFORMAT) && (pDDSD->ddpfPixelFormat.dwFlags & DDPF_RGB) ) - // { - // switch(DevMode.dmBitsPerPel) - // { - // case 8: - // desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - // desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; - // desc_callback.ddpfPixelFormat.dwFourCC = 0; - // desc_callback.ddpfPixelFormat.dwRGBBitCount=8; - // /* FIXME right value */ - // desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ - // desc_callback.ddpfPixelFormat.dwGBitMask = 0; /* Green bitmask */ - // desc_callback.ddpfPixelFormat.dwBBitMask = 0; /* Blue bitmask */ - // break; - - // case 15: - // desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - // desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; - // desc_callback.ddpfPixelFormat.dwFourCC = 0; - // desc_callback.ddpfPixelFormat.dwRGBBitCount=15; - // /* FIXME right value */ - // desc_callback.ddpfPixelFormat.dwRBitMask = 0x7C00; /* red bitmask */ - // desc_callback.ddpfPixelFormat.dwGBitMask = 0x3E0; /* Green bitmask */ - // desc_callback.ddpfPixelFormat.dwBBitMask = 0x1F; /* Blue bitmask */ - // break; - - // case 16: - // desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - // desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; - // desc_callback.ddpfPixelFormat.dwFourCC = 0; - // desc_callback.ddpfPixelFormat.dwRGBBitCount=16; - // /* FIXME right value */ - // desc_callback.ddpfPixelFormat.dwRBitMask = 0xF800; /* red bitmask */ - // desc_callback.ddpfPixelFormat.dwGBitMask = 0x7E0; /* Green bitmask */ - // desc_callback.ddpfPixelFormat.dwBBitMask = 0x1F; /* Blue bitmask */ - // break; - - // case 24: - // desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - // desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; - // desc_callback.ddpfPixelFormat.dwFourCC = 0; - // desc_callback.ddpfPixelFormat.dwRGBBitCount=24; - // /* FIXME right value */ - // desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ - // desc_callback.ddpfPixelFormat.dwGBitMask = 0x00FF00; /* Green bitmask */ - // desc_callback.ddpfPixelFormat.dwBBitMask = 0x0000FF; /* Blue bitmask */ - // break; - - // case 32: - // desc_callback.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT); - // desc_callback.ddpfPixelFormat.dwFlags = DDPF_RGB; - // desc_callback.ddpfPixelFormat.dwFourCC = 0; - // desc_callback.ddpfPixelFormat.dwRGBBitCount=8; - // /* FIXME right value */ - // desc_callback.ddpfPixelFormat.dwRBitMask = 0xFF0000; /* red bitmask */ - // desc_callback.ddpfPixelFormat.dwGBitMask = 0x00FF00; /* Green bitmask */ - // desc_callback.ddpfPixelFormat.dwBBitMask = 0x0000FF; /* Blue bitmask */ - // break; - - // default: - // break; - // } - // desc_callback.ddsCaps.dwCaps = 0; - // if (desc_callback.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXED8) - // { - // /* FIXME srt DDCS Caps flag */ - // desc_callback.ddsCaps.dwCaps |= DDSCAPS_PALETTE; - // } - // } - // - // if (DevMode.dmBitsPerPel==15) - // { - // desc_callback.lPitch = DevMode.dmPelsWidth + (8 - ( DevMode.dmPelsWidth % 8)) % 8; - // } - // else - // { - // desc_callback.lPitch = DevMode.dmPelsWidth * (DevMode.dmBitsPerPel / 8); - // desc_callback.lPitch = desc_callback.lPitch + (8 - (desc_callback.lPitch % 8)) % 8; - // } - // - // if (callback(&desc_callback, context) == DDENUMRET_CANCEL) - // { - // return DD_OK; - // } - // - // iMode++; - // } - - // return DD_OK; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -531,27 +197,9 @@ HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface) { - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - DDHAL_FLIPTOGDISURFACEDATA mDdFlipToGDISurface; - - DX_WINDBG_trace(); - - mDdFlipToGDISurface.ddRVal = DDERR_NOTINITIALIZED; - mDdFlipToGDISurface.dwReserved = 0; - mDdFlipToGDISurface.dwToGDI = TRUE; - mDdFlipToGDISurface.FlipToGDISurface = This->lpLcl->lpDDCB->cbDDCallbacks.FlipToGDISurface; - - if (mDdFlipToGDISurface.FlipToGDISurface == NULL) - { - return DDERR_NODRIVERSUPPORT; - } - - if (mDdFlipToGDISurface.FlipToGDISurface(&mDdFlipToGDISurface)==DDHAL_DRIVER_HANDLED); - { - return mDdFlipToGDISurface.ddRVal; - } - - return DDERR_NODRIVERSUPPORT; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -563,36 +211,9 @@ LPDDCAPS pHELCaps) {
- DDSCAPS2 ddscaps = {0}; - DWORD status = DD_FALSE; - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - if (pDriverCaps != NULL) - { - Main_DirectDraw_GetAvailableVidMem(iface, - &ddscaps, - &This->lpLcl->lpGbl->ddCaps.dwVidMemTotal, - &This->lpLcl->lpGbl->ddCaps.dwVidMemFree); - - RtlCopyMemory(pDriverCaps,&This->lpLcl->lpGbl->ddCaps,sizeof(DDCORECAPS)); - pDriverCaps->dwSize=sizeof(DDCAPS); - - status = DD_OK; - } - - if (pHELCaps != NULL) - { - Main_DirectDraw_GetAvailableVidMem(iface, - &ddscaps, - &This->lpLcl->lpGbl->ddHELCaps.dwVidMemTotal, - &This->lpLcl->lpGbl->ddHELCaps.dwVidMemFree); - - RtlCopyMemory(pDriverCaps,&This->lpLcl->lpGbl->ddHELCaps,sizeof(DDCORECAPS)); - status = DD_OK; - } - return status; + DX_WINDBG_trace(); + + DX_STUB; }
@@ -602,38 +223,11 @@ */ HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7 iface, LPDDSURFACEDESC2 pDDSD) { - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - if (pDDSD == NULL) - { - return DD_FALSE; - } - - pDDSD->dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_REFRESHRATE | DDSD_WIDTH; - pDDSD->dwHeight = This->lpLcl->lpGbl->vmiData.dwDisplayHeight; - pDDSD->dwWidth = This->lpLcl->lpGbl->vmiData.dwDisplayWidth; - pDDSD->lPitch = This->lpLcl->lpGbl->vmiData.lDisplayPitch; - pDDSD->dwRefreshRate = This->lpLcl->lpGbl->dwMonitorFrequency; - pDDSD->dwAlphaBitDepth = This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwAlphaBitDepth; - - RtlCopyMemory(&pDDSD->ddpfPixelFormat,&This->lpLcl->lpGbl->vmiData.ddpfDisplay,sizeof(DDPIXELFORMAT)); - RtlCopyMemory(&pDDSD->ddsCaps,&This->lpLcl->lpGbl->ddCaps,sizeof(DDCORECAPS)); - - RtlCopyMemory(&pDDSD->ddckCKDestOverlay,&This->lpLcl->lpGbl->ddckCKDestOverlay,sizeof(DDCOLORKEY)); - RtlCopyMemory(&pDDSD->ddckCKSrcOverlay,&This->lpLcl->lpGbl->ddckCKSrcOverlay,sizeof(DDCOLORKEY)); - - /* have not check where I should get hold of this info yet - DWORD dwBackBufferCount; - DWORD dwReserved; - LPVOID lpSurface; - DDCOLORKEY ddckCKDestBlt; - DDCOLORKEY ddckCKSrcBlt; - DWORD dwTextureStage; - */ - - return DD_OK; + //LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; + + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -666,17 +260,9 @@ HRESULT WINAPI Main_DirectDraw_GetMonitorFrequency(LPDIRECTDRAW7 iface,LPDWORD freq) { - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - if (freq == NULL) - { - return DD_FALSE; - } - - *freq = This->lpLcl->lpGbl->dwMonitorFrequency; - return DD_OK; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -686,33 +272,9 @@ HRESULT WINAPI Main_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine) { - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - DDHAL_GETSCANLINEDATA mDdGetScanLine; - - DX_WINDBG_trace(); - - *lpdwScanLine = 0; - - mDdGetScanLine.ddRVal = DDERR_NOTINITIALIZED; - mDdGetScanLine.dwScanLine = 0; - mDdGetScanLine.GetScanLine = This->lpLcl->lpDDCB->cbDDCallbacks.GetScanLine; - mDdGetScanLine.lpDD = This->lpLcl->lpGbl; - - if (mDdGetScanLine.GetScanLine == NULL) - { - return DDERR_NODRIVERSUPPORT; - } - - mDdGetScanLine.ddRVal = DDERR_NOTPALETTIZED; - mDdGetScanLine.dwScanLine = 0; - - if (mDdGetScanLine.GetScanLine(&mDdGetScanLine)==DDHAL_DRIVER_HANDLED); - { - *lpdwScanLine = mDdGetScanLine.dwScanLine; - return mDdGetScanLine.ddRVal; - } - - return DDERR_NODRIVERSUPPORT; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -734,16 +296,9 @@ WINAPI Main_DirectDraw_Initialize (LPDIRECTDRAW7 iface, LPGUID lpGUID) { - //LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - if (iface==NULL) - { - return DDERR_NOTINITIALIZED; - } - - return DDERR_ALREADYINITIALIZED; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -753,9 +308,9 @@ HRESULT WINAPI Main_DirectDraw_RestoreDisplayMode(LPDIRECTDRAW7 iface) { - DX_WINDBG_trace(); - - ChangeDisplaySettings(NULL, 0); + DX_WINDBG_trace(); + + DX_STUB; return DD_OK; }
@@ -766,76 +321,9 @@ HRESULT WINAPI Main_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface, HWND hwnd, DWORD cooplevel) { - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - if (cooplevel & DDSCL_FULLSCREEN) - { - This->lpLcl->dwLocalFlags |= DDRAWILCL_ISFULLSCREEN; - } - - if (cooplevel & DDSCL_EXCLUSIVE) - { - This->lpLcl->lpGbl->lpExclusiveOwner = This->lpLcl; - } - - - /* This code should be a callback */ - This->lpLcl->hWnd = hwnd; - This->lpLcl->hFocusWnd = hwnd; - ReCreateDirectDraw((LPDIRECTDRAW*)iface); - - // TODO: - // - create a scaner that check which driver we should get the HDC from - // for now we always asume it is the active dirver that should be use. - // - allow more Flags - - - - // - // DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode; - - //DX_WINDBG_trace(); - // - // - // // check the parameters - // if ((HWND)This->lpLcl->lpGbl->lpExclusiveOwner->hWnd == hwnd) - // return DD_OK; - // - // - - // if ((cooplevel&DDSCL_EXCLUSIVE) && !(cooplevel&DDSCL_FULLSCREEN)) - // return DDERR_INVALIDPARAMS; - - // if (cooplevel&DDSCL_NORMAL && cooplevel&DDSCL_FULLSCREEN) - // return DDERR_INVALIDPARAMS; - - // // set the data - // This->lpLcl->lpGbl->lpExclusiveOwner->hWnd = (ULONG_PTR) hwnd; - // This->lpLcl->lpGbl->lpExclusiveOwner->hDC = (ULONG_PTR)GetDC(hwnd); - - // - ///* FIXME : fill the mDDrawGlobal.lpExclusiveOwner->dwLocalFlags right */ - ////mDDrawGlobal.lpExclusiveOwner->dwLocalFlags - - - // SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED; - //if ((This->lpLcl->lpGbl->lpDDCBtmp->cbDDCallbacks.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE)) - // { - // - // SetExclusiveMode.SetExclusiveMode = This->lpLcl->lpGbl->lpDDCBtmp->cbDDCallbacks.SetExclusiveMode; - // SetExclusiveMode.lpDD = This->lpLcl->lpGbl; - // SetExclusiveMode.dwEnterExcl = cooplevel; - - // if (SetExclusiveMode.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED) - // { - // return DDERR_NODRIVERSUPPORT; - // } - // } - // - // return SetExclusiveMode.ddRVal; - DX_STUB_DD_OK; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -846,76 +334,9 @@ Main_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags) { - - - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - BOOL dummy = TRUE; - DEVMODE DevMode; - int iMode=0; - int Width=0; - int Height=0; - int BPP=0; - DDHAL_SETMODEDATA mDdSetMode; - - DX_WINDBG_trace(); - - /* FIXME check the refresrate if it same if it not same do the mode switch */ - - if ((This->lpLcl->lpGbl->vmiData.dwDisplayHeight == dwHeight) && - (This->lpLcl->lpGbl->vmiData.dwDisplayWidth == dwWidth) && - (This->lpLcl->lpGbl->vmiData.ddpfDisplay.dwRGBBitCount == dwBPP)) - { - return DD_OK; - } - - mDdSetMode.ddRVal = DDERR_NOTINITIALIZED; - mDdSetMode.dwModeIndex = 0; - mDdSetMode.inexcl = 0; - mDdSetMode.lpDD = This->lpLcl->lpGbl; - mDdSetMode.useRefreshRate = FALSE; - mDdSetMode.SetMode = This->lpLcl->lpDDCB->cbDDCallbacks.SetMode; - - if (mDdSetMode.SetMode == NULL) - { - return DDERR_NODRIVERSUPPORT; - } - - /* Check use the Hal or Hel for SetMode */ - // this only for exclusive mode - /*if(!(This->cooperative_level & DDSCL_EXCLUSIVE)) - { - return DDERR_NOEXCLUSIVEMODE; - }*/ - - DevMode.dmSize = (WORD)sizeof(DEVMODE); - DevMode.dmDriverExtra = 0; - - while (EnumDisplaySettingsEx(NULL, iMode, &DevMode, 0 ) != 0) - { - - if ((dwWidth == DevMode.dmPelsWidth) && (dwHeight == DevMode.dmPelsHeight) && ( dwBPP == DevMode.dmBitsPerPel)) - { - Width = DevMode.dmPelsWidth; - Height = DevMode.dmPelsHeight; - BPP = DevMode.dmBitsPerPel; - break; - } - iMode++; - } - - if ((dwWidth != DevMode.dmPelsWidth) || (dwHeight != DevMode.dmPelsHeight) || ( dwBPP != DevMode.dmBitsPerPel)) - { - return DDERR_UNSUPPORTEDMODE; - } - - mDdSetMode.dwModeIndex = iMode; - mDdSetMode.SetMode(&mDdSetMode); - - DdReenableDirectDrawObject(This->lpLcl->lpGbl, &dummy); - - /* FIXME fill the This->DirectDrawGlobal.vmiData right */ - //This->lpLcl->lpGbl->lpExclusiveOwner->hDC = (ULONG_PTR)GetDC( (HWND)This->lpLcl->lpGbl->lpExclusiveOwner->hWnd); - return mDdSetMode.ddRVal; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -927,36 +348,9 @@ HANDLE h) {
- LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - DDHAL_WAITFORVERTICALBLANKDATA mDdWaitForVerticalBlank; - - DX_WINDBG_trace(); - - if (!(This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK)) - { - return DDERR_NODRIVERSUPPORT; - } - - if (mDdWaitForVerticalBlank.WaitForVerticalBlank == NULL) - { - return DDERR_NODRIVERSUPPORT; - } - - mDdWaitForVerticalBlank.bIsInVB = DDWAITVB_BLOCKBEGIN ; /* return begin ? */ - mDdWaitForVerticalBlank.ddRVal = DDERR_NOTINITIALIZED; - mDdWaitForVerticalBlank.dwFlags = dwFlags; - mDdWaitForVerticalBlank.hEvent = (DWORD)h; - mDdWaitForVerticalBlank.lpDD = This->lpLcl->lpGbl; - mDdWaitForVerticalBlank.WaitForVerticalBlank = This->lpLcl->lpDDCB->cbDDCallbacks.WaitForVerticalBlank; - - if (mDdWaitForVerticalBlank.WaitForVerticalBlank(&mDdWaitForVerticalBlank) - != DDHAL_DRIVER_HANDLED) - { - return DDERR_NODRIVERSUPPORT; - } - - - return mDdWaitForVerticalBlank.ddRVal; + DX_WINDBG_trace(); + + DX_STUB; }
/* @@ -967,38 +361,9 @@ Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, LPDWORD total, LPDWORD free) { - DDHAL_GETAVAILDRIVERMEMORYDATA mem; - - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DX_WINDBG_trace(); - - - /* Only Hal version exists acodring msdn */ - if (!(This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY)) - { - return DDERR_NODRIVERSUPPORT; - } - - mem.lpDD = This->lpLcl->lpGbl; - mem.ddRVal = DDERR_NOTPALETTIZED; - mem.DDSCaps.dwCaps = ddscaps->dwCaps; - mem.ddsCapsEx.dwCaps2 = ddscaps->dwCaps2; - mem.ddsCapsEx.dwCaps3 = ddscaps->dwCaps3; - mem.ddsCapsEx.dwCaps4 = ddscaps->dwCaps4; - - if (This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks.GetAvailDriverMemory(&mem) == DDHAL_DRIVER_HANDLED); - { - if (total !=NULL) - { - *total = mem.dwTotal; - } - - *free = mem.dwFree; - return mem.ddRVal; - } - - return DDERR_NODRIVERSUPPORT; + DX_WINDBG_trace(); + + DX_STUB; }
/*
Modified: trunk/reactos/dll/directx/ddraw/rosdraw.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/rosdraw.h... ============================================================================== --- trunk/reactos/dll/directx/ddraw/rosdraw.h (original) +++ trunk/reactos/dll/directx/ddraw/rosdraw.h Sun Apr 22 17:54:34 2007 @@ -21,6 +21,7 @@ extern DDRAWI_DIRECTDRAW_GBL ddgbl; extern DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
+ HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW* iface, LPGUID pGUID, BOOL reenable); HRESULT WINAPI StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable); HRESULT WINAPI StartDirectDrawHel(LPDIRECTDRAW* iface, BOOL reenable); @@ -32,7 +33,7 @@ VOID Cleanup(LPDIRECTDRAW7 iface);
/* own macro to alloc memmory */ -#define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m) +#define DxHeapMemAlloc(m) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, m) #define DxHeapMemFree(p) HeapFree(GetProcessHeap(), 0, p); \ p = NULL;
@@ -45,15 +46,15 @@ HRESULT WINAPI Main_DirectDraw_QueryInterface (LPDIRECTDRAW7 , REFIID , LPVOID *); ULONG WINAPI Main_DirectDraw_AddRef(LPDIRECTDRAW7 ); ULONG WINAPI Main_DirectDraw_Release(LPDIRECTDRAW7 ); -HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 ); +HRESULT WINAPI Main_DirectDraw_Compact(LPDIRECTDRAW7 ); HRESULT WINAPI Main_DirectDraw_CreateClipper(LPDIRECTDRAW7, DWORD, LPDIRECTDRAWCLIPPER *, IUnknown *); HRESULT WINAPI Main_DirectDraw_CreatePalette(LPDIRECTDRAW7, DWORD, LPPALETTEENTRY, LPDIRECTDRAWPALETTE*, LPUNKNOWN); HRESULT WINAPI Main_DirectDraw_CreateSurface(LPDIRECTDRAW7, LPDDSURFACEDESC2, LPDIRECTDRAWSURFACE7 *, IUnknown *); -HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7, LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7*); +HRESULT WINAPI Main_DirectDraw_DuplicateSurface(LPDIRECTDRAW7, LPDIRECTDRAWSURFACE7, LPDIRECTDRAWSURFACE7*); HRESULT WINAPI Main_DirectDraw_GetDeviceIdentifier(LPDIRECTDRAW7, LPDDDEVICEIDENTIFIER2, DWORD);
-HRESULT WINAPI Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7, DWORD, LPDDSURFACEDESC2, LPVOID, - LPDDENUMSURFACESCALLBACK7); +HRESULT WINAPI Main_DirectDraw_EnumSurfaces(LPDIRECTDRAW7, DWORD, LPDDSURFACEDESC2, LPVOID, + LPDDENUMSURFACESCALLBACK7);
HRESULT WINAPI Main_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7); HRESULT WINAPI Main_DirectDraw_GetDisplayMode(LPDIRECTDRAW7, LPDDSURFACEDESC2); @@ -118,7 +119,7 @@ HRESULT WINAPI Main_DDrawSurface_Initialize (LPDIRECTDRAWSURFACE7, LPDIRECTDRAW, LPDDSURFACEDESC2); HRESULT WINAPI Main_DDrawSurface_Lock (LPDIRECTDRAWSURFACE7, LPRECT, LPDDSURFACEDESC2, DWORD, HANDLE); HRESULT WINAPI Main_DDrawSurface_Restore(LPDIRECTDRAWSURFACE7); -HRESULT WINAPI Main_DDrawSurface_UpdateOverlay (LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, +HRESULT WINAPI Main_DDrawSurface_UpdateOverlay (LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDOVERLAYFX);
@@ -131,24 +132,24 @@ HRESULT CreateBackBufferSurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That, LPDDRAWI_DDRAWSURFACE_LCL *lpLcl, LPDDSURFACEDESC2 pDDSD); HRESULT CreatePrimarySurface(LPDDRAWI_DIRECTDRAW_INT This, LPDDRAWI_DDRAWSURFACE_INT *That,LPDDRAWI_DDRAWSURFACE_LCL *lpLcl, LPDDSURFACEDESC2 pDDSD);
-/* DirectDraw Object struct - - DDRAWI_DIRECTDRAW_INT +/* DirectDraw Object struct + + DDRAWI_DIRECTDRAW_INT it is the the return pointer from ddraw.dll to the program - + DDRAWI_DIRECTDRAW_LCL - It is the program own private data + It is the program own private data
DDRAWI_DIRECTDRAW_GBL This struct is gboal for whole ddraw.dll for all program - it is static in ddraw if it change it change for all - program - - The struct - - from http://msdn2.microsoft.com/en-us/library/ms898267.aspx - it was not document for windows 2000/xp/2003 but ms did document it - for windows ce 5.0 the link are to windows ce 5.0 arch + it is static in ddraw if it change it change for all + program + + The struct + + from http://msdn2.microsoft.com/en-us/library/ms898267.aspx + it was not document for windows 2000/xp/2003 but ms did document it + for windows ce 5.0 the link are to windows ce 5.0 arch
typedef struct _DDRAWI_DIRECTDRAW_INT { LPVOID lpVtbl; @@ -157,7 +158,7 @@ DWORD dwIntRefCnt; } DDRAWI_DIRECTDRAW_INT;
- rest of the struct are from msdn for windows 2000/xp/2003 + rest of the struct are from msdn for windows 2000/xp/2003 typedef struct _DDRAWI_DIRECTDRAW_LCL { DWORD lpDDMore; LPDDRAWI_DIRECTDRAW_GBL lpGbl; // fill it from function Create_DirectDraw with static pointer ddgbl @@ -168,9 +169,9 @@ IUnknown FAR *pUnkOuter; DWORD dwObsolete1; ULONG_PTR hWnd; - ULONG_PTR hDC; // create HDC and save it to this pointer + ULONG_PTR hDC; // create HDC and save it to this pointer DWORD dwErrorMode; - LPDDRAWI_DDRAWSURFACE_INT lpPrimary; + LPDDRAWI_DDRAWSURFACE_INT lpPrimary; LPDDRAWI_DDRAWSURFACE_INT lpCB; DWORD dwPreferredMode; HINSTANCE hD3DInstance; @@ -182,9 +183,9 @@ DWORD dwHotTracking; DWORD dwIMEState; ULONG_PTR hWndPopup; - ULONG_PTR hDD; + ULONG_PTR hDD; ULONG_PTR hGammaCalibrator; - LPDDGAMMACALIBRATORPROC lpGammaCalibrator; + LPDDGAMMACALIBRATORPROC lpGammaCalibrator; } DDRAWI_DIRECTDRAW_LCL;
@@ -203,7 +204,7 @@ DWORD dwMaxOverlays; DWORD dwCurrOverlays; DWORD dwMonitorFrequency; - DDCORECAPS ddHELCaps; + DDCORECAPS ddHELCaps; DWORD dwUnused2[50]; DDCOLORKEY ddckCKDestOverlay; DDCOLORKEY ddckCKSrcOverlay; @@ -220,7 +221,7 @@ DWORD dwSurfaceLockCount; DWORD dwAliasedLockCnt; ULONG_PTR dwReserved3; - ULONG_PTR hDD; // GdiEntry1 are filling this pointer + ULONG_PTR hDD; // GdiEntry1 are filling this pointer char cObsolete[12]; DWORD dwReserved1; DWORD dwReserved2; @@ -252,7 +253,7 @@ ULONG_PTR lpD3DExtendedCaps; DWORD dwDOSBoxEvent; RECT rectDesktop; - char cDriverName[MAX_DRIVER_NAME]; + char cDriverName[MAX_DRIVER_NAME]; ULONG_PTR lpD3DHALCallbacks3; DWORD dwNumZPixelFormats; LPDDPIXELFORMAT lpZPixelFormats; @@ -262,22 +263,22 @@ } DDRAWI_DIRECTDRAW_GBL;
-*/ - - -/* Clipper Object struct - DDRAWI_DDRAWCLIPPER_INT +*/ + + +/* Clipper Object struct + DDRAWI_DDRAWCLIPPER_INT it is the the return pointer from ddraw.dll to the program - + DDRAWI_DDRAWCLIPPER_LCL - It is the program own private data + It is the program own private data
DDRAWI_DDRAWCLIPPER_GBL This struct is gboal for whole ddraw.dll for all program - it is static in ddraw if it change it change for all - program - - The struct + it is static in ddraw if it change it change for all + program + + The struct
typedef struct _DDRAWI_DDRAWCLIPPER_INT { LPVOID lpVtbl; @@ -413,7 +414,7 @@ */
-/* This comment info maybe is wrong +/* This comment info maybe is wrong bare in mind I am using logic thinking for follow info does not exists in MSDN so I am drawing clude how previews stuffs @@ -434,13 +435,13 @@ DDRAWI_DDKERNELSURFACE_LCL DDRAWI_DDKERNELSURFACE_GBL
-follow struct can be easy create +follow struct can be easy create DDRAWI_DDGAMMACONTROL_INT DDRAWI_DDCOLORCONTROL_INT DDRAWI_KERNEL_INT
the DDRAWI_DDGAMMACONTROL_INT should looking like this -typedef struct _DDRAWI_DDGAMMACONTROL_INT +typedef struct _DDRAWI_DDGAMMACONTROL_INT { LPVOID lpVtbl; LPDDRAWI_DDGAMMACONTROL_LCL lpLcl; @@ -448,11 +449,11 @@ DWORD dwIntRefCnt; } DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT
-how did I got this struct I looked at all other INT struct how they where +how did I got this struct I looked at all other INT struct how they where build. But it is not 100% sure this one is right untill I/we known how the DDRAWI_DDGAMMACONTROL_LCL works and DDRAWI_DDCOLORCONTROL_GBL our internal struct will look like this -typedef struct _DDRAWI_DDGAMMACONTROL_INT +typedef struct _DDRAWI_DDGAMMACONTROL_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -462,7 +463,7 @@
same goes for DDRAWI_DDCOLORCONTROL_INT
-typedef struct DDRAWI_DDCOLORCONTROL_INT +typedef struct DDRAWI_DDCOLORCONTROL_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -471,7 +472,7 @@ } DDRAWI_DDCOLORCONTROL_INT, *LPDDRAWI_DDCOLORCONTROL_INT */
-typedef struct DDRAWI_DDCOLORCONTROL_INT +typedef struct DDRAWI_DDCOLORCONTROL_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -480,7 +481,7 @@ } DDRAWI_DDCOLORCONTROL_INT, *LPDDRAWI_DDCOLORCONTROL_INT;
-typedef struct _DDRAWI_DDGAMMACONTROL_INT +typedef struct _DDRAWI_DDGAMMACONTROL_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -488,7 +489,7 @@ DWORD dwIntRefCnt; } DDRAWI_DDGAMMACONTROL_INT, *LPDDRAWI_DDGAMMACONTROL_INT;
-typedef struct _DDRAWI_DDKERNEL_INT +typedef struct _DDRAWI_DDKERNEL_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -496,7 +497,7 @@ DWORD dwIntRefCnt; } DDRAWI_KERNEL_INT, *LPDDRAWI_KERNEL_INT;
-typedef struct _DDRAWI_DDKERNELSURFACE_INT +typedef struct _DDRAWI_DDKERNELSURFACE_INT { LPVOID lpVtbl; LPVOID lpLcl; @@ -535,28 +536,28 @@ HRESULT WINAPI Main_DDrawSurface_SetSurfaceDesc(LPDIRECTDRAWSURFACE7 iface, DDSURFACEDESC2 *DDSD, DWORD Flags);
-HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, LPDWORD total, LPDWORD free); +HRESULT WINAPI Main_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps, LPDWORD total, LPDWORD free);
VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 ); -HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7, LPDDSCAPS2, LPDWORD, LPDWORD ); -HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE ); +HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7, LPDDSCAPS2, LPDWORD, LPDWORD ); +HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE ); HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 , LPDWORD ); -HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 ); +HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 ); HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7, DWORD, DWORD, DWORD, DWORD, DWORD ); HRESULT Hal_DDrawSurface_Blt(LPDIRECTDRAWSURFACE7, LPRECT, LPDIRECTDRAWSURFACE7, LPRECT, DWORD, LPDDBLTFX ); HRESULT Hal_DDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect, LPDDSURFACEDESC2 pDDSD, DWORD flags, HANDLE event); HRESULT Hal_DDrawSurface_Flip(LPDIRECTDRAWSURFACE7 iface, LPDIRECTDRAWSURFACE7 override, DWORD dwFlags); HRESULT Hal_DDrawSurface_SetColorKey (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags, LPDDCOLORKEY pCKey); -HRESULT Hal_DDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect); +HRESULT Hal_DDrawSurface_Unlock(LPDIRECTDRAWSURFACE7 iface, LPRECT pRect); HRESULT Hal_DDrawSurface_GetBltStatus(LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags); HRESULT Hal_DDrawSurface_UpdateOverlayDisplay (LPDIRECTDRAWSURFACE7 iface, DWORD dwFlags);
HRESULT Hel_DirectDraw_Initialize (LPDIRECTDRAW7 ); HRESULT Hel_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 ); VOID Hel_DirectDraw_Release (LPDIRECTDRAW7 ); -HRESULT Hel_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 , LPDDSCAPS2 ddsaps, LPDWORD , LPDWORD ); -HRESULT Hel_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE ); +HRESULT Hel_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 , LPDDSCAPS2 ddsaps, LPDWORD , LPDWORD ); +HRESULT Hel_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7, DWORD, HANDLE ); HRESULT Hel_DirectDraw_GetScanLine(LPDIRECTDRAW7 , LPDWORD ); HRESULT Hel_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 ); HRESULT Hel_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 , DWORD , DWORD ,DWORD , DWORD , DWORD ); @@ -605,22 +606,22 @@
/*********** Macros ***********/
-/* - use this macro to close - down the debuger text complete +/* + use this macro to close + down the debuger text complete no debuging at all, it will - crash ms debuger in VS + crash ms debuger in VS */
-//#define DX_WINDBG_trace() +//#define DX_WINDBG_trace() //#define DX_STUB -//#define DX_STUB_DD_OK return DD_OK; -//#define DX_STUB_str(x) +//#define DX_STUB_DD_OK return DD_OK; +//#define DX_STUB_str(x) //#define DX_WINDBG_trace_res
-/* - Use this macro if you want deboug in visual studio or +/* + Use this macro if you want deboug in visual studio or 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. @@ -629,16 +630,16 @@ */
-//#define DX_WINDBG_trace() +//#define DX_WINDBG_trace() //#define DX_STUB -//#define DX_STUB_DD_OK return DD_OK; +//#define DX_STUB_DD_OK return DD_OK; //#define DX_STUB_str(x) printf("%s",x); //#define DX_WINDBG_trace_res
-/* +/* use this if want doing a trace from a program like a game and ReactOS ddraw.dll in windows - so you can figout what going wrong and what + so you can figout what going wrong and what api are being call or if it hel or is it hal
This marco does not create warings when you compile @@ -655,8 +656,8 @@ firstcall = FALSE; \ } \ } \ - return DDERR_UNSUPPORTED; - + return DDERR_UNSUPPORTED; +
#define DX_STUB_DD_OK \ @@ -670,8 +671,8 @@ firstcall = FALSE; \ } \ } \ - return DD_OK; - + return DD_OK; +
#define DX_STUB_str(x) \ { \
Modified: trunk/reactos/dll/directx/ddraw/startup.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/directx/ddraw/startup.c... ============================================================================== --- trunk/reactos/dll/directx/ddraw/startup.c (original) +++ trunk/reactos/dll/directx/ddraw/startup.c Sun Apr 22 17:54:34 2007 @@ -3,7 +3,7 @@ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: lib/ddraw/ddraw.c - * PURPOSE: DirectDraw Library + * PURPOSE: DirectDraw Library * PROGRAMMER: Magnus Olsen (greatlrd) * */ @@ -13,27 +13,95 @@ #include "d3dhal.h" #include "ddrawgdi.h"
+#include "ddrawi.h" DDRAWI_DIRECTDRAW_GBL ddgbl; DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
-HRESULT WINAPI + +HRESULT +WINAPI +Create_DirectDraw (LPGUID pGUID, + LPDIRECTDRAW* pIface, + REFIID id, + BOOL ex) +{ + LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; + + DX_WINDBG_trace(); + + if (This == NULL) + { + /* We do not have a DirectDraw interface, we need alloc it*/ + LPDDRAWI_DIRECTDRAW_INT memThis; + + memThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); + This = memThis; + if (This == NULL) + { + if (memThis != NULL) DxHeapMemFree(memThis); + return DDERR_OUTOFMEMORY; + } + } + else + { + /* We got the DirectDraw interface alloc and we need create the link */ + LPDDRAWI_DIRECTDRAW_INT newThis; + newThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); + if (newThis == NULL) + return DDERR_OUTOFMEMORY; + /* we need check the GUID lpGUID what type it is */ + if (pGUID != (LPGUID)DDCREATE_HARDWAREONLY) + { + if (pGUID !=NULL) + { + This = newThis; + return DDERR_INVALIDDIRECTDRAWGUID; + } + } + newThis->lpLink = This; + This = newThis; + } + + /* Fixme release memory alloc if we fail */ + This->lpLcl = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); + if (This->lpLcl == NULL) + return DDERR_OUTOFMEMORY; + + *pIface = (LPDIRECTDRAW)This; + + /* Get right interface we whant */ + if (Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface)) + { + if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID, FALSE) == DD_OK); + return DD_OK; + } + + return DDERR_INVALIDPARAMS; +} + + +HRESULT WINAPI StartDirectDraw(LPDIRECTDRAW* iface, LPGUID lpGuid, BOOL reenable) { LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; DWORD hal_ret = DD_FALSE; DWORD hel_ret = DD_FALSE; - DEVMODE devmode; - HBITMAP hbmp; - const UINT bmiSize = sizeof(BITMAPINFOHEADER) + 0x10; - UCHAR *pbmiData; - BITMAPINFO *pbmi; - DWORD *pMasks; - INT devicetypes = 0; - DWORD dwFlags = 0; - + DWORD devicetypes = 0; + DWORD dwFlags; + DX_WINDBG_trace(); - + + /* + * ddgbl.dwPDevice is not longer in use in windows 2000 and higher + * I am using it for device type + * devicetypes = 1 : both hal and hel are enable + * devicetypes = 2 : both hal are enable + * devicetypes = 3 : both hel are enable + * devicetypes = 4 :loading a guid drv from the register + */ + + if (reenable == FALSE) { if (This->lpLink == NULL) @@ -42,7 +110,7 @@ This->lpLcl->lpGbl->dwRefCnt++; if (ddgbl.lpDDCBtmp == NULL) { - ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS)); + ddgbl.lpDDCBtmp = (LPDDHAL_CALLBACKS) DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS)); if (ddgbl.lpDDCBtmp == NULL) { DX_STUB_str("Out of memmory"); @@ -52,79 +120,48 @@ } }
- /* - Visual studio think this code is a break point if we call - second time to this function, press on continue in visual - studio the program will work. No real bug. gcc 3.4.5 genreate - code that look like MS visual studio break point. - */ - - This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp; - - /* Same for HEL and HAL */ - - if (ddgbl.lpModeInfo == NULL) - { - ddgbl.lpModeInfo = (DDHALMODEINFO*) DxHeapMemAlloc(1 * sizeof(DDHALMODEINFO)); - if (ddgbl.lpModeInfo == NULL) - { - DX_STUB_str("DD_FALSE"); - return DD_FALSE; - } - } - - EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode); - - This->lpLcl->lpGbl->lpModeInfo[0].dwWidth = devmode.dmPelsWidth; - This->lpLcl->lpGbl->lpModeInfo[0].dwHeight = devmode.dmPelsHeight; - This->lpLcl->lpGbl->lpModeInfo[0].dwBPP = devmode.dmBitsPerPel; - This->lpLcl->lpGbl->lpModeInfo[0].lPitch = (devmode.dmPelsWidth*devmode.dmBitsPerPel)/8; - This->lpLcl->lpGbl->lpModeInfo[0].wRefreshRate = (WORD)devmode.dmDisplayFrequency; - - if (reenable == FALSE) { if (lpGuid == NULL) { - devicetypes = 1; + devicetypes= 1;
/* Create HDC for default, hal and hel driver */ - This->lpLcl->hDC = (ULONG_PTR) CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL); - - /* cObsolete is undoc in msdn it being use in CreateDCA */ - RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7); - RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7); - - dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV; - } - else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY) - { - devicetypes = 2; - /* Create HDC for default, hal and hel driver */ - This->lpLcl->hDC = (ULONG_PTR)CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL); + This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow());
/* cObsolete is undoc in msdn it being use in CreateDCA */ RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7); RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7); dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV; } - else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY) - { - devicetypes = 3; - - /* Create HDC for default, hal and hel driver */ - This->lpLcl->hDC = (ULONG_PTR) CreateDCW(L"DISPLAY",L"DISPLAY",NULL,NULL); + else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY) + { + devicetypes = 2; + /* Create HDC for default, hal driver */ + This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow());
/* cObsolete is undoc in msdn it being use in CreateDCA */ RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7); RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7); - dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV; } + else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY) + { + devicetypes = 3; + + /* Create HDC for default, hal and hel driver */ + This->lpLcl->hDC = (ULONG_PTR) GetDC(GetActiveWindow()); + + /* cObsolete is undoc in msdn it being use in CreateDCA */ + RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7); + RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7); + + dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV; + } else { /* FIXME : need getting driver from the GUID that have been pass in from - * the register. we do not support that yet + * the register. we do not support that yet */ devicetypes = 4; This->lpLcl->hDC = (ULONG_PTR) NULL ; @@ -137,50 +174,12 @@ } }
- hbmp = CreateCompatibleBitmap((HDC) This->lpLcl->hDC, 1, 1); - if (hbmp==NULL) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC) This->lpLcl->hDC); - DX_STUB_str("DDERR_OUTOFMEMORY"); - return DDERR_OUTOFMEMORY; - } - - pbmiData = (UCHAR *) DxHeapMemAlloc(bmiSize); - pbmi = (BITMAPINFO*)pbmiData; - - if (pbmiData==NULL) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC) This->lpLcl->hDC); - DeleteObject(hbmp); - DX_STUB_str("DDERR_OUTOFMEMORY"); - return DDERR_OUTOFMEMORY; - } - - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biBitCount = (WORD)devmode.dmBitsPerPel; - pbmi->bmiHeader.biCompression = BI_BITFIELDS; - pbmi->bmiHeader.biWidth = 1; - pbmi->bmiHeader.biHeight = 1; - - GetDIBits((HDC) This->lpLcl->hDC, hbmp, 0, 0, NULL, pbmi, 0); - DeleteObject(hbmp); - - pMasks = (DWORD*)(pbmiData + sizeof(BITMAPINFOHEADER)); - This->lpLcl->lpGbl->lpModeInfo[0].dwRBitMask = pMasks[0]; - This->lpLcl->lpGbl->lpModeInfo[0].dwGBitMask = pMasks[1]; - This->lpLcl->lpGbl->lpModeInfo[0].dwBBitMask = pMasks[2]; - This->lpLcl->lpGbl->lpModeInfo[0].dwAlphaBitMask = pMasks[3]; - - DxHeapMemFree(pbmiData); + This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
/* Startup HEL and HAL */ - // RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL)); - This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp; This->lpLcl->dwProcessId = GetCurrentProcessId(); - + switch (devicetypes) { case 2: @@ -203,7 +202,7 @@ if (hel_ret!=DD_OK) { DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT"); - return DDERR_NODIRECTDRAWSUPPORT; + return DDERR_NODIRECTDRAWSUPPORT; } dwFlags |= DDRAWI_NOHARDWARE; } @@ -218,595 +217,20 @@ dwFlags |= DDRAWI_EMULATIONINITIALIZED; }
- This->lpLcl->lpGbl->dwFlags = dwFlags | DDRAWI_ATTACHEDTODESKTOP; - - This->lpLcl->hDD = This->lpLcl->lpGbl->hDD; - - /* Mix the DDCALLBACKS */ - This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp; - - This->lpLcl->lpDDCB->cbDDCallbacks.dwSize = sizeof(This->lpLcl->lpDDCB->cbDDCallbacks); - - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_CANCREATESURFACE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CANCREATESURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.CanCreateSurface = This->lpLcl->lpDDCB->HALDD.CanCreateSurface; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_CANCREATESURFACE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CANCREATESURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.CanCreateSurface = This->lpLcl->lpDDCB->HELDD.CanCreateSurface; - } - - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_CREATESURFACE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CREATESURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface = This->lpLcl->lpDDCB->HALDD.CreateSurface; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_CREATESURFACE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CREATESURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.CreateSurface = This->lpLcl->lpDDCB->HELDD.CreateSurface; - } - - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_CREATEPALETTE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CREATEPALETTE; - This->lpLcl->lpDDCB->cbDDCallbacks.CreatePalette = This->lpLcl->lpDDCB->HALDD.CreatePalette; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_CREATEPALETTE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_CREATEPALETTE; - This->lpLcl->lpDDCB->cbDDCallbacks.CreatePalette = This->lpLcl->lpDDCB->HELDD.CreatePalette; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_DESTROYDRIVER) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_DESTROYDRIVER; - This->lpLcl->lpDDCB->cbDDCallbacks.DestroyDriver = This->lpLcl->lpDDCB->HALDD.DestroyDriver; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_DESTROYDRIVER) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_DESTROYDRIVER; - This->lpLcl->lpDDCB->cbDDCallbacks.DestroyDriver = This->lpLcl->lpDDCB->HELDD.DestroyDriver; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_FLIPTOGDISURFACE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_FLIPTOGDISURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.FlipToGDISurface = This->lpLcl->lpDDCB->HALDD.FlipToGDISurface; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_FLIPTOGDISURFACE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_FLIPTOGDISURFACE; - This->lpLcl->lpDDCB->cbDDCallbacks.FlipToGDISurface = This->lpLcl->lpDDCB->HELDD.FlipToGDISurface; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_GETSCANLINE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_GETSCANLINE; - This->lpLcl->lpDDCB->cbDDCallbacks.GetScanLine = This->lpLcl->lpDDCB->HALDD.GetScanLine; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_GETSCANLINE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_GETSCANLINE; - This->lpLcl->lpDDCB->cbDDCallbacks.GetScanLine = This->lpLcl->lpDDCB->HELDD.GetScanLine; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_SETCOLORKEY) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETCOLORKEY; - This->lpLcl->lpDDCB->cbDDCallbacks.SetColorKey = This->lpLcl->lpDDCB->HALDD.SetColorKey; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_SETCOLORKEY) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETCOLORKEY; - This->lpLcl->lpDDCB->cbDDCallbacks.SetColorKey = This->lpLcl->lpDDCB->HELDD.SetColorKey; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETEXCLUSIVEMODE; - This->lpLcl->lpDDCB->cbDDCallbacks.SetExclusiveMode = This->lpLcl->lpDDCB->HALDD.SetExclusiveMode; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETEXCLUSIVEMODE; - This->lpLcl->lpDDCB->cbDDCallbacks.SetExclusiveMode = This->lpLcl->lpDDCB->HELDD.SetExclusiveMode; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_SETMODE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETMODE; - This->lpLcl->lpDDCB->cbDDCallbacks.SetMode = This->lpLcl->lpDDCB->HALDD.SetMode; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_SETMODE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_SETMODE; - This->lpLcl->lpDDCB->cbDDCallbacks.SetMode = This->lpLcl->lpDDCB->HELDD.SetMode; - } - if ((This->lpLcl->lpDDCB->HALDD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_WAITFORVERTICALBLANK; - This->lpLcl->lpDDCB->cbDDCallbacks.WaitForVerticalBlank = - This->lpLcl->lpDDCB->HALDD.WaitForVerticalBlank; - } - else if ((This->lpLcl->lpDDCB->HELDD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDCallbacks.dwFlags |= DDHAL_CB32_WAITFORVERTICALBLANK; - This->lpLcl->lpDDCB->cbDDCallbacks.WaitForVerticalBlank = - This->lpLcl->lpDDCB->HELDD.WaitForVerticalBlank; - } - - /* Mix the DDSURFACE CALLBACKS */ - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwSize = sizeof(This->lpLcl->lpDDCB->cbDDSurfaceCallbacks); - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_ADDATTACHEDSURFACE; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.AddAttachedSurface = - This->lpLcl->lpDDCB->HALDDSurface.AddAttachedSurface; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_ADDATTACHEDSURFACE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_ADDATTACHEDSURFACE; - - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.AddAttachedSurface = - This->lpLcl->lpDDCB->HELDDSurface.AddAttachedSurface; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_BLT) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_BLT; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Blt = This->lpLcl->lpDDCB->HALDDSurface.Blt; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_BLT) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_BLT; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Blt = This->lpLcl->lpDDCB->HELDDSurface.Blt; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_DESTROYSURFACE; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.DestroySurface = This->lpLcl->lpDDCB->HALDDSurface.DestroySurface; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_DESTROYSURFACE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_DESTROYSURFACE; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.DestroySurface = This->lpLcl->lpDDCB->HELDDSurface.DestroySurface; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_FLIP) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_FLIP; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Flip = This->lpLcl->lpDDCB->HALDDSurface.Flip; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_FLIP) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_FLIP; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Flip = This->lpLcl->lpDDCB->HELDDSurface.Flip; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_GETBLTSTATUS; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.GetBltStatus = - This->lpLcl->lpDDCB->HALDDSurface.GetBltStatus; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_GETBLTSTATUS) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_GETBLTSTATUS; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.GetBltStatus = This->lpLcl->lpDDCB->HELDDSurface.GetBltStatus; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_GETFLIPSTATUS; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.GetFlipStatus = This->lpLcl->lpDDCB->HALDDSurface.GetFlipStatus; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_GETFLIPSTATUS) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_GETFLIPSTATUS; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.GetFlipStatus = This->lpLcl->lpDDCB->HELDDSurface.GetFlipStatus; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_LOCK) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_LOCK; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Lock = This->lpLcl->lpDDCB->HALDDSurface.Lock; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_LOCK) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_LOCK; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Lock = This->lpLcl->lpDDCB->HELDDSurface.Lock; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_RESERVED4) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_RESERVED4; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.reserved4 = This->lpLcl->lpDDCB->HALDDSurface.reserved4; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_RESERVED4) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_RESERVED4; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.reserved4 = This->lpLcl->lpDDCB->HELDDSurface.reserved4; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_SETCLIPLIST) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETCLIPLIST; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetClipList = This->lpLcl->lpDDCB->HALDDSurface.SetClipList; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_SETCLIPLIST) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETCLIPLIST; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetClipList = This->lpLcl->lpDDCB->HELDDSurface.SetClipList; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_SETCOLORKEY) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETCOLORKEY; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetColorKey = This->lpLcl->lpDDCB->HALDDSurface.SetColorKey; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_SETCOLORKEY) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETCOLORKEY; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetColorKey = This->lpLcl->lpDDCB->HELDDSurface.SetColorKey; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETOVERLAYPOSITION; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetOverlayPosition = - This->lpLcl->lpDDCB->HALDDSurface.SetOverlayPosition; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_SETOVERLAYPOSITION) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETOVERLAYPOSITION; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetOverlayPosition = - This->lpLcl->lpDDCB->HELDDSurface.SetOverlayPosition; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_SETPALETTE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETPALETTE; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetPalette = This->lpLcl->lpDDCB->HALDDSurface.SetPalette; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_SETPALETTE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_SETPALETTE; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.SetPalette = This->lpLcl->lpDDCB->HELDDSurface.SetPalette; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_UNLOCK) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_UNLOCK; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Unlock = This->lpLcl->lpDDCB->HALDDSurface.Unlock; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_UNLOCK) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_UNLOCK; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.Unlock = This->lpLcl->lpDDCB->HELDDSurface.Unlock; - } - - if ((This->lpLcl->lpDDCB->HALDDSurface.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_UPDATEOVERLAY; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.UpdateOverlay = This->lpLcl->lpDDCB->HALDDSurface.UpdateOverlay; - } - else if ((This->lpLcl->lpDDCB->HELDDSurface.dwFlags & DDHAL_SURFCB32_UPDATEOVERLAY) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.dwFlags |= DDHAL_SURFCB32_UPDATEOVERLAY; - This->lpLcl->lpDDCB->cbDDSurfaceCallbacks.UpdateOverlay = This->lpLcl->lpDDCB->HELDDSurface.UpdateOverlay; - } - - /* Mix the DDPALETTE CALLBACKS */ - This->lpLcl->lpDDCB->HALDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HALDDPalette); - - if ((This->lpLcl->lpDDCB->HALDDPalette.dwFlags & DDHAL_PALCB32_DESTROYPALETTE) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.dwFlags |= DDHAL_PALCB32_SETENTRIES; - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.DestroyPalette = - This->lpLcl->lpDDCB->HALDDPalette.DestroyPalette; - } - else if ((This->lpLcl->lpDDCB->HELDDPalette.dwFlags & DDHAL_PALCB32_DESTROYPALETTE) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.dwFlags |= DDHAL_PALCB32_DESTROYPALETTE; - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.DestroyPalette = - This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette; - } - - if ((This->lpLcl->lpDDCB->HALDDPalette.dwFlags & DDHAL_PALCB32_SETENTRIES) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.dwFlags |= DDHAL_PALCB32_SETENTRIES; - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.SetEntries = - This->lpLcl->lpDDCB->HALDDPalette.SetEntries; - } - else if ((This->lpLcl->lpDDCB->HELDDPalette.dwFlags & DDHAL_PALCB32_SETENTRIES) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.dwFlags |= DDHAL_PALCB32_SETENTRIES; - This->lpLcl->lpDDCB->cbDDPaletteCallbacks.SetEntries = - This->lpLcl->lpDDCB->HELDDPalette.SetEntries; - } - - /* Mix the DDExeBuf CALLBACKS */ - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwSize = sizeof(This->lpLcl->lpDDCB->cbDDExeBufCallbacks); - - if ((This->lpLcl->lpDDCB->HALDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_CANCREATEEXEBUF) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.CanCreateExecuteBuffer = - This->lpLcl->lpDDCB->HALDDExeBuf.CanCreateExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_CANCREATEEXEBUF; - } - else if ((This->lpLcl->lpDDCB->HELDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_CANCREATEEXEBUF) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.CanCreateExecuteBuffer = - This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_CANCREATEEXEBUF; - } - - if ((This->lpLcl->lpDDCB->HALDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_CREATEEXEBUF) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.CreateExecuteBuffer = - This->lpLcl->lpDDCB->HALDDExeBuf.CreateExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_CREATEEXEBUF; - } - else if ((This->lpLcl->lpDDCB->HELDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_CREATEEXEBUF) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.CreateExecuteBuffer = - This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_CREATEEXEBUF; - } - - if ((This->lpLcl->lpDDCB->HALDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_DESTROYEXEBUF) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.DestroyExecuteBuffer = - This->lpLcl->lpDDCB->HALDDExeBuf.DestroyExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_DESTROYEXEBUF; - } - else if ((This->lpLcl->lpDDCB->HELDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_DESTROYEXEBUF) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.DestroyExecuteBuffer = - This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_DESTROYEXEBUF; - } - - if ((This->lpLcl->lpDDCB->HALDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_LOCKEXEBUF) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.LockExecuteBuffer = - This->lpLcl->lpDDCB->HALDDExeBuf.LockExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_LOCKEXEBUF; - } - else if ((This->lpLcl->lpDDCB->HELDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_LOCKEXEBUF) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.LockExecuteBuffer = - This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_LOCKEXEBUF; - } - - if ((This->lpLcl->lpDDCB->HALDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_UNLOCKEXEBUF) && (devicetypes !=3)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.UnlockExecuteBuffer = - This->lpLcl->lpDDCB->HALDDExeBuf.UnlockExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_UNLOCKEXEBUF; - } - else if ((This->lpLcl->lpDDCB->HELDDExeBuf.dwFlags & DDHAL_EXEBUFCB32_UNLOCKEXEBUF) && (devicetypes !=2)) - { - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.UnlockExecuteBuffer = - This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer; - This->lpLcl->lpDDCB->cbDDExeBufCallbacks.dwFlags |= DDHAL_EXEBUFCB32_UNLOCKEXEBUF; - } - /* Fill some basic info for Surface */ - - /* FIXME - We need setup this also - This->lpLcl->lpDDCB->cbDDColorControlCallbacks - This->lpLcl->lpDDCB->cbDDKernelCallbacks - This->lpLcl->lpDDCB->cbDDMiscellaneousCallbacks - This->lpLcl->lpDDCB->cbDDMotionCompCallbacks - This->lpLcl->lpDDCB->cbDDVideoPortCallbacks - */
This->lpLcl->hDD = ddgbl.hDD;
return DD_OK; }
- -HRESULT WINAPI -StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable) -{ - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - DDHAL_GETDRIVERINFODATA DriverInfo; - - DDHALINFO mHALInfo; - DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks; - D3DHAL_CALLBACKS mD3dCallbacks; - D3DHAL_GLOBALDRIVERDATA mD3dDriverData; - UINT mcvmList; - VIDMEM *mpvmList; - - UINT mcFourCC; - DWORD *mpFourCC; - UINT mcTextures; - DDSURFACEDESC *mpTextures; - - /* HAL Startup process */ - BOOL newmode = FALSE; - RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO)); - - if (reenable == FALSE) - { - ddgbl.lpDDCBtmp = DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS)); - if ( ddgbl.lpDDCBtmp == NULL) - { - return DD_FALSE; - } - } - else - { - RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS)); - } - - /* - Startup DX HAL step one of three - */ - if (!DdCreateDirectDrawObject(This->lpLcl->lpGbl, (HDC)This->lpLcl->hDC)) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - return DD_FALSE; - } - - // Do not relase HDC it have been map in kernel mode - // DeleteDC(hdc); - - if (!DdReenableDirectDrawObject(This->lpLcl->lpGbl, &newmode)) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - return DD_FALSE; - } - - - /* - Startup DX HAL step two of three - */ - - if (!DdQueryDirectDrawObject(This->lpLcl->lpGbl, - &mHALInfo, - &ddgbl.lpDDCBtmp->HALDD, - &ddgbl.lpDDCBtmp->HALDDSurface, - &ddgbl.lpDDCBtmp->HALDDPalette, - &mD3dCallbacks, - &mD3dDriverData, - &mD3dBufferCallbacks, - NULL, - NULL, - NULL)) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - // FIXME Close DX fristcall and second call - return DD_FALSE; - } - - mcvmList = mHALInfo.vmiData.dwNumHeaps; - mpvmList = (VIDMEM*) DxHeapMemAlloc(sizeof(VIDMEM) * mcvmList); - if (mpvmList == NULL) - { - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - // FIXME Close DX fristcall and second call - return DD_FALSE; - } - - mcFourCC = mHALInfo.ddCaps.dwNumFourCCCodes; - mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * mcFourCC); - if (mpFourCC == NULL) - { - DxHeapMemFree(mpvmList); - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - // FIXME Close DX fristcall and second call - return DD_FALSE; - } - - mcTextures = mD3dDriverData.dwNumTextureFormats; - mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mcTextures); - if (mpTextures == NULL) - { - DxHeapMemFree( mpFourCC); - DxHeapMemFree( mpvmList); - DxHeapMemFree( This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - // FIXME Close DX fristcall and second call - return DD_FALSE; - } - - mHALInfo.vmiData.pvmList = mpvmList; - mHALInfo.lpdwFourCC = mpFourCC; - mD3dDriverData.lpTextureFormats = (DDSURFACEDESC*) mpTextures; - - if (!DdQueryDirectDrawObject( - This->lpLcl->lpGbl, - &mHALInfo, - &ddgbl.lpDDCBtmp->HALDD, - &ddgbl.lpDDCBtmp->HALDDSurface, - &ddgbl.lpDDCBtmp->HALDDPalette, - &mD3dCallbacks, - &mD3dDriverData, - &ddgbl.lpDDCBtmp->HALDDExeBuf, - (DDSURFACEDESC*)mpTextures, - mpFourCC, - mpvmList)) - - { - DxHeapMemFree(mpTextures); - DxHeapMemFree(mpFourCC); - DxHeapMemFree(mpvmList); - DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); - DeleteDC((HDC)This->lpLcl->hDC); - // FIXME Close DX fristcall and second call - return DD_FALSE; - } - - - /* - Copy over from HalInfo to DirectDrawGlobal - */ - - // this is wrong, cDriverName need be in ASC code not UNICODE - //memcpy(mDDrawGlobal.cDriverName, mDisplayAdapter, sizeof(wchar)*MAX_DRIVER_NAME); - - memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO)); - memcpy(&ddgbl.ddCaps, &mHALInfo.ddCaps,sizeof(DDCORECAPS)); - - mHALInfo.dwNumModes = 1; - mHALInfo.lpModeInfo = This->lpLcl->lpGbl->lpModeInfo; - mHALInfo.dwMonitorFrequency = This->lpLcl->lpGbl->lpModeInfo[0].wRefreshRate; - - This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency; - This->lpLcl->lpGbl->dwModeIndex = mHALInfo.dwModeIndex; - This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes; - This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo; - This->lpLcl->lpGbl->hInstance = mHALInfo.hInstance; - - This->lpLcl->lpGbl->lp16DD = This->lpLcl->lpGbl; - - - memset(&DriverInfo,0, sizeof(DDHAL_GETDRIVERINFODATA)); - DriverInfo.dwSize = sizeof(DDHAL_GETDRIVERINFODATA); - DriverInfo.dwContext = This->lpLcl->lpGbl->hDD; - - /* Get the MiscellaneousCallbacks */ - DriverInfo.guidInfo = GUID_MiscellaneousCallbacks; - DriverInfo.lpvData = &ddgbl.lpDDCBtmp->HALDDMiscellaneous; - DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS); - mHALInfo.GetDriverInfo(&DriverInfo); - - - /* FIXME - The 3d and private data are not save at moment - - we need lest the private data being setup - for some driver are puting kmode memory there - the memory often contain the private struct + - surface, see MS DDK how MS example driver using - it - - the 3d interface are not so improten if u do not - want the 3d, and we are not writing 3d code yet - so we be okay for now. - */ - - - return DD_OK; -} - -HRESULT WINAPI +HRESULT WINAPI StartDirectDrawHel(LPDIRECTDRAW* iface, BOOL reenable) { LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
- This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface; - This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface; + This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface; + This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface; This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette; This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver; This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface; @@ -861,7 +285,7 @@ This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);
/* - This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette; + This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette; This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries; This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette); */ @@ -877,152 +301,142 @@ return DD_OK; }
-HRESULT -WINAPI -Create_DirectDraw (LPGUID pGUID, - LPDIRECTDRAW* pIface, - REFIID id, - BOOL ex) -{ - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)*pIface; - - DX_WINDBG_trace(); - - if (!IsEqualGUID(&IID_IDirectDraw7, id)) - { - return DDERR_INVALIDDIRECTDRAWGUID; - } - - if (This == NULL) - { - LPDDRAWI_DIRECTDRAW_INT memThis; - - /* We do not have any DirectDraw interface alloc - * or a idot send in pIface as NULL - */ - memThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); - This = memThis; - if (This == NULL) - { - if (memThis != NULL) - { - /* do not create memmory leak if some - * idot send in pIface as NULL - */ - DxHeapMemFree(memThis); - } - return DDERR_OUTOFMEMORY; + +HRESULT WINAPI +StartDirectDrawHal(LPDIRECTDRAW* iface, BOOL reenable) +{ + + + LPDWORD mpFourCC; + DDHALINFO mHALInfo; + BOOL newmode = FALSE; + LPDDSURFACEDESC mpTextures; + D3DHAL_CALLBACKS mD3dCallbacks; + D3DHAL_GLOBALDRIVERDATA mD3dDriverData; + DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks; + LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; + + + RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO)); + RtlZeroMemory(&mD3dCallbacks, sizeof(D3DHAL_CALLBACKS)); + RtlZeroMemory(&mD3dDriverData, sizeof(D3DHAL_GLOBALDRIVERDATA)); + RtlZeroMemory(&mD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS)); + + if (reenable == FALSE) + { + ddgbl.lpDDCBtmp = DxHeapMemAlloc(sizeof(DDHAL_CALLBACKS)); + if ( ddgbl.lpDDCBtmp == NULL) + { + return DD_FALSE; } } else { - /* We got the DirectDraw interface alloc and we need create the link */ - - LPDDRAWI_DIRECTDRAW_INT newThis; - newThis = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); - if (newThis == NULL) - { - return DDERR_OUTOFMEMORY; - } - - /* we need check the GUID lpGUID what type it is */ - if (pGUID != (LPGUID)DDCREATE_HARDWAREONLY) - { - if (pGUID !=NULL) - { - This = newThis; - return DDERR_INVALIDDIRECTDRAWGUID; - } - } - - newThis->lpLink = This; - This = newThis; - } - - This->lpLcl = DxHeapMemAlloc(sizeof(DDRAWI_DIRECTDRAW_INT)); - - if (This->lpLcl == NULL) - { - /* FIXME cleanup */ - return DDERR_OUTOFMEMORY; + RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS)); }
/* - FIXME - read dwAppHackFlags flag from the system register instead for hard code it + * Startup DX HAL step one of three */ - This->lpLcl->dwAppHackFlags = 0; - This->lpLcl->dwHotTracking = 0; - This->lpLcl->dwIMEState = 0; - This->lpLcl->dwLocalFlags = DDRAWILCL_DIRECTDRAW7; - This->lpLcl->dwLocalRefCnt = 0; - /* - do not rest this flag to NULL it need be unistae for some reason other wise - somet thing will crash dwObsolete1 seam being use for something this was a - supriese for me - */ - //This->lpLcl->dwObsolete1 = 0; - This->lpLcl->dwProcessId = 0; - This->lpLcl->dwUnused0 = 0; - This->lpLcl->hD3DInstance = NULL; - This->lpLcl->hDC = 0; - This->lpLcl->hDDVxd = 0; - This->lpLcl->hFocusWnd = 0; - This->lpLcl->hGammaCalibrator = 0; - /* Do mot inistate this value if we do we can not open the HAL interface */ - //This->lpLcl->hWnd = 0; - This->lpLcl->hWndPopup = 0; - This->lpLcl->lpCB = NULL; - This->lpLcl->lpDDCB = NULL; - This->lpLcl->lpDDMore = 0; - This->lpLcl->lpGammaCalibrator = 0; - This->lpLcl->lpGbl = &ddgbl; - - /* Do mot inistate this value if we do we can not open the HAL interface */ - //This->lpLcl->lpPrimary = NULL; - This->lpLcl->pD3DIUnknown = NULL; - This->lpLcl->pUnkOuter = NULL; - - *pIface = (LPDIRECTDRAW)This; - - if(Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface) != S_OK) - { - return DDERR_INVALIDPARAMS; - } - - if (StartDirectDraw((LPDIRECTDRAW*)This, pGUID, FALSE) == DD_OK); - { - return DD_OK; - } - return DDERR_INVALIDPARAMS; + if (!DdCreateDirectDrawObject(This->lpLcl->lpGbl, (HDC)This->lpLcl->hDC)) + { + DxHeapMemFree(ddgbl.lpDDCBtmp); + return DD_FALSE; + } + + /* Some card disable the dx after it have been created so + * we are force reanble it + */ + if (!DdReenableDirectDrawObject(This->lpLcl->lpGbl, &newmode)) + { + DxHeapMemFree(ddgbl.lpDDCBtmp); + return DD_FALSE; + } + + if (!DdQueryDirectDrawObject(This->lpLcl->lpGbl, + &mHALInfo, + &ddgbl.lpDDCBtmp->HALDD, + &ddgbl.lpDDCBtmp->HALDDSurface, + &ddgbl.lpDDCBtmp->HALDDPalette, + &mD3dCallbacks, + &mD3dDriverData, + &mD3dBufferCallbacks, + NULL, + NULL, + NULL)) + { + DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo); + DxHeapMemFree(ddgbl.lpDDCBtmp); + // FIXME Close DX fristcall and second call + return DD_FALSE; + } + + /* Alloc mpFourCC */ + mpFourCC = NULL; + if (mHALInfo.ddCaps.dwNumFourCCCodes) + { + mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * mHALInfo.ddCaps.dwNumFourCCCodes); + if (mpFourCC == NULL) + { + DxHeapMemFree(ddgbl.lpDDCBtmp); + // FIXME Close DX fristcall and second call + return DD_FALSE; + } + } + + /* Alloc mpTextures */ + mpTextures = NULL; + + if (mD3dDriverData.dwNumTextureFormats) + { + mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mD3dDriverData.dwNumTextureFormats); + if (mpTextures == NULL) + { + DxHeapMemFree( mpFourCC); + DxHeapMemFree(ddgbl.lpDDCBtmp); + // FIXME Close DX fristcall and second call + } + return DD_FALSE; + } + + + /* Get all basic data from the driver */ + if (!DdQueryDirectDrawObject( + This->lpLcl->lpGbl, + &mHALInfo, + &ddgbl.lpDDCBtmp->HALDD, + &ddgbl.lpDDCBtmp->HALDDSurface, + &ddgbl.lpDDCBtmp->HALDDPalette, + &mD3dCallbacks, + &mD3dDriverData, + &ddgbl.lpDDCBtmp->HALDDExeBuf, + (DDSURFACEDESC*)mpTextures, + mpFourCC, + NULL)) + { + DxHeapMemFree( mpFourCC); + DxHeapMemFree( mpTextures); + DxHeapMemFree(ddgbl.lpDDCBtmp); + // FIXME Close DX fristcall and second call + return DD_FALSE; + } + + memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO)); + memcpy(&ddgbl.ddCaps, &mHALInfo.ddCaps,sizeof(DDCORECAPS)); + + This->lpLcl->lpGbl->dwNumFourCC = mHALInfo.ddCaps.dwNumFourCCCodes; + This->lpLcl->lpGbl->lpdwFourCC = mpFourCC; + + This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency; + This->lpLcl->lpGbl->dwModeIndex = mHALInfo.dwModeIndex; + This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes; + This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo; + This->lpLcl->lpGbl->hInstance = mHALInfo.hInstance; + This->lpLcl->lpGbl->lp16DD = This->lpLcl->lpGbl; + + /* FIXME convert mpTextures to DDHALMODEINFO */ + DxHeapMemFree( mpTextures); + + /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */ + return DD_OK; } - - - -HRESULT WINAPI -ReCreateDirectDraw(LPDIRECTDRAW* iface) -{ - LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface; - - DdDeleteDirectDrawObject(This->lpLcl->lpGbl); - - if ((This->lpLcl->lpGbl->dwFlags & DDRAWI_NOHARDWARE) != DDRAWI_NOHARDWARE) - { - if (This->lpLcl->lpGbl->dwFlags & DDRAWI_EMULATIONINITIALIZED) - { - return StartDirectDraw(iface,NULL, TRUE); - } - else - { - return StartDirectDraw(iface,(LPGUID)DDCREATE_HARDWAREONLY, TRUE); - } - } - else - { - return StartDirectDraw(iface,(LPGUID)DDCREATE_EMULATIONONLY, TRUE); - } - - return DD_FALSE; -} - -