* Source cleanup.
[reactos.git] / reactos / lib / ddraw / hal / ddraw_hal.c
1 /* $Id$
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS
5 * FILE: lib/ddraw/hal/ddraw.c
6 * PURPOSE: DirectDraw HAL Implementation
7 * PROGRAMMER: Magnus Olsen, Maarten Bosma
8 *
9 */
10
11 #include "rosdraw.h"
12
13
14 HRESULT Hal_DirectDraw_Initialize (LPDIRECTDRAW7 iface)
15 {
16 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
17
18 /* point to it self */
19 This->DirectDrawGlobal.lp16DD = &This->DirectDrawGlobal;
20
21 /* get the object */
22 if(!DdCreateDirectDrawObject (&This->DirectDrawGlobal, This->hdc))
23 return DDERR_INVALIDPARAMS;
24
25 BOOL dummy;
26 DdReenableDirectDrawObject(&This->DirectDrawGlobal, &dummy);
27
28 /* alloc all the space */
29 This->DirectDrawGlobal.lpDDCBtmp = (LPDDHAL_CALLBACKS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
30 sizeof(DDHAL_CALLBACKS));
31
32 This->DirectDrawGlobal.lpD3DHALCallbacks = (ULONG_PTR)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,
33 sizeof(D3DHAL_CALLBACKS));
34
35 This->DirectDrawGlobal.lpD3DGlobalDriverData = (ULONG_PTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
36 sizeof(D3DHAL_GLOBALDRIVERDATA));
37
38 /* Fill in some info */
39 This->HalInfo.lpD3DGlobalDriverData = This->DirectDrawGlobal.lpD3DGlobalDriverData;
40 This->HalInfo.lpD3DHALCallbacks = This->DirectDrawGlobal.lpD3DHALCallbacks;
41 This->HalInfo.lpDDCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->HALDD;
42 This->HalInfo.lpDDExeBufCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->HALDDExeBuf;
43 This->HalInfo.lpDDPaletteCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->HALDDPalette;
44 This->HalInfo.lpDDSurfaceCallbacks = &This->DirectDrawGlobal.lpDDCBtmp->HALDDSurface;
45
46 /* query all kinds of infos from the driver */
47 if(!DdQueryDirectDrawObject (
48 &This->DirectDrawGlobal,
49 &This->HalInfo,
50 This->HalInfo.lpDDCallbacks,
51 This->HalInfo.lpDDSurfaceCallbacks,
52 This->HalInfo.lpDDPaletteCallbacks,
53 (LPD3DHAL_CALLBACKS)This->DirectDrawGlobal.lpD3DHALCallbacks,
54 (LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData,
55 This->HalInfo.lpDDExeBufCallbacks,
56 NULL,
57 NULL,
58 NULL ))
59 {
60 return DD_FALSE;
61 }
62
63 This->HalInfo.vmiData.pvmList = (LPVIDMEM) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
64 sizeof(VIDMEM) * This->HalInfo.vmiData.dwNumHeaps);
65
66 This->DirectDrawGlobal.lpdwFourCC = (DWORD *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
67 sizeof(DWORD) * This->HalInfo.ddCaps.dwNumFourCCCodes);
68 ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats =
69 (LPDDSURFACEDESC) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(DDSURFACEDESC) *
70 ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->dwNumTextureFormats);
71
72 if(!DdQueryDirectDrawObject (
73 &This->DirectDrawGlobal,
74 &This->HalInfo,
75 This->HalInfo.lpDDCallbacks,
76 This->HalInfo.lpDDSurfaceCallbacks,
77 This->HalInfo.lpDDPaletteCallbacks,
78 (LPD3DHAL_CALLBACKS)This->DirectDrawGlobal.lpD3DHALCallbacks,
79 (LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData,
80 This->HalInfo.lpDDExeBufCallbacks,
81 ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats,
82 This->DirectDrawGlobal.lpdwFourCC,
83 This->HalInfo.vmiData.pvmList
84 ))
85 {
86 return DD_FALSE;
87 }
88
89 /* Copy HalInfo to DirectDrawGlobal (Not complete)*/
90 RtlCopyMemory(&This->DirectDrawGlobal.vmiData,&This->HalInfo.vmiData,sizeof(VIDMEMINFO));
91 RtlCopyMemory(&This->DirectDrawGlobal.ddCaps,&This->HalInfo.ddCaps,sizeof(DDCORECAPS));
92 This->DirectDrawGlobal.dwMonitorFrequency = This->HalInfo.dwMonitorFrequency;
93
94 This->DirectDrawGlobal.dwModeIndex = This->HalInfo.dwModeIndex;
95 This->DirectDrawGlobal.dwNumModes = This->HalInfo.dwNumModes;
96 This->DirectDrawGlobal.lpModeInfo = This->HalInfo.lpModeInfo;
97
98 /* Unsure which of these two for lpPDevice
99 This->DirectDrawGlobal.dwPDevice = This->HalInfo.lpPDevice;
100 This->lpDriverHandle = This->HalInfo.lpPDevice;
101 */
102 This->DirectDrawGlobal.hInstance = This->HalInfo.hInstance;
103 RtlCopyMemory(&This->DirectDrawGlobal.lpDDCBtmp->HALDDExeBuf,
104 &This->HalInfo.lpDDExeBufCallbacks,sizeof(DDHAL_DDEXEBUFCALLBACKS));
105
106 /************************************************************************/
107 /* Set up the rest of the callbacks all callbacks we get back from */
108 /* gdi32.dll is user mode */
109 /************************************************************************/
110
111 /* Todo add a check see if HalInfo.GetDriverInfo is supported or not */
112 /* Do not trust msdn what it say about dwContext it is not in use for
113 windows nt, it is in use for all os, and it always pont to
114 DirectDrawGlobal.hDD */
115
116 /* FIXME add all callback that have been commect out to gpl */
117 /* FIXME free the memmor that being alloc when ddraw.dll exists */
118 /* FIXME add check for DriverInfo if the handle or not */
119
120 DDHAL_GETDRIVERINFODATA DriverInfo;
121 memset(&DriverInfo,0, sizeof(DDHAL_GETDRIVERINFODATA));
122 DriverInfo.dwSize = sizeof(DDHAL_GETDRIVERINFODATA);
123 DriverInfo.dwContext = This->DirectDrawGlobal.hDD;
124
125 /* Get ColorControlCallbacks */
126 DriverInfo.guidInfo = GUID_ColorControlCallbacks;
127 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDColorControl;
128 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDCOLORCONTROLCALLBACKS);
129 This->HalInfo.GetDriverInfo(&DriverInfo);
130
131 /* Get the GUID_D3DCallbacks callback */
132 /* Problem with include files
133 DDHAL_DDMISCELLANEOUSCALLBACKS misc;
134 DriverInfo.guidInfo = GUID_D3DCallbacks;
135 DriverInfo.lpvData = &misc;
136 DriverInfo.dwExpectedSize = sizeof();
137 This->HalInfo.GetDriverInfo( &DriverInfo);*/
138
139 /* Get the D3DCallbacks2 */
140 This->DirectDrawGlobal.lpD3DHALCallbacks2 = (ULONG_PTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
141 sizeof(D3DHAL_CALLBACKS2));
142 DriverInfo.guidInfo = GUID_D3DCallbacks2;
143 DriverInfo.lpvData = (PVOID)This->DirectDrawGlobal.lpD3DHALCallbacks2;
144 DriverInfo.dwExpectedSize = sizeof(D3DHAL_CALLBACKS2);
145 This->HalInfo.GetDriverInfo(&DriverInfo);
146
147
148 /* Get the D3DCallbacks3 */
149 This->DirectDrawGlobal.lpD3DHALCallbacks = (ULONG_PTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
150 sizeof(D3DHAL_CALLBACKS3));
151 DriverInfo.guidInfo = GUID_D3DCallbacks3;
152 DriverInfo.lpvData = (PVOID)This->DirectDrawGlobal.lpD3DHALCallbacks;
153 DriverInfo.dwExpectedSize = sizeof(D3DHAL_CALLBACKS3);
154 This->HalInfo.GetDriverInfo(&DriverInfo);
155
156 /* Get the misc callback */
157 /* Problem with include files
158 DriverInfo.guidInfo = GUID_D3DCaps;
159 DriverInfo.lpvData = &misc;
160 DriverInfo.dwExpectedSize = sizeof();
161 This->HalInfo.GetDriverInfo( &DriverInfo);
162 */
163
164 /* Get the D3DExtendedCaps */
165
166 This->DirectDrawGlobal.lpD3DExtendedCaps = (ULONG_PTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
167 sizeof(D3DHAL_D3DEXTENDEDCAPS));
168 DriverInfo.guidInfo = GUID_D3DExtendedCaps;
169 DriverInfo.lpvData = (PVOID) This->DirectDrawGlobal.lpD3DExtendedCaps;
170 DriverInfo.dwExpectedSize = sizeof(D3DHAL_D3DEXTENDEDCAPS);
171 This->HalInfo.GetDriverInfo(&DriverInfo);
172
173 /* Get the D3DParseUnknownCommandCallback */
174 /* D3dDrawPrimitives2 callback where should it be fill in
175 DriverInfo.guidInfo = GUID_D3DParseUnknownCommandCallback;
176 DriverInfo.lpvData = &misc;
177 DriverInfo.dwExpectedSize = sizeof();
178 This->HalInfo.GetDriverInfo( &DriverInfo);
179 */
180
181 /* Get the GetHeapAlignment */
182 /* where should it be fill in
183 DriverInfo.guidInfo = GUID_GetHeapAlignment;
184 DriverInfo.lpvData = &misc;
185 DriverInfo.dwExpectedSize = sizeof();
186 This->HalInfo.GetDriverInfo( &DriverInfo);
187 */
188
189 /* Get the KernelCallbacks */
190 DriverInfo.guidInfo = GUID_KernelCallbacks;
191 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDKernel;
192 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDKERNELCALLBACKS);
193 This->HalInfo.GetDriverInfo(&DriverInfo);
194
195 /* Get the KernelCaps */
196 This->DirectDrawGlobal.lpDDKernelCaps = (LPDDKERNELCAPS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
197 sizeof(DDHAL_DDKERNELCALLBACKS));
198 DriverInfo.guidInfo = GUID_KernelCaps;
199 DriverInfo.lpvData = (PVOID) This->DirectDrawGlobal.lpDDKernelCaps;
200 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDKERNELCALLBACKS);
201 This->HalInfo.GetDriverInfo(&DriverInfo);
202
203 /* Get the MiscellaneousCallbacks */
204 DriverInfo.guidInfo = GUID_MiscellaneousCallbacks;
205 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDMiscellaneous;
206 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
207 This->HalInfo.GetDriverInfo(&DriverInfo);
208
209 /* Get the Miscellaneous2Callbacks */
210 /* Not in the DDRAWI_DIRECTDRAW_GBL we map it up as private
211 Contain CreatesurfaceEx and other nice callbacks */
212 DriverInfo.guidInfo = GUID_Miscellaneous2Callbacks;
213 DriverInfo.lpvData = &This->Misc2Callback;
214 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMISCELLANEOUSCALLBACKS);
215 This->HalInfo.GetDriverInfo(&DriverInfo);
216
217 /* Get the MotionCompCallbacks */
218 DriverInfo.guidInfo = GUID_MotionCompCallbacks;
219 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDMotionComp;
220 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDMOTIONCOMPCALLBACKS);
221 This->HalInfo.GetDriverInfo(&DriverInfo);
222
223 /* Get the NonLocalVidMemCaps */
224 This->DirectDrawGlobal.lpddNLVCaps = (LPDDNONLOCALVIDMEMCAPS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
225 sizeof(DDNONLOCALVIDMEMCAPS));
226 DriverInfo.guidInfo = GUID_NonLocalVidMemCaps;
227 DriverInfo.lpvData = (PVOID)This->DirectDrawGlobal.lpddNLVCaps;
228 DriverInfo.dwExpectedSize = sizeof(DDNONLOCALVIDMEMCAPS);
229 This->HalInfo.GetDriverInfo(&DriverInfo);
230
231 /* Get the NTCallbacks */
232 /* Fill in wher
233 DriverInfo.guidInfo = GUID_NTCallbacks;
234 DriverInfo.lpvData = &misc;
235 DriverInfo.dwExpectedSize = sizeof();
236 This->HalInfo.GetDriverInfo( &DriverInfo);
237 */
238
239 /* Get the NTPrivateDriverCaps */
240 /* Fill in wher
241 DriverInfo.guidInfo = GUID_NTPrivateDriverCaps;
242 DriverInfo.lpvData = &misc;
243 DriverInfo.dwExpectedSize = sizeof();
244 This->HalInfo.GetDriverInfo( &DriverInfo);
245 */
246
247 /* Get the UpdateNonLocalHeap */
248 /* Fill in where
249 DriverInfo.guidInfo = GUID_UpdateNonLocalHeap;
250 DriverInfo.lpvData = &misc;
251 DriverInfo.dwExpectedSize = sizeof();
252 This->HalInfo.GetDriverInfo( &DriverInfo);
253 */
254
255 /* Get the VideoPortCallbacks */
256 DriverInfo.guidInfo = GUID_VideoPortCallbacks;
257 DriverInfo.lpvData = &This->DirectDrawGlobal.lpDDCBtmp->HALDDVideoPort;
258 DriverInfo.dwExpectedSize = sizeof(DDHAL_DDVIDEOPORTCALLBACKS);
259 This->HalInfo.GetDriverInfo(&DriverInfo);
260
261 /* Get the VideoPortCaps */
262 This->DirectDrawGlobal.lpDDVideoPortCaps = (LPDDVIDEOPORTCAPS)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
263 sizeof(DDVIDEOPORTCAPS));
264 DriverInfo.guidInfo = GUID_VideoPortCaps;
265 DriverInfo.lpvData = (PVOID)This->DirectDrawGlobal.lpDDVideoPortCaps;
266 DriverInfo.dwExpectedSize = sizeof(DDVIDEOPORTCAPS);
267 This->HalInfo.GetDriverInfo(&DriverInfo);
268
269 /* Get the ZPixelFormats */
270 This->DirectDrawGlobal.lpZPixelFormats = (LPDDPIXELFORMAT) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
271 sizeof(DDPIXELFORMAT) * This->DirectDrawGlobal.dwNumZPixelFormats);
272 DriverInfo.guidInfo = GUID_ZPixelFormats;
273 DriverInfo.lpvData = (PVOID)This->DirectDrawGlobal.lpZPixelFormats;
274 DriverInfo.dwExpectedSize = sizeof(DDPIXELFORMAT);
275 This->HalInfo.GetDriverInfo(&DriverInfo);
276
277 /* Setup some info from the callbacks we got */
278 DDHAL_GETAVAILDRIVERMEMORYDATA mem;
279 mem.lpDD = &This->DirectDrawGlobal;
280 This->DirectDrawGlobal.lpDDCBtmp->HALDDMiscellaneous.GetAvailDriverMemory(&mem);
281 This->DirectDrawGlobal.ddCaps.dwVidMemFree = mem.dwFree;
282 This->DirectDrawGlobal.ddCaps.dwVidMemTotal = mem.dwTotal;
283
284 /* Now all setup for HAL is done */
285 return DD_OK;
286 }
287
288 HRESULT Hal_DirectDraw_SetCooperativeLevel (LPDIRECTDRAW7 iface)
289 {
290 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
291
292 DDHAL_SETEXCLUSIVEMODEDATA SetExclusiveMode;
293
294 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETEXCLUSIVEMODE))
295 {
296 return DDERR_NODRIVERSUPPORT;
297 }
298
299 SetExclusiveMode.lpDD = &This->DirectDrawGlobal;
300 SetExclusiveMode.ddRVal = DDERR_NOTPALETTIZED;
301 SetExclusiveMode.dwEnterExcl = This->cooperative_level;
302
303 if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.SetExclusiveMode(&SetExclusiveMode) != DDHAL_DRIVER_HANDLED)
304 {
305 return DDERR_NODRIVERSUPPORT;
306 }
307
308 return SetExclusiveMode.ddRVal;
309 }
310
311
312 VOID Hal_DirectDraw_Release (LPDIRECTDRAW7 iface)
313 {
314 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
315
316 DdDeleteDirectDrawObject (&This->DirectDrawGlobal);
317
318 if(This->DirectDrawGlobal.lpDDKernelCaps)
319 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpDDKernelCaps);
320
321 if(This->DirectDrawGlobal.lpddNLVCaps)
322 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpddNLVCaps);
323
324 if(This->DirectDrawGlobal.lpDDVideoPortCaps)
325 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpDDVideoPortCaps);
326
327 if(This->DirectDrawGlobal.lpdwFourCC)
328 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpdwFourCC);
329
330 if(This->DirectDrawGlobal.lpZPixelFormats)
331 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpZPixelFormats);
332
333 if(This->HalInfo.vmiData.pvmList)
334 HeapFree(GetProcessHeap(), 0, This->HalInfo.vmiData.pvmList);
335
336 if(((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats)
337 HeapFree(GetProcessHeap(), 0, ((LPD3DHAL_GLOBALDRIVERDATA)This->DirectDrawGlobal.lpD3DGlobalDriverData)->lpTextureFormats);
338
339 if(This->DirectDrawGlobal.lpDDCBtmp)
340 HeapFree(GetProcessHeap(), 0, This->DirectDrawGlobal.lpDDCBtmp);
341
342 if(This->DirectDrawGlobal.lpD3DHALCallbacks)
343 HeapFree(GetProcessHeap(), 0, (PVOID)This->DirectDrawGlobal.lpD3DHALCallbacks);
344
345 if(This->DirectDrawGlobal.lpD3DGlobalDriverData)
346 HeapFree(GetProcessHeap(), 0, (PVOID)This->DirectDrawGlobal.lpD3DGlobalDriverData);
347 }
348
349
350 HRESULT Hal_DirectDraw_GetAvailableVidMem(LPDIRECTDRAW7 iface, LPDDSCAPS2 ddscaps,
351 LPDWORD total, LPDWORD free)
352 {
353 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
354
355 DDHAL_GETAVAILDRIVERMEMORYDATA mem;
356
357 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDDMiscellaneous.dwFlags & DDHAL_MISCCB32_GETAVAILDRIVERMEMORY))
358 {
359 return DDERR_NODRIVERSUPPORT;
360 }
361
362 mem.lpDD = &This->DirectDrawGlobal;
363 mem.ddRVal = DDERR_NOTPALETTIZED;
364
365 if (This->DirectDrawGlobal.lpDDCBtmp->HALDDMiscellaneous.GetAvailDriverMemory(&mem) != DDHAL_DRIVER_HANDLED)
366 {
367 return DDERR_NODRIVERSUPPORT;
368 }
369
370 ddscaps->dwCaps = mem.DDSCaps.dwCaps;
371 ddscaps->dwCaps2 = mem.ddsCapsEx.dwCaps2;
372 ddscaps->dwCaps3 = mem.ddsCapsEx.dwCaps3;
373 ddscaps->dwCaps4 = mem.ddsCapsEx.dwCaps4;
374 *total = mem.dwTotal;
375 *free = mem.dwFree;
376
377 return mem.ddRVal;
378 }
379
380 HRESULT Hal_DirectDraw_WaitForVerticalBlank(LPDIRECTDRAW7 iface, DWORD dwFlags,HANDLE h)
381 {
382 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
383
384 DDHAL_WAITFORVERTICALBLANKDATA WaitVectorData;
385
386 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_WAITFORVERTICALBLANK))
387 {
388 return DDERR_NODRIVERSUPPORT;
389 }
390
391 WaitVectorData.lpDD = &This->DirectDrawGlobal;
392 WaitVectorData.dwFlags = dwFlags;
393 WaitVectorData.hEvent = (DWORD)h;
394 WaitVectorData.ddRVal = DDERR_NOTPALETTIZED;
395
396 if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.WaitForVerticalBlank(&WaitVectorData) != DDHAL_DRIVER_HANDLED)
397 {
398 return DDERR_NODRIVERSUPPORT;
399 }
400
401 return WaitVectorData.ddRVal;
402 }
403
404 HRESULT Hal_DirectDraw_GetScanLine(LPDIRECTDRAW7 iface, LPDWORD lpdwScanLine)
405 {
406 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
407
408 DDHAL_GETSCANLINEDATA GetScan;
409
410 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_GETSCANLINE))
411 {
412 return DDERR_NODRIVERSUPPORT;
413 }
414
415 GetScan.lpDD = &This->DirectDrawGlobal;
416 GetScan.ddRVal = DDERR_NOTPALETTIZED;
417
418 if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.GetScanLine(&GetScan) != DDHAL_DRIVER_HANDLED)
419 {
420 return DDERR_NODRIVERSUPPORT;
421 }
422
423 *lpdwScanLine = GetScan.ddRVal;
424 return GetScan.ddRVal;
425 }
426
427 HRESULT Hal_DirectDraw_FlipToGDISurface(LPDIRECTDRAW7 iface)
428 {
429 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
430
431 DDHAL_FLIPTOGDISURFACEDATA FlipGdi;
432
433 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_FLIPTOGDISURFACE))
434 {
435 return DDERR_NODRIVERSUPPORT;
436 }
437
438 FlipGdi.lpDD = &This->DirectDrawGlobal;
439 FlipGdi.ddRVal = DDERR_NOTPALETTIZED;
440
441 if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.FlipToGDISurface(&FlipGdi) != DDHAL_DRIVER_HANDLED)
442 {
443 return DDERR_NODRIVERSUPPORT;
444 }
445
446 /* FIXME where should FlipGdi.dwToGDI be fill in */
447 return FlipGdi.ddRVal;
448 }
449
450
451
452 HRESULT Hal_DirectDraw_SetDisplayMode (LPDIRECTDRAW7 iface, DWORD dwWidth, DWORD dwHeight,
453 DWORD dwBPP, DWORD dwRefreshRate, DWORD dwFlags)
454 {
455 IDirectDrawImpl* This = (IDirectDrawImpl*)iface;
456 DDHAL_SETMODEDATA mode;
457
458 if (!(This->DirectDrawGlobal.lpDDCBtmp->HALDD.dwFlags & DDHAL_CB32_SETMODE))
459 {
460 return DDERR_NODRIVERSUPPORT;
461 }
462
463 mode.lpDD = &This->DirectDrawGlobal;
464 mode.ddRVal = DDERR_NODRIVERSUPPORT;
465
466 // FIXME : add search for which mode.ModeIndex we should use
467 // FIXME : fill the mode.inexcl;
468 // FIXME : fill the mode.useRefreshRate;
469
470 if (This->DirectDrawGlobal.lpDDCBtmp->HALDD.SetMode(&mode) != DDHAL_DRIVER_HANDLED)
471 {
472 return DDERR_NODRIVERSUPPORT;
473 }
474
475 return mode.ddRVal;
476 }
477
478