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;
182 * ddgbl.dwPDevice is not longer in use in windows 2000 and higher
183 * I am using it for device type
184 * devicetypes = 1 : both hal and hel are enable
185 * devicetypes = 2 : both hal are enable
186 * devicetypes = 3 : both hel are enable
187 * devicetypes = 4 :loading a guid drv from the register
190 ddgbl
.lpDriverHandle
= &ddgbl
;
193 if (reenable
== FALSE
)
195 if ((!IsBadReadPtr(This
->lpLink
,sizeof(LPDIRECTDRAW
))) && (This
->lpLink
== NULL
))
197 RtlZeroMemory(&ddgbl
, sizeof(DDRAWI_DIRECTDRAW_GBL
));
198 This
->lpLcl
->lpGbl
->dwRefCnt
++;
199 if (ddgbl
.lpDDCBtmp
== NULL
)
202 DxHeapMemAlloc( ddgbl
.lpDDCBtmp
, sizeof(DDHAL_CALLBACKS
));
203 if (ddgbl
.lpDDCBtmp
== NULL
)
205 DX_STUB_str("Out of memmory\n");
211 /* Windows handler are by set of SetCooperLevel
215 if (reenable
== FALSE
)
219 DX_STUB_str("lpGuid == NULL\n");
222 /* Create HDC for default, hal and hel driver */
223 // This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
224 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
226 /* cObsolete is undoc in msdn it being use in CreateDCA */
227 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
228 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
229 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
233 else if (lpGuid
== (LPGUID
) DDCREATE_HARDWAREONLY
)
236 /* Create HDC for default, hal driver */
237 // This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
238 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
240 /* cObsolete is undoc in msdn it being use in CreateDCA */
241 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
242 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
243 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
245 else if (lpGuid
== (LPGUID
) DDCREATE_EMULATIONONLY
)
249 /* Create HDC for default, hal and hel driver */
250 //This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
251 This
->lpLcl
->hDC
= (ULONG_PTR
)CreateDCA("DISPLAY",NULL
,NULL
,NULL
);
253 /* cObsolete is undoc in msdn it being use in CreateDCA */
254 RtlCopyMemory(&ddgbl
.cObsolete
,&"DISPLAY",7);
255 RtlCopyMemory(&ddgbl
.cDriverName
,&"DISPLAY",7);
257 dwFlags
|= DDRAWI_DISPLAYDRV
| DDRAWI_GDIDRV
;
261 /* FIXME : need getting driver from the GUID that have been pass in from
262 * the register. we do not support that yet
265 //This->lpLcl->hDC = (ULONG_PTR) NULL ;
266 //This->lpLcl->hDC = (ULONG_PTR)CreateDCA("DISPLAY",NULL,NULL,NULL);
270 if ( (HDC)This->lpLcl->hDC == NULL)
272 DX_STUB_str("DDERR_OUTOFMEMORY\n");
273 return DDERR_OUTOFMEMORY ;
278 This
->lpLcl
->lpDDCB
= ddgbl
.lpDDCBtmp
;
280 /* Startup HEL and HAL */
281 This
->lpLcl
->lpDDCB
= This
->lpLcl
->lpGbl
->lpDDCBtmp
;
282 This
->lpLcl
->dwProcessId
= GetCurrentProcessId();
287 hal_ret
= StartDirectDrawHal(iface
, reenable
);
288 This
->lpLcl
->lpDDCB
->HELDD
.dwFlags
= 0;
292 hel_ret
= StartDirectDrawHel(iface
, reenable
);
293 This
->lpLcl
->lpDDCB
->HALDD
.dwFlags
= 0;
297 hal_ret
= StartDirectDrawHal(iface
, reenable
);
298 hel_ret
= StartDirectDrawHel(iface
, reenable
);
301 DX_STUB_str("return\n");
307 DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT\n");
308 return DDERR_NODIRECTDRAWSUPPORT
;
310 dwFlags
|= DDRAWI_NOHARDWARE
;
315 dwFlags
|= DDRAWI_NOEMULATION
;
320 dwFlags
|= DDRAWI_EMULATIONINITIALIZED
;
323 /* Fill some basic info for Surface */
324 This
->lpLcl
->lpGbl
->dwFlags
= This
->lpLcl
->lpGbl
->dwFlags
| dwFlags
| DDRAWI_ATTACHEDTODESKTOP
;
325 This
->lpLcl
->lpDDCB
= This
->lpLcl
->lpGbl
->lpDDCBtmp
;
326 This
->lpLcl
->hDD
= ddgbl
.hDD
;
328 ddgbl
.rectDevice
.bottom
= 0;
329 ddgbl
.rectDevice
.left
= 0;
330 ddgbl
.rectDevice
.right
= ddgbl
.vmiData
.dwDisplayWidth
;
331 ddgbl
.rectDevice
.right
= ddgbl
.vmiData
.dwDisplayHeight
;
333 ddgbl
.rectDesktop
.bottom
= 0;
334 ddgbl
.rectDesktop
.left
= 0;
335 ddgbl
.rectDesktop
.right
= ddgbl
.vmiData
.dwDisplayWidth
;
336 ddgbl
.rectDesktop
.right
= ddgbl
.vmiData
.dwDisplayHeight
;
339 /* HALINFO always returen false for lpModeInfo */
340 DxHeapMemAlloc(ddgbl
.lpModeInfo
, sizeof(DDHALMODEINFO
));
341 if (!ddgbl
.lpModeInfo
)
343 return DDERR_OUTOFMEMORY
;
347 EnumDisplaySettings(NULL
, ENUM_CURRENT_SETTINGS
, &devmode
);
348 ddgbl
.lpModeInfo
->dwWidth
= devmode
.dmPelsWidth
;
349 ddgbl
.lpModeInfo
->dwHeight
= devmode
.dmPelsHeight
;
350 ddgbl
.lpModeInfo
->dwBPP
= devmode
.dmBitsPerPel
;
351 ddgbl
.lpModeInfo
->lPitch
= ddgbl
.vmiData
.lDisplayPitch
;
352 ddgbl
.lpModeInfo
->wRefreshRate
= (WORD
)devmode
.dmDisplayFrequency
;
353 ddgbl
.lpModeInfo
->dwRBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwRBitMask
;
354 ddgbl
.lpModeInfo
->dwGBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwGBitMask
;
355 ddgbl
.lpModeInfo
->dwBBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwBBitMask
;
356 ddgbl
.lpModeInfo
->dwAlphaBitMask
= ddgbl
.vmiData
.ddpfDisplay
.dwRGBAlphaBitMask
;
357 ddgbl
.dwMonitorFrequency
= ddgbl
.lpModeInfo
->wRefreshRate
;
358 ddgbl
.dwNumModes
= 1;
359 ddgbl
.dwSaveNumModes
= 1;
361 DX_STUB_str("DD_OK\n");
366 StartDirectDrawHel(LPDIRECTDRAW iface
, BOOL reenable
)
368 LPDDRAWI_DIRECTDRAW_INT This
= (LPDDRAWI_DIRECTDRAW_INT
)iface
;
370 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CanCreateSurface
= HelDdCanCreateSurface
;
371 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CreateSurface
= HelDdCreateSurface
;
372 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.CreatePalette
= HelDdCreatePalette
;
373 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.DestroyDriver
= HelDdDestroyDriver
;
374 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.FlipToGDISurface
= HelDdFlipToGDISurface
;
375 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.GetScanLine
= HelDdGetScanLine
;
376 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetColorKey
= HelDdSetColorKey
;
377 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetExclusiveMode
= HelDdSetExclusiveMode
;
378 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.SetMode
= HelDdSetMode
;
379 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.WaitForVerticalBlank
= HelDdWaitForVerticalBlank
;
381 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.dwFlags
= DDHAL_CB32_CANCREATESURFACE
|
382 DDHAL_CB32_CREATESURFACE
|
383 DDHAL_CB32_CREATEPALETTE
|
384 DDHAL_CB32_DESTROYDRIVER
|
385 DDHAL_CB32_FLIPTOGDISURFACE
|
386 DDHAL_CB32_GETSCANLINE
|
387 DDHAL_CB32_SETCOLORKEY
|
388 DDHAL_CB32_SETEXCLUSIVEMODE
|
390 DDHAL_CB32_WAITFORVERTICALBLANK
;
392 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDD
.dwSize
= sizeof(This
->lpLcl
->lpDDCB
->HELDD
);
394 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.AddAttachedSurface
= HelDdSurfAddAttachedSurface
;
395 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Blt
= HelDdSurfBlt
;
396 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.DestroySurface
= HelDdSurfDestroySurface
;
397 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Flip
= HelDdSurfFlip
;
398 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.GetBltStatus
= HelDdSurfGetBltStatus
;
399 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.GetFlipStatus
= HelDdSurfGetFlipStatus
;
400 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Lock
= HelDdSurfLock
;
401 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.reserved4
= HelDdSurfreserved4
;
402 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetClipList
= HelDdSurfSetClipList
;
403 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetColorKey
= HelDdSurfSetColorKey
;
404 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetOverlayPosition
= HelDdSurfSetOverlayPosition
;
405 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.SetPalette
= HelDdSurfSetPalette
;
406 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.Unlock
= HelDdSurfUnlock
;
407 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.UpdateOverlay
= HelDdSurfUpdateOverlay
;
408 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.dwFlags
= DDHAL_SURFCB32_ADDATTACHEDSURFACE
|
410 DDHAL_SURFCB32_DESTROYSURFACE
|
411 DDHAL_SURFCB32_FLIP
|
412 DDHAL_SURFCB32_GETBLTSTATUS
|
413 DDHAL_SURFCB32_GETFLIPSTATUS
|
414 DDHAL_SURFCB32_LOCK
|
415 DDHAL_SURFCB32_RESERVED4
|
416 DDHAL_SURFCB32_SETCLIPLIST
|
417 DDHAL_SURFCB32_SETCOLORKEY
|
418 DDHAL_SURFCB32_SETOVERLAYPOSITION
|
419 DDHAL_SURFCB32_SETPALETTE
|
420 DDHAL_SURFCB32_UNLOCK
|
421 DDHAL_SURFCB32_UPDATEOVERLAY
;
423 This
->lpLcl
->lpGbl
->lpDDCBtmp
->HELDDSurface
.dwSize
= sizeof(This
->lpLcl
->lpDDCB
->HELDDSurface
);
426 This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;
427 This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
428 This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
432 This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
433 This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
434 This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
435 This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
436 This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
444 StartDirectDrawHal(LPDIRECTDRAW iface
, BOOL reenable
)
446 LPDWORD mpFourCC
= NULL
;
448 BOOL newmode
= FALSE
;
449 LPDDSURFACEDESC mpTextures
;
450 D3DHAL_CALLBACKS mD3dCallbacks
;
451 D3DHAL_GLOBALDRIVERDATA mD3dDriverData
;
452 DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks
;
453 LPDDRAWI_DIRECTDRAW_INT This
= (LPDDRAWI_DIRECTDRAW_INT
)iface
;
454 DDHAL_GETDRIVERINFODATA DdGetDriverInfo
= { 0 };
458 RtlZeroMemory(&mHALInfo
, sizeof(DDHALINFO
));
459 RtlZeroMemory(&mD3dCallbacks
, sizeof(D3DHAL_CALLBACKS
));
460 RtlZeroMemory(&mD3dDriverData
, sizeof(D3DHAL_GLOBALDRIVERDATA
));
461 RtlZeroMemory(&mD3dBufferCallbacks
, sizeof(DDHAL_DDEXEBUFCALLBACKS
));
463 if (reenable
== FALSE
)
465 if (ddgbl
.lpDDCBtmp
== NULL
)
467 DxHeapMemAlloc(ddgbl
.lpDDCBtmp
, sizeof(DDHAL_CALLBACKS
));
468 if ( ddgbl
.lpDDCBtmp
== NULL
)
476 RtlZeroMemory(ddgbl
.lpDDCBtmp
,sizeof(DDHAL_CALLBACKS
));
480 * Startup DX HAL step one of three
482 if (!DdCreateDirectDrawObject(This
->lpLcl
->lpGbl
, (HDC
)This
->lpLcl
->hDC
))
484 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
488 /* Some card disable the dx after it have been created so
489 * we are force reanble it
491 if (!DdReenableDirectDrawObject(This
->lpLcl
->lpGbl
, &newmode
))
493 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
497 if (!DdQueryDirectDrawObject(This
->lpLcl
->lpGbl
,
499 &ddgbl
.lpDDCBtmp
->HALDD
,
500 &ddgbl
.lpDDCBtmp
->HALDDSurface
,
501 &ddgbl
.lpDDCBtmp
->HALDDPalette
,
504 &mD3dBufferCallbacks
,
509 DxHeapMemFree(This
->lpLcl
->lpGbl
->lpModeInfo
);
510 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
511 // FIXME Close DX fristcall and second call
515 DX_STUB_str("Trying alloc FourCCC \n");
518 if (This
->lpLcl
->lpGbl
->lpdwFourCC
!= NULL
)
520 DxHeapMemFree(This
->lpLcl
->lpGbl
->lpdwFourCC
);
523 if (mHALInfo
.ddCaps
.dwNumFourCCCodes
> 0 )
526 DxHeapMemAlloc(mpFourCC
, sizeof(DWORD
) * (mHALInfo
.ddCaps
.dwNumFourCCCodes
+ 2));
528 if (mpFourCC
== NULL
)
530 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
531 // FIXME Close DX fristcall and second call
536 DX_STUB_str("End Trying alloc FourCCC\n");
542 /* Alloc mpTextures */
544 DX_STUB_str("1 Here\n");
547 if (This->lpLcl->lpGbl->texture != NULL)
549 DxHeapMemFree(This->lpLcl->lpGbl->);
554 if (mD3dDriverData
.dwNumTextureFormats
> 0)
556 DxHeapMemAlloc(mpTextures
, sizeof(DDSURFACEDESC
) * mD3dDriverData
.dwNumTextureFormats
);
557 if (mpTextures
== NULL
)
559 DxHeapMemFree(mpFourCC
);
560 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
561 // FIXME Close DX fristcall and second call
565 DX_STUB_str("2 Here\n");
570 /* Get all basic data from the driver */
571 if (!DdQueryDirectDrawObject(
574 &ddgbl
.lpDDCBtmp
->HALDD
,
575 &ddgbl
.lpDDCBtmp
->HALDDSurface
,
576 &ddgbl
.lpDDCBtmp
->HALDDPalette
,
579 &ddgbl
.lpDDCBtmp
->HALDDExeBuf
,
580 (DDSURFACEDESC
*)mpTextures
,
584 DxHeapMemFree(mpFourCC
);
585 DxHeapMemFree(mpTextures
);
586 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
587 // FIXME Close DX fristcall and second call
591 memcpy(&ddgbl
.vmiData
, &mHALInfo
.vmiData
,sizeof(VIDMEMINFO
));
594 memcpy(&ddgbl
.ddCaps
, &mHALInfo
.ddCaps
,sizeof(DDCORECAPS
));
596 This
->lpLcl
->lpGbl
->dwNumFourCC
= mHALInfo
.ddCaps
.dwNumFourCCCodes
;
597 This
->lpLcl
->lpGbl
->lpdwFourCC
= mpFourCC
;
598 // This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency; // 0
599 This
->lpLcl
->lpGbl
->dwModeIndex
= mHALInfo
.dwModeIndex
;
600 // This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes;
601 // This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo;
603 DX_STUB_str("Here\n");
605 /* FIXME convert mpTextures to DDHALMODEINFO */
606 // DxHeapMemFree( mpTextures);
608 /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */
613 if (mHALInfo
.dwFlags
& DDHALINFO_GETDRIVERINFOSET
)
615 DdGetDriverInfo
.dwSize
= sizeof (DDHAL_GETDRIVERINFODATA
);
616 DdGetDriverInfo
.guidInfo
= GUID_MiscellaneousCallbacks
;
617 DdGetDriverInfo
.lpvData
= (PVOID
)&ddgbl
.lpDDCBtmp
->HALDDMiscellaneous
;
618 DdGetDriverInfo
.dwExpectedSize
= sizeof (DDHAL_DDMISCELLANEOUSCALLBACKS
);
620 if(mHALInfo
.GetDriverInfo (&DdGetDriverInfo
) == DDHAL_DRIVER_NOTHANDLED
|| DdGetDriverInfo
.ddRVal
!= DD_OK
)
622 DxHeapMemFree(mpFourCC
);
623 DxHeapMemFree(mpTextures
);
624 DxHeapMemFree(ddgbl
.lpDDCBtmp
);
625 // FIXME Close DX fristcall and second call
629 RtlZeroMemory(&DdGetDriverInfo
, sizeof(DDHAL_GETDRIVERINFODATA
));
630 DdGetDriverInfo
.dwSize
= sizeof (DDHAL_GETDRIVERINFODATA
);
631 DdGetDriverInfo
.guidInfo
= GUID_Miscellaneous2Callbacks
;
634 DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
635 DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUS2CALLBACKS);
637 if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
639 DxHeapMemFree(mpFourCC);
640 DxHeapMemFree(mpTextures);
641 DxHeapMemFree(ddgbl.lpDDCBtmp);
642 // FIXME Close DX fristcall and second call
645 DD_MISCELLANEOUS2CALLBACKS
649 PDD_ALPHABLT AlphaBlt; // unsuse acoding msdn and always set to NULL
650 PDD_CREATESURFACEEX CreateSurfaceEx;
651 PDD_GETDRIVERSTATE GetDriverState;
652 PDD_DESTROYDDLOCAL DestroyDDLocal;
654 DDHAL_MISC2CB32_CREATESURFACEEX
655 DDHAL_MISC2CB32_GETDRIVERSTATE
656 DDHAL_MISC2CB32_DESTROYDDLOCAL
660 if (mHALInfo
.dwFlags
& DDHALINFO_GETDRIVERINFO2
)
662 This
->lpLcl
->lpGbl
->dwFlags
= This
->lpLcl
->lpGbl
->dwFlags
| DDRAWI_DRIVERINFO2
;