Fixed one weird crash, please type make draw_clean 3 times so it gurated be clean...
[reactos.git] / reactos / dll / directx / ddraw / startup.c
1 /* $Id: main.c 21434 2006-04-01 19:12:56Z greatlrd $
2 *
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)
8 *
9 */
10
11 #include "rosdraw.h"
12 #include "ddrawgdi.h"
13
14 DDRAWI_DIRECTDRAW_GBL ddgbl;
15 DDRAWI_DDRAWSURFACE_GBL ddSurfGbl;
16
17 WCHAR classname[128];
18 WNDCLASSW wnd_class;
19
20
21 HRESULT WINAPI
22 Create_DirectDraw (LPGUID pGUID, LPDIRECTDRAW* pIface,
23 REFIID id, BOOL ex)
24 {
25 LPDDRAWI_DIRECTDRAW_INT This;
26
27 DX_WINDBG_trace();
28
29 if ((IsBadReadPtr(pIface,sizeof(LPDIRECTDRAW))) ||
30 (IsBadWritePtr(pIface,sizeof(LPDIRECTDRAW))))
31 {
32 return DDERR_INVALIDPARAMS;
33 }
34
35 DX_STUB_str("here\n");
36
37 This = (LPDDRAWI_DIRECTDRAW_INT)*pIface;
38
39 /* fixme linking too second link when we shall not doing it */
40 if (IsBadReadPtr(This,sizeof(LPDIRECTDRAW)))
41 {
42 DX_STUB_str("1. no linking\n");
43 /* We do not have a DirectDraw interface, we need alloc it*/
44 LPDDRAWI_DIRECTDRAW_INT memThis;
45
46 DX_STUB_str("here\n");
47
48 DxHeapMemAlloc(memThis, sizeof(DDRAWI_DIRECTDRAW_INT));
49
50 DX_STUB_str("here\n")
51
52 if (memThis == NULL)
53 {
54 DX_STUB_str("DDERR_OUTOFMEMORY\n");
55 return DDERR_OUTOFMEMORY;
56 }
57
58 This = memThis;
59
60
61 DX_STUB_str("here\n");
62
63 /* Fixme release memory alloc if we fail */
64 DxHeapMemAlloc(This->lpLcl, sizeof(DDRAWI_DIRECTDRAW_INT));
65 if (This->lpLcl == NULL)
66 {
67 DX_STUB_str("DDERR_OUTOFMEMORY\n");
68 return DDERR_OUTOFMEMORY;
69 }
70
71 DX_STUB_str("here\n");
72 }
73 else
74 {
75 DX_STUB_str("2.linking\n");
76 /* We got the DirectDraw interface alloc and we need create the link */
77 LPDDRAWI_DIRECTDRAW_INT newThis;
78
79 DX_STUB_str("here\n");
80
81 /* step 1.Alloc the new DDRAWI_DIRECTDRAW_INT for the lnking */
82 DxHeapMemAlloc(newThis, sizeof(DDRAWI_DIRECTDRAW_INT));
83 if (newThis == NULL)
84 {
85 DX_STUB_str("DDERR_OUTOFMEMORY\n");
86 return DDERR_OUTOFMEMORY;
87 }
88
89 DX_STUB_str("here\n");
90
91 /* step 2 check if it not DDCREATE_HARDWAREONLY we got if so we fail */
92 if ((pGUID) && (pGUID != (LPGUID)DDCREATE_HARDWAREONLY))
93 {
94 if (pGUID !=NULL)
95 {
96 This = newThis;
97 DX_STUB_str("DDERR_INVALIDDIRECTDRAWGUID\n");
98 return DDERR_INVALIDDIRECTDRAWGUID;
99 }
100 }
101
102 DX_STUB_str("here\n");
103
104 /* step 3 do the link the old interface are store in the new one */
105 newThis->lpLink = This;
106
107 /* step 4 we need create new local directdraw struct for the new linked interface */
108 DxHeapMemAlloc(newThis->lpLcl, sizeof(DDRAWI_DIRECTDRAW_LCL));
109 if (newThis->lpLcl == NULL)
110 {
111 This = newThis;
112 DX_STUB_str("DDERR_OUTOFMEMORY\n");
113 return DDERR_OUTOFMEMORY;
114 }
115
116 DX_STUB_str("here\n");
117
118 This = newThis;
119 }
120
121
122 This->lpLcl->lpGbl = &ddgbl;
123
124 *pIface = (LPDIRECTDRAW)This;
125
126 /* Get right interface we whant */
127 if (Main_DirectDraw_QueryInterface((LPDIRECTDRAW7)This, id, (void**)&pIface) == DD_OK)
128 {
129 DX_STUB_str("Got iface\n");
130
131 if (StartDirectDraw((LPDIRECTDRAW)This, pGUID, FALSE) == DD_OK);
132 {
133 /*
134 RtlZeroMemory(&wnd_class, sizeof(wnd_class));
135 wnd_class.style = CS_HREDRAW | CS_VREDRAW;
136 wnd_class.lpfnWndProc = DefWindowProcW;
137 wnd_class.cbClsExtra = 0;
138 wnd_class.cbWndExtra = 0;
139 wnd_class.hInstance = GetModuleHandleW(0);
140 wnd_class.hIcon = 0;
141 wnd_class.hCursor = 0;
142 wnd_class.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
143 wnd_class.lpszMenuName = NULL;
144 wnd_class.lpszClassName = classname;
145 if(!RegisterClassW(&wnd_class))
146 {
147 DX_STUB_str("DDERR_GENERIC");
148 return DDERR_GENERIC;
149 }
150 */
151
152 DX_STUB_str("DD_OK\n");
153 return DD_OK;
154 }
155 }
156
157 DX_STUB_str("DDERR_INVALIDPARAMS\n");
158 return DDERR_INVALIDPARAMS;
159 }
160
161
162 HRESULT WINAPI
163 StartDirectDraw(LPDIRECTDRAW iface, LPGUID lpGuid, BOOL reenable)
164 {
165 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
166 DWORD hal_ret = DD_FALSE;
167 DWORD hel_ret = DD_FALSE;
168 DWORD devicetypes = 0;
169 DWORD dwFlags = 0;
170
171 DX_WINDBG_trace();
172
173 /*
174 * ddgbl.dwPDevice is not longer in use in windows 2000 and higher
175 * I am using it for device type
176 * devicetypes = 1 : both hal and hel are enable
177 * devicetypes = 2 : both hal are enable
178 * devicetypes = 3 : both hel are enable
179 * devicetypes = 4 :loading a guid drv from the register
180 */
181
182 if (reenable == FALSE)
183 {
184 if ((!IsBadReadPtr(This->lpLink,sizeof(LPDIRECTDRAW))) && (This->lpLink == NULL))
185 {
186 RtlZeroMemory(&ddgbl, sizeof(DDRAWI_DIRECTDRAW_GBL));
187 This->lpLcl->lpGbl->dwRefCnt++;
188 if (ddgbl.lpDDCBtmp == NULL)
189 {
190 // LPDDHAL_CALLBACKS
191 DxHeapMemAlloc( ddgbl.lpDDCBtmp , sizeof(DDHAL_CALLBACKS));
192 if (ddgbl.lpDDCBtmp == NULL)
193 {
194 DX_STUB_str("Out of memmory\n");
195 return DD_FALSE;
196 }
197 }
198 }
199 }
200
201 DX_STUB_str("here\n");
202
203 if (reenable == FALSE)
204 {
205 if (lpGuid == NULL)
206 {
207 DX_STUB_str("lpGuid == NULL\n");
208 devicetypes= 1;
209
210 /* Create HDC for default, hal and hel driver */
211 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
212 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
213
214 /* cObsolete is undoc in msdn it being use in CreateDCA */
215 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
216 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
217 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
218
219
220 }
221 else if (lpGuid == (LPGUID) DDCREATE_HARDWAREONLY)
222 {
223 devicetypes = 2;
224 /* Create HDC for default, hal driver */
225 This->lpLcl->hWnd =(ULONG_PTR) GetActiveWindow();
226 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
227
228 /* cObsolete is undoc in msdn it being use in CreateDCA */
229 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
230 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
231 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
232 }
233 else if (lpGuid == (LPGUID) DDCREATE_EMULATIONONLY)
234 {
235 devicetypes = 3;
236
237 /* Create HDC for default, hal and hel driver */
238 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
239 This->lpLcl->hDC = (ULONG_PTR) GetDC((HWND)This->lpLcl->hWnd);
240
241 /* cObsolete is undoc in msdn it being use in CreateDCA */
242 RtlCopyMemory(&ddgbl.cObsolete,&"DISPLAY",7);
243 RtlCopyMemory(&ddgbl.cDriverName,&"DISPLAY",7);
244
245 dwFlags |= DDRAWI_DISPLAYDRV | DDRAWI_GDIDRV;
246 }
247 else
248 {
249 /* FIXME : need getting driver from the GUID that have been pass in from
250 * the register. we do not support that yet
251 */
252 devicetypes = 4;
253 This->lpLcl->hDC = (ULONG_PTR) NULL ;
254 This->lpLcl->hWnd = (ULONG_PTR) GetActiveWindow();
255 }
256
257 if ( (HDC)This->lpLcl->hDC == NULL)
258 {
259 DX_STUB_str("DDERR_OUTOFMEMORY\n");
260 return DDERR_OUTOFMEMORY ;
261 }
262 }
263
264 This->lpLcl->lpDDCB = ddgbl.lpDDCBtmp;
265
266 /* Startup HEL and HAL */
267 This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
268 This->lpLcl->dwProcessId = GetCurrentProcessId();
269
270 switch (devicetypes)
271 {
272 case 2:
273 hal_ret = StartDirectDrawHal(iface, reenable);
274 This->lpLcl->lpDDCB->HELDD.dwFlags = 0;
275 break;
276
277 case 3:
278 hel_ret = StartDirectDrawHel(iface, reenable);
279 This->lpLcl->lpDDCB->HALDD.dwFlags = 0;
280 break;
281
282 default:
283 hal_ret = StartDirectDrawHal(iface, reenable);
284 hel_ret = StartDirectDrawHel(iface, reenable);
285 }
286
287 DX_STUB_str("return\n");
288
289 if (hal_ret!=DD_OK)
290 {
291 if (hel_ret!=DD_OK)
292 {
293 DX_STUB_str("DDERR_NODIRECTDRAWSUPPORT\n");
294 return DDERR_NODIRECTDRAWSUPPORT;
295 }
296 dwFlags |= DDRAWI_NOHARDWARE;
297 }
298
299 if (hel_ret!=DD_OK)
300 {
301 dwFlags |= DDRAWI_NOEMULATION;
302
303 }
304 else
305 {
306 dwFlags |= DDRAWI_EMULATIONINITIALIZED;
307 }
308
309 /* Fill some basic info for Surface */
310 This->lpLcl->lpGbl->dwFlags = dwFlags | DDRAWI_ATTACHEDTODESKTOP;
311 This->lpLcl->lpDDCB = This->lpLcl->lpGbl->lpDDCBtmp;
312 This->lpLcl->hDD = This->lpLcl->lpGbl->hDD;
313 ddgbl.hDD = This->lpLcl->lpGbl->hDD;
314
315 DX_STUB_str("DD_OK\n");
316 return DD_OK;
317 }
318
319 HRESULT WINAPI
320 StartDirectDrawHel(LPDIRECTDRAW iface, BOOL reenable)
321 {
322 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
323
324 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CanCreateSurface = HelDdCanCreateSurface;
325 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreateSurface = HelDdCreateSurface;
326 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.CreatePalette = HelDdCreatePalette;
327 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.DestroyDriver = HelDdDestroyDriver;
328 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.FlipToGDISurface = HelDdFlipToGDISurface;
329 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.GetScanLine = HelDdGetScanLine;
330 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetColorKey = HelDdSetColorKey;
331 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetExclusiveMode = HelDdSetExclusiveMode;
332 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.SetMode = HelDdSetMode;
333 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.WaitForVerticalBlank = HelDdWaitForVerticalBlank;
334
335 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwFlags = DDHAL_CB32_CANCREATESURFACE |
336 DDHAL_CB32_CREATESURFACE |
337 DDHAL_CB32_CREATEPALETTE |
338 DDHAL_CB32_DESTROYDRIVER |
339 DDHAL_CB32_FLIPTOGDISURFACE |
340 DDHAL_CB32_GETSCANLINE |
341 DDHAL_CB32_SETCOLORKEY |
342 DDHAL_CB32_SETEXCLUSIVEMODE |
343 DDHAL_CB32_SETMODE |
344 DDHAL_CB32_WAITFORVERTICALBLANK ;
345
346 This->lpLcl->lpGbl->lpDDCBtmp->HELDD.dwSize = sizeof(This->lpLcl->lpDDCB->HELDD);
347
348 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.AddAttachedSurface = HelDdSurfAddAttachedSurface;
349 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Blt = HelDdSurfBlt;
350 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.DestroySurface = HelDdSurfDestroySurface;
351 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Flip = HelDdSurfFlip;
352 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetBltStatus = HelDdSurfGetBltStatus;
353 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.GetFlipStatus = HelDdSurfGetFlipStatus;
354 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Lock = HelDdSurfLock;
355 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.reserved4 = HelDdSurfreserved4;
356 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetClipList = HelDdSurfSetClipList;
357 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetColorKey = HelDdSurfSetColorKey;
358 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetOverlayPosition = HelDdSurfSetOverlayPosition;
359 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.SetPalette = HelDdSurfSetPalette;
360 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.Unlock = HelDdSurfUnlock;
361 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.UpdateOverlay = HelDdSurfUpdateOverlay;
362 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwFlags = DDHAL_SURFCB32_ADDATTACHEDSURFACE |
363 DDHAL_SURFCB32_BLT |
364 DDHAL_SURFCB32_DESTROYSURFACE |
365 DDHAL_SURFCB32_FLIP |
366 DDHAL_SURFCB32_GETBLTSTATUS |
367 DDHAL_SURFCB32_GETFLIPSTATUS |
368 DDHAL_SURFCB32_LOCK |
369 DDHAL_SURFCB32_RESERVED4 |
370 DDHAL_SURFCB32_SETCLIPLIST |
371 DDHAL_SURFCB32_SETCOLORKEY |
372 DDHAL_SURFCB32_SETOVERLAYPOSITION |
373 DDHAL_SURFCB32_SETPALETTE |
374 DDHAL_SURFCB32_UNLOCK |
375 DDHAL_SURFCB32_UPDATEOVERLAY;
376
377 This->lpLcl->lpGbl->lpDDCBtmp->HELDDSurface.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDSurface);
378
379 /*
380 This->lpLcl->lpDDCB->HELDDPalette.DestroyPalette = HelDdPalDestroyPalette;
381 This->lpLcl->lpDDCB->HELDDPalette.SetEntries = HelDdPalSetEntries;
382 This->lpLcl->lpDDCB->HELDDPalette.dwSize = sizeof(This->lpLcl->lpDDCB->HELDDPalette);
383 */
384
385 /*
386 This->lpLcl->lpDDCB->HELDDExeBuf.CanCreateExecuteBuffer = HelDdExeCanCreateExecuteBuffer;
387 This->lpLcl->lpDDCB->HELDDExeBuf.CreateExecuteBuffer = HelDdExeCreateExecuteBuffer;
388 This->lpLcl->lpDDCB->HELDDExeBuf.DestroyExecuteBuffer = HelDdExeDestroyExecuteBuffer;
389 This->lpLcl->lpDDCB->HELDDExeBuf.LockExecuteBuffer = HelDdExeLockExecuteBuffer;
390 This->lpLcl->lpDDCB->HELDDExeBuf.UnlockExecuteBuffer = HelDdExeUnlockExecuteBuffer;
391 */
392
393 return DD_OK;
394 }
395
396
397 HRESULT WINAPI
398 StartDirectDrawHal(LPDIRECTDRAW iface, BOOL reenable)
399 {
400 LPDWORD mpFourCC = NULL;
401 DDHALINFO mHALInfo;
402 BOOL newmode = FALSE;
403 LPDDSURFACEDESC mpTextures;
404 D3DHAL_CALLBACKS mD3dCallbacks;
405 D3DHAL_GLOBALDRIVERDATA mD3dDriverData;
406 DDHAL_DDEXEBUFCALLBACKS mD3dBufferCallbacks;
407 LPDDRAWI_DIRECTDRAW_INT This = (LPDDRAWI_DIRECTDRAW_INT)iface;
408
409 DX_WINDBG_trace();
410
411 RtlZeroMemory(&mHALInfo, sizeof(DDHALINFO));
412 RtlZeroMemory(&mD3dCallbacks, sizeof(D3DHAL_CALLBACKS));
413 RtlZeroMemory(&mD3dDriverData, sizeof(D3DHAL_GLOBALDRIVERDATA));
414 RtlZeroMemory(&mD3dBufferCallbacks, sizeof(DDHAL_DDEXEBUFCALLBACKS));
415
416 if (reenable == FALSE)
417 {
418 if (ddgbl.lpDDCBtmp == NULL)
419 {
420 DxHeapMemAlloc(ddgbl.lpDDCBtmp, sizeof(DDHAL_CALLBACKS));
421 if ( ddgbl.lpDDCBtmp == NULL)
422 {
423 return DD_FALSE;
424 }
425 }
426 }
427 else
428 {
429 RtlZeroMemory(ddgbl.lpDDCBtmp,sizeof(DDHAL_CALLBACKS));
430 }
431
432 /*
433 * Startup DX HAL step one of three
434 */
435 if (!DdCreateDirectDrawObject(This->lpLcl->lpGbl, (HDC)This->lpLcl->hDC))
436 {
437 DxHeapMemFree(ddgbl.lpDDCBtmp);
438 return DD_FALSE;
439 }
440
441 /* Some card disable the dx after it have been created so
442 * we are force reanble it
443 */
444 if (!DdReenableDirectDrawObject(This->lpLcl->lpGbl, &newmode))
445 {
446 DxHeapMemFree(ddgbl.lpDDCBtmp);
447 return DD_FALSE;
448 }
449
450 if (!DdQueryDirectDrawObject(This->lpLcl->lpGbl,
451 &mHALInfo,
452 &ddgbl.lpDDCBtmp->HALDD,
453 &ddgbl.lpDDCBtmp->HALDDSurface,
454 &ddgbl.lpDDCBtmp->HALDDPalette,
455 &mD3dCallbacks,
456 &mD3dDriverData,
457 &mD3dBufferCallbacks,
458 NULL,
459 mpFourCC,
460 NULL))
461 {
462 DxHeapMemFree(This->lpLcl->lpGbl->lpModeInfo);
463 DxHeapMemFree(ddgbl.lpDDCBtmp);
464 // FIXME Close DX fristcall and second call
465 return DD_FALSE;
466 }
467
468 #if 0
469 DX_STUB_str("Trying alloc FourCCC \n");
470
471 /* Alloc mpFourCC */
472 if (This->lpLcl->lpGbl->lpdwFourCC != NULL)
473 {
474 DxHeapMemFree(This->lpLcl->lpGbl->lpdwFourCC);
475 }
476
477 if (mHALInfo.ddCaps.dwNumFourCCCodes > 0 )
478 {
479 DxHeapMemAlloc(mpFourCC, sizeof(DWORD) * 21);
480
481 mpFourCC = (DWORD *) DxHeapMemAlloc(sizeof(DWORD) * (mHALInfo.ddCaps.dwNumFourCCCodes + 2));
482
483 if (mpFourCC == NULL)
484 {
485 DxHeapMemFree(ddgbl.lpDDCBtmp);
486 // FIXME Close DX fristcall and second call
487 return DD_FALSE;
488 }
489 }
490
491 DX_STUB_str("End Trying alloc FourCCC\n");
492 #endif
493
494
495
496
497 /* Alloc mpTextures */
498 #if 0
499 DX_STUB_str("1 Here\n");
500
501 if (This->lpLcl->lpGbl->texture != NULL)
502 {
503 DxHeapMemFree(This->lpLcl->lpGbl->texture;
504 }
505
506 mpTextures = NULL;
507 if (mD3dDriverData.dwNumTextureFormats > 0)
508 {
509 mpTextures = (DDSURFACEDESC*) DxHeapMemAlloc(sizeof(DDSURFACEDESC) * mD3dDriverData.dwNumTextureFormats);
510 if (mpTextures == NULL)
511 {
512 DxHeapMemFree(mpFourCC);
513 DxHeapMemFree(ddgbl.lpDDCBtmp);
514 // FIXME Close DX fristcall and second call
515 }
516 }
517
518 DX_STUB_str("2 Here\n");
519
520 #else
521 mpTextures = NULL;
522 #endif
523
524
525 /* Get all basic data from the driver */
526 if (!DdQueryDirectDrawObject(
527 This->lpLcl->lpGbl,
528 &mHALInfo,
529 &ddgbl.lpDDCBtmp->HALDD,
530 &ddgbl.lpDDCBtmp->HALDDSurface,
531 &ddgbl.lpDDCBtmp->HALDDPalette,
532 &mD3dCallbacks,
533 &mD3dDriverData,
534 &ddgbl.lpDDCBtmp->HALDDExeBuf,
535 (DDSURFACEDESC*)mpTextures,
536 mpFourCC,
537 NULL))
538 {
539 DxHeapMemFree(mpFourCC);
540 DxHeapMemFree(mpTextures);
541 DxHeapMemFree(ddgbl.lpDDCBtmp);
542 // FIXME Close DX fristcall and second call
543 return DD_FALSE;
544 }
545
546 memcpy(&ddgbl.vmiData, &mHALInfo.vmiData,sizeof(VIDMEMINFO));
547
548
549 memcpy(&ddgbl.ddCaps, &mHALInfo.ddCaps,sizeof(DDCORECAPS));
550
551 This->lpLcl->lpGbl->dwNumFourCC = mHALInfo.ddCaps.dwNumFourCCCodes;
552 This->lpLcl->lpGbl->lpdwFourCC = mpFourCC;
553 This->lpLcl->lpGbl->dwMonitorFrequency = mHALInfo.dwMonitorFrequency;
554 This->lpLcl->lpGbl->dwModeIndex = mHALInfo.dwModeIndex;
555 This->lpLcl->lpGbl->dwNumModes = mHALInfo.dwNumModes;
556 This->lpLcl->lpGbl->lpModeInfo = mHALInfo.lpModeInfo;
557
558 DX_STUB_str("Here\n");
559
560 /* FIXME convert mpTextures to DDHALMODEINFO */
561 // DxHeapMemFree( mpTextures);
562
563 /* FIXME D3D setup mD3dCallbacks and mD3dDriverData */
564 DDHAL_GETDRIVERINFODATA DdGetDriverInfo = { 0 };
565 DdGetDriverInfo.dwSize = sizeof (DDHAL_GETDRIVERINFODATA);
566 DdGetDriverInfo.guidInfo = GUID_MiscellaneousCallbacks;
567
568 DdGetDriverInfo.lpvData = (PVOID)&ddgbl.lpDDCBtmp->HALDDMiscellaneous;
569
570 DdGetDriverInfo.dwExpectedSize = sizeof (DDHAL_DDMISCELLANEOUSCALLBACKS);
571
572 if(mHALInfo.GetDriverInfo (&DdGetDriverInfo) == DDHAL_DRIVER_NOTHANDLED || DdGetDriverInfo.ddRVal != DD_OK)
573 {
574 DxHeapMemFree(mpFourCC);
575 DxHeapMemFree(mpTextures);
576 DxHeapMemFree(ddgbl.lpDDCBtmp);
577 // FIXME Close DX fristcall and second call
578 return DD_FALSE;
579 }
580
581 return DD_OK;
582 }