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