1 /* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: lib/ddraw/ddraw.c
6 * PURPOSE: DirectDraw Library
7 * PROGRAMMER: Magnus Olsen (greatlrd)
14 DDRAWI_DIRECTDRAW_GBL ddgbl
;
15 DDRAWI_DDRAWSURFACE_GBL ddSurfGbl
;
22 Create_DirectDraw (LPGUID pGUID
, LPDIRECTDRAW
* pIface
,
23 REFIID id
, BOOL reenable
)
25 LPDDRAWI_DIRECTDRAW_INT This
;
29 if ((IsBadReadPtr(pIface
,sizeof(LPDIRECTDRAW
))) ||
30 (IsBadWritePtr(pIface
,sizeof(LPDIRECTDRAW
))))
32 return DDERR_INVALIDPARAMS
;
35 This
= (LPDDRAWI_DIRECTDRAW_INT
)*pIface
;
37 /* fixme linking too second link when we shall not doing it */
38 if (IsBadReadPtr(This
,sizeof(LPDIRECTDRAW
)))
40 /* We do not have a DirectDraw interface, we need alloc it*/
41 LPDDRAWI_DIRECTDRAW_INT memThis
;
43 DX_STUB_str("1. no linking\n");
45 DxHeapMemAlloc(memThis
, sizeof(DDRAWI_DIRECTDRAW_INT
));
48 return DDERR_OUTOFMEMORY
;
53 /* Fixme release memory alloc if we fail */
55 DxHeapMemAlloc(This
->lpLcl
, sizeof(DDRAWI_DIRECTDRAW_LCL
));
56 if (This
->lpLcl
== NULL
)
58 return DDERR_OUTOFMEMORY
;
63 /* We got the DirectDraw interface alloc and we need create the link */
64 LPDDRAWI_DIRECTDRAW_INT newThis
;
66 DX_STUB_str("2.linking\n");
68 /* step 1.Alloc the new DDRAWI_DIRECTDRAW_INT for the lnking */
69 DxHeapMemAlloc(newThis
, sizeof(DDRAWI_DIRECTDRAW_INT
));
72 return DDERR_OUTOFMEMORY
;
75 /* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */
76 if ((pGUID
) && (pGUID
!= (LPGUID
)DDCREATE_HARDWAREONLY
))
81 return DDERR_INVALIDDIRECTDRAWGUID
;
85 /* step 3 do the link the old interface are store in the new one */
86 newThis
->lpLink
= This
;
88 /* step 4 we need create new local directdraw struct for the new linked interface */
89 DxHeapMemAlloc(newThis
->lpLcl
, sizeof(DDRAWI_DIRECTDRAW_LCL
));
90 if (newThis
->lpLcl
== NULL
)
93 return DDERR_OUTOFMEMORY
;
99 This
->lpLcl
->lpGbl
= &ddgbl
;
101 *pIface
= (LPDIRECTDRAW
)This
;
103 /* Get right interface we whant */
106 if (IsEqualGUID(&IID_IDirectDraw7
, id
))
108 /* DirectDraw7 Vtable */
109 This
->lpVtbl
= &DirectDraw7_Vtable
;
110 This
->lpLcl
->dwLocalFlags
= This
->lpLcl
->dwLocalFlags
+ DDRAWILCL_DIRECTDRAW7
;
111 *pIface
= (LPDIRECTDRAW
)&This
->lpVtbl
;
112 Main_DirectDraw_AddRef(This
);
114 else if (IsEqualGUID(&IID_IDirectDraw4
, id
))
116 /* DirectDraw4 Vtable */
117 This
->lpVtbl
= &DirectDraw4_Vtable
;
118 *pIface
= (LPDIRECTDRAW
)&This
->lpVtbl
;
119 Main_DirectDraw_AddRef(This
);
121 else if (IsEqualGUID(&IID_IDirectDraw2
, id
))
123 /* DirectDraw2 Vtable */
124 This
->lpVtbl
= &DirectDraw2_Vtable
;
125 *pIface
= (LPDIRECTDRAW
)&This
->lpVtbl
;
126 Main_DirectDraw_AddRef(This
);
128 else if (IsEqualGUID(&IID_IDirectDraw
, id
))
130 /* DirectDraw Vtable */
131 This
->lpVtbl
= &DirectDraw_Vtable
;
132 *pIface
= (LPDIRECTDRAW
)&This
->lpVtbl
;
133 Main_DirectDraw_AddRef(This
);
136 if ( This
->lpVtbl
!= 0)
138 DX_STUB_str("Got iface\n");
140 if (StartDirectDraw((LPDIRECTDRAW
)This
, pGUID
, FALSE
) == DD_OK
);
143 RtlZeroMemory(&wnd_class, sizeof(wnd_class));
144 wnd_class.style = CS_HREDRAW | CS_VREDRAW;
145 wnd_class.lpfnWndProc = DefWindowProcW;
146 wnd_class.cbClsExtra = 0;
147 wnd_class.cbWndExtra = 0;
148 wnd_class.hInstance = GetModuleHandleW(0);
150 wnd_class.hCursor = 0;
151 wnd_class.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
152 wnd_class.lpszMenuName = NULL;
153 wnd_class.lpszClassName = classname;
154 if(!RegisterClassW(&wnd_class))
156 DX_STUB_str("DDERR_GENERIC");
157 return DDERR_GENERIC;
160 This
->lpLcl
->hDD
= ddgbl
.hDD
;
165 return DDERR_INVALIDPARAMS
;
170 StartDirectDraw(LPDIRECTDRAW iface
, LPGUID lpGuid
, BOOL reenable
)
172 LPDDRAWI_DIRECTDRAW_INT This
= (LPDDRAWI_DIRECTDRAW_INT
)iface
;
173 DWORD hal_ret
= DD_FALSE
;
174 DWORD hel_ret
= DD_FALSE
;
175 DWORD devicetypes
= 0;
183 * ddgbl.dwPDevice is not longer in use in windows 2000 and higher
184 * I am using it for device type
185 * devicetypes = 1 : both hal and hel are enable
186 * devicetypes = 2 : both hal are enable
187 * devicetypes = 3 : both hel are enable
188 * devicetypes = 4 :loading a guid drv from the register
191 ddgbl
.lpDriverHandle
= &ddgbl
;
197 if (reenable
== FALSE
)
199 if ((!IsBadReadPtr(This
->lpLink
,sizeof(LPDIRECTDRAW
))) && (This
->lpLink
== NULL
))
201 RtlZeroMemory(&ddgbl
, sizeof(DDRAWI_DIRECTDRAW_GBL
));
202 This
->lpLcl
->lpGbl
->dwRefCnt
++;
203 if (ddgbl
.lpDDCBtmp
== NULL
)
206 DxHeapMemAlloc( ddgbl
.lpDDCBtmp
, sizeof(DDHAL_CALLBACKS
));
207 if (ddgbl
.lpDDCBtmp
== NULL
)
209 DX_STUB_str("Out of memmory\n");
215 DxHeapMemAlloc(ddgbl
.lpModeInfo
, sizeof(DDHALMODEINFO
));
216 if (!ddgbl
.lpModeInfo
)
218 return DDERR_OUTOFMEMORY
;
222 /* Windows handler are by set of SetCooperLevel
226 if (reenable
== FALSE
)
232 /* Create HDC for default, hal and hel driver */
233 // This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
234 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
236 /* cObsolete is undoc in msdn it being use in CreateDCA */
237 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
238 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
239 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
243 else if (lpGuid
== (LPGUID
) DDCREATE_HARDWAREONLY
)
246 /* Create HDC for default, hal driver */
247 // This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
248 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
250 /* cObsolete is undoc in msdn it being use in CreateDCA */
251 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
252 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
253 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
255 else if (lpGuid
== (LPGUID
) DDCREATE_EMULATIONONLY
)
259 /* Create HDC for default, hal and hel driver */
260 //This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
261 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
263 /* cObsolete is undoc in msdn it being use in CreateDCA */
264 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
265 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
267 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
271 /* FIXME : need getting driver from the GUID that have been pass in from
272 * the register. we do not support that yet
275 //This->lpLcl->hDC = (ULONG_PTR) NULL ;
276 //This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
280 if ( (HDC)This->lpLcl->hDC == NULL)
282 DX_STUB_str("DDERR_OUTOFMEMORY\n");
283 return DDERR_OUTOFMEMORY ;
288 This
->lpLcl
->lpDDCB
= ddgbl
.lpDDCBtmp
;
290 /* Startup HEL and HAL */
291 This
->lpLcl
->lpDDCB
= This
->lpLcl
->lpGbl
->lpDDCBtmp
;
292 This
->lpLcl
->dwProcessId
= GetCurrentProcessId();
297 hal_ret
= StartDirectDrawHal(iface
, reenable
);
298 This
->lpLcl
->lpDDCB
->HELDD
.dwFlags
= 0;
302 hel_ret
= StartDirectDrawHel(iface
, reenable
);
303 This
->lpLcl
->lpDDCB
->HALDD
.dwFlags
= 0;
307 hal_ret
= StartDirectDrawHal(iface
, reenable
);
308 hel_ret
= StartDirectDrawHel(iface
, reenable
);
315 DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT\n");
316 return DDERR_NODIRECTDRAWSUPPORT
;
318 dwFlags
|= DDRAWI_NOHARDWARE
;
323 dwFlags
|= DDRAWI_NOEMULATION
;
328 dwFlags
|= DDRAWI_EMULATIONINITIALIZED
;
331 /* Fill some basic info for Surface */
332 This
->lpLcl
->lpGbl
->dwFlags
= This
->lpLcl
->lpGbl
->dwFlags
| dwFlags
| DDRAWI_ATTACHEDTODESKTOP
;
333 This
->lpLcl
->lpDDCB
= This
->lpLcl
->lpGbl
->lpDDCBtmp
;
334 This
->lpLcl
->hDD
= ddgbl
.hDD
;
336 ddgbl
.rectDevice
.bottom
= 0;
337 ddgbl
.rectDevice
.left
= 0;
338 ddgbl
.rectDevice
.right
= ddgbl
.vmiData
.dwDisplayWidth
;
339 ddgbl
.rectDevice
.right
= ddgbl
.vmiData
.dwDisplayHeight
;
341 ddgbl
.rectDesktop
.bottom
= 0;
342 ddgbl
.rectDesktop
.left
= 0;
343 ddgbl
.rectDesktop
.right
= ddgbl
.vmiData
.dwDisplayWidth
;
344 ddgbl
.rectDesktop
.right
= ddgbl
.vmiData
.dwDisplayHeight
;
346 ddgbl
.dwMonitorFrequency
= GetDeviceCaps(GetWindowDC(NULL
),VREFRESH
);
347 ddgbl
.lpModeInfo
->dwWidth
= ddgbl
.vmiData
.dwDisplayWidth
;
348 ddgbl
.lpModeInfo
->dwHeight
= ddgbl
.vmiData
.dwDisplayHeight
;
349 ddgbl
.lpModeInfo
->dwBPP
= ddgbl
.vmiData
.ddpfDisplay
.dwRGBBitCount
;
350 ddgbl
.lpModeInfo
->lPitch
= ddgbl
.vmiData
.lDisplayPitch
;
351 ddgbl
.lpModeInfo
->wRefreshRate
= ddgbl
.dwMonitorFrequency
;
352 ddgbl
.lpModeInfo
->dwRBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwRBitMask
;
353 ddgbl
.lpModeInfo
->dwGBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwGBitMask
;
354 ddgbl
.lpModeInfo
->dwBBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwBBitMask
;
355 ddgbl
.lpModeInfo
->dwAlphaBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwRGBAlphaBitMask
;
362 StartDirectDrawHel(LPDIRECTDRAW iface
, BOOL reenable
)
364 LPDDRAWI_DIRECTDRAW_INT This
= (LPDDRAWI_DIRECTDRAW_INT
)iface
;
366 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CanCreateSurface
= HelDdCanCreateSurface
;
367 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CreateSurface
= HelDdCreateSurface
;
368 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CreatePalette
= HelDdCreatePalette
;
369 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.DestroyDriver
= HelDdDestroyDriver
;
370 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.FlipToGDISurface
= HelDdFlipToGDISurface
;
371 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.GetScanLine
= HelDdGetScanLine
;
372 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetColorKey
= HelDdSetColorKey
;
373 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetExclusiveMode
= HelDdSetExclusiveMode
;
374 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetMode
= HelDdSetMode
;
375 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.WaitForVerticalBlank
= HelDdWaitForVerticalBlank
;
377 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.dwFlags
= DDHAL_CB32_CANCREATESURFACE
|
378 DDHAL_CB32_CREATESURFACE
|
379 DDHAL_CB32_CREATEPALETTE
|
380 DDHAL_CB32_DESTROYDRIVER
|
381 DDHAL_CB32_FLIPTOGDISURFACE
|
382 DDHAL_CB32_GETSCANLINE
|
383 DDHAL_CB32_SETCOLORKEY
|
384 DDHAL_CB32_SETEXCLUSIVEMODE
|
386 DDHAL_CB32_WAITFORVERTICALBLANK
;
388 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.dwSize
= sizeof(This
->lpLcl
->lpDDCB
->HELDD
);
390 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.AddAttachedSurface
= HelDdSurfAddAttachedSurface
;
391 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Blt
= HelDdSurfBlt
;
392 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.DestroySurface
= HelDdSurfDestroySurface
;
393 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Flip
= HelDdSurfFlip
;
394 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.GetBltStatus
= HelDdSurfGetBltStatus
;
395 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.GetFlipStatus
= HelDdSurfGetFlipStatus
;
396 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Lock
= HelDdSurfLock
;
397 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.reserved4
= HelDdSurfreserved4
;
398 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetClipList
= HelDdSurfSetClipList
;
399 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetColorKey
= HelDdSurfSetColorKey
;
400 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetOverlayPosition
= HelDdSurfSetOverlayPosition
;
401 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetPalette
= HelDdSurfSetPalette
;
402 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Unlock
= HelDdSurfUnlock
;
403 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.UpdateOverlay
= HelDdSurfUpdateOverlay
;
404 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.dwFlags
= DDHAL_SURFCB32_ADDATTACHEDSURFACE
|
406 DDHAL_SURFCB32_DESTROYSURFACE
|
407 DDHAL_SURFCB32_FLIP
|
408 DDHAL_SURFCB32_GETBLTSTATUS
|
409 DDHAL_SURFCB32_GETFLIPSTATUS
|
410 DDHAL_SURFCB32_LOCK
|
411 DDHAL_SURFCB32_RESERVED4
|
412 DDHAL_SURFCB32_SETCLIPLIST
|
413 DDHAL_SURFCB32_SETCOLORKEY
|
414 DDHAL_SURFCB32_SETOVERLAYPOSITION
|
415 DDHAL_SURFCB32_SETPALETTE
|
416 DDHAL_SURFCB32_UNLOCK
|
417 DDHAL_SURFCB32_UPDATEOVERLAY
;
419 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.dwSize
= sizeof(This
->lpLcl
->lpDDCB
->HELDDSurface
);
422 This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;
423 This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
424 This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
428 This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
429 This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
430 This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
431 This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
432 This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
440 StartDirectDrawHal(LPDIRECTDRAW iface
, BOOL reenable
)
442 LPDWORD mpFourCC
= NULL
;
444 BOOL newmode
= FALSE
;
445 LPDDSURFACEDESC mpTextures
;
446 D3DHAL_CALLBACKS mD3dCallbacks
;
447 D3DHAL_GLOBALDRIVERDATA mD3dDriverData
;
448 DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks
;
449 LPDDRAWI_DIRECTDRAW_INT This
= (LPDDRAWI_DIRECTDRAW_INT
)iface
;
450 DDHAL_GETDRIVERINFODATA DdGetDriverInfo
= { 0 };
454 RtlZeroMemory(&mHALInfo
, sizeof(DDHALINFO
));
455 RtlZeroMemory(&mD3dCallbacks
, sizeof(D3DHAL_CALLBACKS
));
456 RtlZeroMemory(&mD3dDriverData
, sizeof(D3DHAL_GLOBALDRIVERDATA
));
457 RtlZeroMemory(&mD3dBufferCallbacks
, sizeof(DDHAL_DDEXEBUFCALLBACKS
));
459 if (reenable
== FALSE
)
461 if (ddgbl
.lpDDCBtmp
== NULL
)
463 DxHeapMemAlloc(ddgbl
.lpDDCBtmp
, sizeof(DDHAL_CALLBACKS
));
464 if ( ddgbl
.lpDDCBtmp
== NULL
)
472 RtlZeroMemory(ddgbl
.lpDDCBtmp
,sizeof(DDHAL_CALLBACKS
));
476 * Startup DX HAL step one of three
478 if (!DdCreateDirectDrawObject(This
->lpLcl
->lpGbl
, (HDC
)This
->lpLcl
->hDC
))
480 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
484 /* Some card disable the dx after it have been created so
485 * we are force reanble it
487 if (!DdReenableDirectDrawObject(This
->lpLcl
->lpGbl
, &newmode
))
489 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
493 if (!DdQueryDirectDrawObject(This
->lpLcl
->lpGbl
,
495 &ddgbl
.lpDDCBtmp
->HALDD
,
496 &ddgbl
.lpDDCBtmp
->HALDDSurface
,
497 &ddgbl
.lpDDCBtmp
->HALDDPalette
,
500 &mD3dBufferCallbacks
,
505 DxHeapMemFree(This
->lpLcl
->lpGbl
->lpModeInfo
);
506 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
507 // FIXME Close DX fristcall and second call
512 if (This
->lpLcl
->lpGbl
->lpdwFourCC
!= NULL
)
514 DxHeapMemFree(This
->lpLcl
->lpGbl
->lpdwFourCC
);
517 if (mHALInfo
.ddCaps
.dwNumFourCCCodes
> 0 )
520 DxHeapMemAlloc(mpFourCC
, sizeof(DWORD
) * (mHALInfo
.ddCaps
.dwNumFourCCCodes
+ 2));
522 if (mpFourCC
== NULL
)
524 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
525 // FIXME Close DX fristcall and second call
530 /* Alloc mpTextures */
532 DX_STUB_str("1 Here\n");
534 if (This
->lpLcl
->lpGbl
->texture
!= NULL
)
536 DxHeapMemFree(This
->lpLcl
->lpGbl
->texture
;
540 if (mD3dDriverData
.dwNumTextureFormats
> 0)
542 mpTextures
= (DDSURFACEDESC
*) DxHeapMemAlloc(sizeof(DDSURFACEDESC
) * mD3dDriverData
.dwNumTextureFormats
);
543 if (mpTextures
== NULL
)
545 DxHeapMemFree(mpFourCC
);
546 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
547 // FIXME Close DX fristcall and second call
551 DX_STUB_str("2 Here\n");
558 /* Get all basic data from the driver */
559 if (!DdQueryDirectDrawObject(
562 &ddgbl
.lpDDCBtmp
->HALDD
,
563 &ddgbl
.lpDDCBtmp
->HALDDSurface
,
564 &ddgbl
.lpDDCBtmp
->HALDDPalette
,
567 &ddgbl
.lpDDCBtmp
->HALDDExeBuf
,
568 (DDSURFACEDESC
*)mpTextures
,
572 DxHeapMemFree(mpFourCC
);
573 DxHeapMemFree(mpTextures
);
574 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
575 // FIXME Close DX fristcall and second call
579 memcpy(&ddgbl
.vmiData
, &mHALInfo
.vmiData
,sizeof(VIDMEMINFO
));
582 memcpy(&ddgbl
.ddCaps
, &mHALInfo
.ddCaps
,sizeof(DDCORECAPS
));
584 This
->lpLcl
->lpGbl
->dwNumFourCC
= mHALInfo
.ddCaps
.dwNumFourCCCodes
;
585 This
->lpLcl
->lpGbl
->lpdwFourCC
= mpFourCC
;
586 // This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency; // 0
587 This
->lpLcl
->lpGbl
->dwModeIndex
= mHALInfo
.dwModeIndex
;
588 // This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes;
589 // This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo;
591 /* FIXME convert mpTextures to DDHALMODEINFO */
592 // DxHeapMemFree( mpTextures);
594 /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */
599 if (mHALInfo
.dwFlags
& DDHALINFO_GETDRIVERINFOSET
)
601 DdGetDriverInfo
.dwSize
= sizeof (DDHAL_GETDRIVERINFODATA
);
602 DdGetDriverInfo
.guidInfo
= GUID_MiscellaneousCallbacks
;
603 DdGetDriverInfo
.lpvData
= (PVOID
)&ddgbl
.lpDDCBtmp
->HALDDMiscellaneous
;
604 DdGetDriverInfo
.dwExpectedSize
= sizeof (DDHAL_DDMISCELLANEOUSCALLBACKS
);
606 if(mHALInfo
.GetDriverInfo (&DdGetDriverInfo
) == DDHAL_DRIVER_NOTHANDLED
|| DdGetDriverInfo
.ddRVal
!= DD_OK
)
608 DxHeapMemFree(mpFourCC
);
609 DxHeapMemFree(mpTextures
);
610 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
611 // FIXME Close DX fristcall and second call
615 RtlZeroMemory(&DdGetDriverInfo
, sizeof(DDHAL_GETDRIVERINFODATA
));
616 DdGetDriverInfo
.dwSize
= sizeof (DDHAL_GETDRIVERINFODATA
);
617 DdGetDriverInfo
.guidInfo
= GUID_Miscellaneous2Callbacks
;
620 DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
621 DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUS2CALLBACKS);
623 if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
625 DxHeapMemFree(mpFourCC);
626 DxHeapMemFree(mpTextures);
627 DxHeapMemFree(ddgbl.lpDDCBtmp);
628 // FIXME Close DX fristcall and second call
631 DD_MISCELLANEOUS2CALLBACKS
635 PDD_ALPHABLT AlphaBlt; // unsuse acoding msdn and always set to NULL
636 PDD_CREATESURFACEEX CreateSurfaceEx;
637 PDD_GETDRIVERSTATE GetDriverState;
638 PDD_DESTROYDDLOCAL DestroyDDLocal;
640 DDHAL_MISC2CB32_CREATESURFACEEX
641 DDHAL_MISC2CB32_GETDRIVERSTATE
642 DDHAL_MISC2CB32_DESTROYDDLOCAL
646 if (mHALInfo
.dwFlags
& DDHALINFO_GETDRIVERINFO2
)
648 This
->lpLcl
->lpGbl
->dwFlags
= This
->lpLcl
->lpGbl
->dwFlags
| DDRAWI_DRIVERINFO2
;