source: trunk/src/ddraw/OS2DDRAW.CPP@ 8115

Last change on this file since 8115 was 8115, checked in by sandervl, 23 years ago

Do not use XFree driver unless fullscreen mode is enabled

File size: 76.3 KB
Line 
1/* $Id: OS2DDRAW.CPP,v 1.34 2002-03-22 13:49:54 sandervl Exp $ */
2
3/*
4 * DX Draw base class implementation
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1999 Markus Montkowski
8 * Copyright 2000 Przemyslaw Dobrowolski
9 * Copyright 2001 Michal Necasek
10 *
11 * Project Odin Software License can be found in LICENSE.TXT
12 *
13 */
14#define _OS2WIN_H
15#define FAR
16
17#include <odin.h>
18#include <winbase.h>
19#include <stdlib.h>
20#include <string.h>
21#include <memory.h>
22
23#define INITGUID
24#include "os2ddraw.h"
25#include "os2clipper.h"
26#include "os2palette.h"
27#include "os2surface.h"
28#include <misc.h>
29#include <string.h>
30#include <winreg.h>
31#include <winuser.h>
32#include <winerror.h>
33#include <options.h>
34#include "cio2.h"
35#include "os2util.h"
36#include "os2fsdd.h"
37// include with the videomodes we support
38// better would be to get these modes from the card
39// But for now we use standard VESA 2.0 modes with 70Hz
40#include "os2ddrawmodes.h"
41#include "os2DDWindow.h"
42#include "os2palset.h"
43
44#define KEY_DIRECT2 "\\Software\\Win32OS2\\Direct2"
45#define KEY_DIRECT2DRAW "\\Software\\Win32OS2\\Direct2\\Draw"
46
47
48BOOL bUseFSDD = FALSE;
49
50FOURCC SupportedFourCCs[] = {FOURCC_SCRN,FOURCC_LUT8,FOURCC_R565,FOURCC_RGB3,FOURCC_RGB4};
51//******************************************************************************
52//******************************************************************************
53OS2IDirectDraw::OS2IDirectDraw(GUID *lpGUID) :
54 Referenced(0), lastError(DD_OK),
55 pFrameBuffer(NULL), hwndClient(0), screenwidth(640),
56 screenheight(480), screenbpp(8),PrimaryExists(FALSE),pPrimSurf(NULL)
57
58{
59 HKEY hkDirectDraw2;
60 DWORD dwVSize, dwVType;
61 ULONG rc;
62 FOURCC fccModes[100];
63
64 // Setup table for 3d devices
65 Vtbl3D.AddRef = D3DAddRef;
66 Vtbl3D.Release = D3DRelease;
67 Vtbl3D.QueryInterface = D3DQueryInterface;
68 Vtbl3D.Initialize = D3DInitialize;
69 Vtbl3D.EnumDevices = D3DEnumDevices;
70 Vtbl3D.CreateLight = D3DCreateLight;
71 Vtbl3D.CreateMaterial = D3DCreateMaterial;
72 Vtbl3D.CreateViewport = D3DCreateViewport;
73 Vtbl3D.FindDevice = D3DFindDevice;
74
75 // Org Interface
76 Vtbl.AddRef = DrawAddRef;
77 Vtbl.Release = DrawRelease;
78 Vtbl.QueryInterface = DrawQueryInterface;
79 Vtbl.Compact = DrawCompact;
80 Vtbl.CreateClipper = DrawCreateClipper;
81 Vtbl.CreatePalette = DrawCreatePalette;
82 Vtbl.CreateSurface = DrawCreateSurface;
83 Vtbl.DuplicateSurface = DrawDuplicateSurface;
84 Vtbl.EnumDisplayModes = DrawEnumDisplayModes;
85 Vtbl.EnumSurfaces = DrawEnumSurfaces;
86 Vtbl.FlipToGDISurface = DrawFlipToGDISurface;
87 Vtbl.GetCaps = DrawGetCaps;
88 Vtbl.GetDisplayMode = DrawGetDisplayMode;
89 Vtbl.GetFourCCCodes = DrawGetFourCCCodes;
90 Vtbl.GetGDISurface = DrawGetGDISurface;
91 Vtbl.GetMonitorFrequency = DrawGetMonitorFrequency;
92 Vtbl.GetScanLine = DrawGetScanLine;
93 Vtbl.GetVerticalBlankStatus = DrawGetVerticalBlankStatus;
94 Vtbl.Initialize = DrawInitialize;
95 Vtbl.RestoreDisplayMode = DrawRestoreDisplayMode;
96 Vtbl.SetCooperativeLevel = DrawSetCooperativeLevel;
97 Vtbl.SetDisplayMode = DrawSetDisplayMode;
98 Vtbl.WaitForVerticalBlank = DrawWaitForVerticalBlank;
99
100 // V2 Interface
101
102 Vtbl2.AddRef = DrawAddRef;
103 Vtbl2.Release = DrawRelease;
104 Vtbl2.QueryInterface = DrawQueryInterface;
105 Vtbl2.Compact = DrawCompact;
106 Vtbl2.CreateClipper = DrawCreateClipper;
107 Vtbl2.CreatePalette = DrawCreatePalette;
108 Vtbl2.CreateSurface = DrawCreateSurface;
109 Vtbl2.DuplicateSurface = DrawDuplicateSurface;
110 Vtbl2.EnumDisplayModes = DrawEnumDisplayModes;
111 Vtbl2.EnumSurfaces = DrawEnumSurfaces;
112 Vtbl2.FlipToGDISurface = DrawFlipToGDISurface;
113 Vtbl2.GetCaps = DrawGetCaps;
114 Vtbl2.GetDisplayMode = DrawGetDisplayMode;
115 Vtbl2.GetFourCCCodes = DrawGetFourCCCodes;
116 Vtbl2.GetGDISurface = DrawGetGDISurface;
117 Vtbl2.GetMonitorFrequency = DrawGetMonitorFrequency;
118 Vtbl2.GetScanLine = DrawGetScanLine;
119 Vtbl2.GetVerticalBlankStatus = DrawGetVerticalBlankStatus;
120 Vtbl2.Initialize = DrawInitialize;
121 Vtbl2.RestoreDisplayMode = DrawRestoreDisplayMode;
122 Vtbl2.SetCooperativeLevel = DrawSetCooperativeLevel;
123 Vtbl2.SetDisplayMode = DrawSetDisplayMode2;
124 Vtbl2.WaitForVerticalBlank = DrawWaitForVerticalBlank;
125 Vtbl2.GetAvailableVidMem = DrawGetAvailableVidMem;
126
127 // New V4 interface
128 Vtbl4.AddRef = DrawAddRef; // todo change to a DrawAddRef4 as handling this has changed
129 Vtbl4.Release = DrawRelease; // see above
130 Vtbl4.QueryInterface = DrawQueryInterface;
131 Vtbl4.Compact = DrawCompact;
132 Vtbl4.CreateClipper = DrawCreateClipper;
133 Vtbl4.CreatePalette = DrawCreatePalette;
134 Vtbl4.CreateSurface = DrawCreateSurface4;//
135 Vtbl4.DuplicateSurface = DrawDuplicateSurface4;//
136 Vtbl4.EnumDisplayModes = DrawEnumDisplayModes4;//
137 Vtbl4.EnumSurfaces = DrawEnumSurfaces4; //
138 Vtbl4.FlipToGDISurface = DrawFlipToGDISurface;
139 Vtbl4.GetCaps = DrawGetCaps;
140 Vtbl4.GetDisplayMode = DrawGetDisplayMode4;//
141 Vtbl4.GetFourCCCodes = DrawGetFourCCCodes;
142 Vtbl4.GetGDISurface = DrawGetGDISurface4;//
143 Vtbl4.GetMonitorFrequency = DrawGetMonitorFrequency;
144 Vtbl4.GetScanLine = DrawGetScanLine;
145 Vtbl4.GetVerticalBlankStatus = DrawGetVerticalBlankStatus;
146 Vtbl4.Initialize = DrawInitialize;
147 Vtbl4.RestoreDisplayMode = DrawRestoreDisplayMode;
148 Vtbl4.SetCooperativeLevel = DrawSetCooperativeLevel;
149 Vtbl4.SetDisplayMode = DrawSetDisplayMode2;
150 Vtbl4.WaitForVerticalBlank = DrawWaitForVerticalBlank;
151 Vtbl4.GetAvailableVidMem = DrawGetAvailableVidMem4;
152 Vtbl4.GetSurfaceFromDC = DrawGetSurfaceFromDC;
153 Vtbl4.RestoreAllSurfaces = DrawRestoreAllSurfaces;
154 Vtbl4.TestCooperativeLevel = DrawTestCooperativeLevel;
155 Vtbl4.GetDeviceIdentifier = DrawGetDeviceIdentifier;
156
157 if(lpGUID && *lpGUID == IID_IDirect3D)
158 {
159 dprintf(("DDRAW: D3D Interface -> using V4 Interface"));
160
161 lpVtbl = &Vtbl4;
162 }
163 else
164 {
165 if(lpGUID && *lpGUID == IID_IDirectDraw4)
166 {
167 dprintf(("DDRAW: V4 Interface\n"));
168 lpVtbl = &Vtbl4;
169 }
170 else
171 {
172 dprintf(("DDRAW: <V4 Interface\n"));
173 lpVtbl = (IDirectDraw4Vtbl *) &Vtbl;
174 }
175 }
176
177 lpVtbl2 = lpVtbl;
178
179 pdwUnknownData = (DWORD*) malloc (255*sizeof(DWORD));
180 for(int i= 0 ;i<255;i++)
181 pdwUnknownData[i] = 0;
182
183 rc = DiveOpen( &hDive,
184 FALSE,
185 &pFrameBuffer);
186 if(rc)
187 {
188 dprintf(("DDRAW: ERROR: DiveOpen returned %d\n", rc));
189 lastError = DDERR_GENERIC;
190 hDive = NULL;
191 }
192 else
193 {
194 dprintf(("DDRAW: DiveOpen OK Framebuufer at 0x%08X\n",pFrameBuffer));
195 }
196 memset( &dCaps,
197 0,
198 sizeof(DIVE_CAPS) );
199 dCaps.ulStructLen = sizeof(DIVE_CAPS);
200 dCaps.ulFormatLength = 100;
201 dCaps.pFormatData = &fccModes[0];
202
203 rc = DiveQueryCaps( &dCaps,
204 DIVE_BUFFER_SCREEN);
205
206 dprintf(("DDRAW: DiveQueryCaps rc=0x%08X\n",rc));
207
208 pdwUnknownData[235] = dCaps.ulHorizontalResolution;
209 pdwUnknownData[236] = dCaps.ulVerticalResolution;
210 pdwUnknownData[241] = dCaps.ulDepth;
211
212 screenwidth = dCaps.ulHorizontalResolution;
213 screenheight = dCaps.ulVerticalResolution;
214 screenbpp = dCaps.ulDepth;
215
216 // Shall we run in FS mode ?
217 if(ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,KEY_DIRECT2DRAW,&hkDirectDraw2))
218 {
219 dwVSize = 4;
220 dwVType = REG_DWORD;
221 if(ERROR_SUCCESS!=RegQueryValueExA(hkDirectDraw2,"Fullscreen",NULL,&dwVType,(LPBYTE)&bScale,&dwVSize))
222 bScale = FALSE;
223 }
224 else
225 bScale = FALSE;
226
227 // Check to see if FS DDraw is enabled in ODIN.INI
228 if (PROFILE_GetOdinIniBool(ODINDDRAW_SECTION, "Fullscreen", FALSE))
229 {
230 rc = InitIO();
231
232 if(rc) // try to get IOPL for the thread
233 {
234 dprintf(("DDRAW: No IOPL"));
235 }
236 else
237 {
238 dprintf(("DDRAW: IOPL 3!"));
239 }
240
241 rc = LoadPMIService();
242 dprintf(("DDRAW: LoadPMIService() rc=0x%08X",rc));
243
244 if (!rc) {
245 SetUpModeTable();
246
247 bUseFSDD = TRUE;
248 dprintf(("DDRAW: Fullscreen enabled",rc));
249 }
250 }
251}
252//******************************************************************************
253//******************************************************************************
254OS2IDirectDraw::~OS2IDirectDraw()
255{
256 dprintf(("DDRAW: OS2IDirectDraw::~OS2IDirectDraw()"));
257
258 if (hDive)
259 DiveClose(hDive);
260
261 // Safety call in case the program did set the pal to all black
262 // so if the destructor gets called we might be able change this back
263 OS2ResetPhysPalette();
264
265 // FSDDRAW additions
266 // we need this in Full Screen, but don't do anything in windowed
267 // session.
268 if (bUseFSDD) {
269 RestorePM();
270 FreeModeTable();
271 }
272}
273//******************************************************************************
274//******************************************************************************
275FOURCC OS2IDirectDraw::GetScreenFourCC()
276{
277 return SupportedFourCCs[screenbpp>>3];
278}
279//******************************************************************************
280//******************************************************************************
281HRESULT WIN32API DrawQueryInterface(THIS This, REFIID riid, LPVOID FAR * ppvObj)
282{
283 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
284
285 dprintf(("DDRAW: OS2IDirectDraw::QueryInterface %x %x %x", This, riid, ppvObj));
286
287 *ppvObj = NULL;
288
289 if(!IsEqualGUID(riid, CLSID_DirectDraw) &&
290 !IsEqualGUID(riid, IID_IDirectDraw) &&
291 !IsEqualGUID(riid, IID_IDirectDraw2) &&
292 !IsEqualGUID(riid, IID_IDirectDraw4) &&
293 !IsEqualGUID(riid, IID_IDirect3D))
294// !IsEqualGUID(riid, IID_IUnknown))
295 return E_NOINTERFACE;
296
297 // ToDo Better way of returning differnent interfaces for same class
298 if(IsEqualGUID(riid, IID_IDirect3D))
299 {
300 me->lpVtbl3D = &me->Vtbl3D;
301 me->lpVtbl3D2 = me->lpVtbl3D;
302 me->pdwUnknownData3D = me->pdwUnknownData;
303 *ppvObj = (LPVOID)&me->lpVtbl3D;
304 DrawAddRef(This);
305 return DD_OK;
306 }
307 else
308 {
309 if(IsEqualGUID(riid, IID_IDirectDraw4))
310 {
311 dprintf(("DDRAW: IID_IDirectDraw4 Interface"));
312 me->lpVtbl = &me->Vtbl4;
313 }
314 else
315 {
316 if(IsEqualGUID(riid, IID_IDirectDraw2))
317 {
318 dprintf(("DDRAW: IID_IDirectDraw2 Interface"));
319 me->lpVtbl = (IDirectDraw4Vtbl *) &me->Vtbl2;
320 }
321 else
322 {
323 dprintf(("DDRAW: IID_IDirectDraw Interface"));
324 me->lpVtbl = (IDirectDraw4Vtbl *) &me->Vtbl;
325 }
326 }
327 }
328 me->lpVtbl2 = me->lpVtbl;
329 *ppvObj = This;
330 DrawAddRef(This);
331
332 return(DD_OK);
333}
334//******************************************************************************
335//******************************************************************************
336ULONG WIN32API DrawAddRef(THIS This)
337{
338 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
339
340 dprintf(("DDRAW: OS2IDirectDraw::AddRef %d", me->Referenced+1));
341
342 return ++me->Referenced;
343}
344//******************************************************************************
345//******************************************************************************
346ULONG WIN32API DrawRelease(THIS This)
347{
348 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
349 ULONG rc;
350
351 dprintf(("DDRAW: OS2IDirectDraw::Release %d", me->Referenced-1));
352 dprintf(("DDRAW: OS2IDirectDraw::%X", me));
353
354 if(me->Referenced)
355 {
356
357 me->Referenced--;
358 if(me->Referenced == 0)
359 {
360 delete(me);
361 rc = 0;
362 }
363 else
364 rc = me->Referenced;
365 }
366 else
367 rc = 0;
368
369 return rc;
370}
371//******************************************************************************
372//******************************************************************************
373HRESULT WIN32API DrawCompact(THIS)
374{
375 dprintf(("DDRAW: Compact"));
376
377 return(DD_OK);
378}
379//******************************************************************************
380//******************************************************************************
381HRESULT WIN32API DrawCreateClipper(THIS This, DWORD, LPDIRECTDRAWCLIPPER FAR *lplpDD, IUnknown FAR * )
382{
383 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
384 OS2IDirectDrawClipper *newclip;
385 HRESULT rc;
386
387 newclip = new OS2IDirectDrawClipper(me);
388
389 dprintf(("DDRAW: CreateClipper"));
390
391 if(newclip == NULL)
392 {
393 rc = DDERR_OUTOFMEMORY;
394 }
395 else
396 {
397 newclip->Vtbl.AddRef((IDirectDrawClipper *)newclip);
398 rc = newclip->GetLastError();
399 if(rc != DD_OK)
400 {
401 *lplpDD = NULL;
402 delete newclip;
403 }
404 else
405 *lplpDD = (IDirectDrawClipper *)newclip;
406 }
407
408 return(rc);
409}
410//******************************************************************************
411//******************************************************************************
412HRESULT WIN32API DrawCreatePalette(THIS This, DWORD dwFlags,
413 LPPALETTEENTRY lpColorTable,
414 LPDIRECTDRAWPALETTE FAR *lplpDD,
415 IUnknown FAR *pUnkOuter)
416{
417 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
418 OS2IDirectDrawPalette *newpal;
419 HRESULT rc = DD_OK;
420 int palsize = 0;
421
422 if(dwFlags & DDPCAPS_8BITENTRIES)
423 {
424 // We Don't support Indexed palettes...
425
426 rc = DDERR_INVALIDPARAMS;
427 }
428
429 if(dwFlags & DDPCAPS_2BIT)
430 palsize = 4;
431 if(dwFlags & DDPCAPS_4BIT)
432 palsize = 16;
433 if(dwFlags & DDPCAPS_8BIT)
434 palsize = 256;
435 if(dwFlags & DDPCAPS_ALLOW256)
436 palsize = 256;
437
438 if(palsize == 0)
439 rc = DDERR_INVALIDPARAMS;
440
441 if(DD_OK == rc)
442 {
443 dprintf(("DDRAW: CreatePalette with %d colors", palsize));
444
445 newpal = new OS2IDirectDrawPalette((VOID*)me, palsize, lpColorTable, dwFlags);
446
447 if(newpal == NULL)
448 {
449 rc = DDERR_OUTOFMEMORY;
450 }
451 else
452 {
453 newpal->Vtbl.AddRef((IDirectDrawPalette *)newpal);
454 rc = newpal->GetLastError();
455
456 if(DD_OK != rc)
457 {
458 *lplpDD = NULL;
459 delete newpal;
460 }
461 else
462 *lplpDD = (IDirectDrawPalette *)newpal;
463 }
464 }
465
466 return(rc);
467}
468//******************************************************************************
469//******************************************************************************
470HRESULT WIN32API DrawCreateSurface(THIS This, LPDDSURFACEDESC lpDDSurfaceDesc,
471 LPDIRECTDRAWSURFACE FAR *lplpDD,
472 IUnknown FAR *pUnkOuter)
473{
474 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
475 OS2IDirectDrawSurface *newsurf;
476 HRESULT rc;
477
478 dprintf(("DDRAW: CreateSurface\n"));
479 dprintf(("DDRAW: dwSize %d\n", lpDDSurfaceDesc->dwSize));
480 dprintf(("DDRAW: dwFlags %X\n", lpDDSurfaceDesc->dwFlags));
481 dprintf(("DDRAW: dwHeight %d\n", lpDDSurfaceDesc->dwHeight));
482 dprintf(("DDRAW: dwWidth %d\n", lpDDSurfaceDesc->dwWidth));
483 dprintf(("DDRAW: lPitch %d\n", lpDDSurfaceDesc->lPitch));
484 dprintf(("DDRAW: dwBackBufferCount %d\n", lpDDSurfaceDesc->dwBackBufferCount));
485 dprintf(("DDRAW: dwMipMapCount %d\n", lpDDSurfaceDesc->dwMipMapCount));
486 dprintf(("DDRAW: dwAlphaBitDepth %d\n", lpDDSurfaceDesc->dwAlphaBitDepth));
487 dprintf(("DDRAW: ddsCaps.dwCaps %X\n", lpDDSurfaceDesc->ddsCaps.dwCaps));
488
489 newsurf = new OS2IDirectDrawSurface(me, (LPDDSURFACEDESC2)lpDDSurfaceDesc);
490 if(newsurf == NULL)
491 {
492 rc = DDERR_OUTOFMEMORY;
493 }
494 else
495 {
496 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
497 rc = newsurf->GetLastError();
498 if(rc != DD_OK)
499 {
500 dprintf(("DDRAW: Error createing Surface rc = %d\n\n", rc));
501 *lplpDD = NULL;
502 delete newsurf;
503 }
504 else
505 *lplpDD = (IDirectDrawSurface *)newsurf;
506
507 dprintf(("DDRAW: New Surface created at %08X\n\n", newsurf));
508 }
509
510 return(rc);
511}
512//******************************************************************************
513//******************************************************************************
514HRESULT WIN32API DrawCreateSurface4(THIS This, LPDDSURFACEDESC2 lpDDSurfaceDesc2,
515 LPDIRECTDRAWSURFACE4 FAR *lplpDD,
516 IUnknown FAR *pUnkOuter)
517{
518 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
519 OS2IDirectDrawSurface *newsurf;
520 HRESULT rc;
521
522 dprintf(("DDRAW: CreateSurface4\n"));
523 dprintf(("DDRAW: dwSize %d\n", lpDDSurfaceDesc2->dwSize));
524 dprintf(("DDRAW: dwHeight %d\n", lpDDSurfaceDesc2->dwHeight));
525 dprintf(("DDRAW: dwWidth %d\n", lpDDSurfaceDesc2->dwWidth));
526 dprintf(("DDRAW: lPitch %d\n", lpDDSurfaceDesc2->lPitch));
527 dprintf(("DDRAW: dwBackBufferCount %d\n", lpDDSurfaceDesc2->dwBackBufferCount));
528 dprintf(("DDRAW: dwMipMapCount %d\n", lpDDSurfaceDesc2->dwMipMapCount));
529 dprintf(("DDRAW: dwAlphaBitDepth %d\n", lpDDSurfaceDesc2->dwAlphaBitDepth));
530 dprintf(("DDRAW: ddsCaps.dwCaps %X\n", lpDDSurfaceDesc2->ddsCaps.dwCaps));
531
532 newsurf = new OS2IDirectDrawSurface(me, lpDDSurfaceDesc2);
533
534 if(newsurf == NULL)
535 {
536 rc = DDERR_OUTOFMEMORY;
537 }
538 else
539 {
540 newsurf->Vtbl.AddRef((IDirectDrawSurface *)newsurf);
541 rc = newsurf->GetLastError();
542 if(rc != DD_OK)
543 {
544 dprintf(("DDRAW: Error createing Surface\n\n"));
545 *lplpDD = NULL;
546
547 delete newsurf;
548 }
549 else
550 *lplpDD = (IDirectDrawSurface4 *)newsurf;
551
552 dprintf(("DDRAW: New Surface created at %08X\n\n", newsurf));
553 }
554
555 return(rc);
556}
557//******************************************************************************
558//******************************************************************************
559HRESULT WIN32API DrawDuplicateSurface(THIS, LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE FAR * )
560{
561 dprintf(("DDRAW: DuplicateSurface NIY\n"));
562
563 return(DD_OK);
564}
565//******************************************************************************
566//******************************************************************************
567HRESULT WIN32API DrawDuplicateSurface4(THIS, LPDIRECTDRAWSURFACE4, LPDIRECTDRAWSURFACE4 FAR * )
568{
569 dprintf(("DDRAW: DuplicateSurface4 NIY\n"));
570
571 return(DD_OK);
572}
573//******************************************************************************
574//******************************************************************************
575HRESULT WIN32API DrawEnumDisplayModes( THIS This,
576 DWORD dwFlags,
577 LPDDSURFACEDESC lpDDSurfaceDesc,
578 LPVOID lpContext,
579 LPDDENUMMODESCALLBACK lpDDEnumModesCallback)
580{
581 int iMode = 0;
582 DDSURFACEDESC DDSurfAct;
583 BOOL fCallAgain;
584 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
585
586 dprintf(("DDRAW: EnumDisplayModes\n"));
587
588 // Check for Pointer to callback function
589 if (NULL == lpDDEnumModesCallback)
590 {
591 dprintf(("DDRAW: EnumDisplayModes : Error NO EnumFunction passed in\n"));
592
593 return(DDERR_GENERIC);
594 }
595
596
597 // Setting up the surface
598 // During enum we report resolution and bitdepth, maybe we should
599 // also report back : Caps and Pitch
600 memset(&DDSurfAct,0,sizeof(DDSURFACEDESC));
601 DDSurfAct.dwSize = sizeof(DDSURFACEDESC);
602 DDSurfAct.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT ;
603 // Only report the bitdepth hope this is ok this way, we must set the BitMask fields
604
605 DDSurfAct.ddpfPixelFormat.dwSize = sizeof (DDPIXELFORMAT);
606 DDSurfAct.ddpfPixelFormat.dwFlags = DDPF_RGB;
607 // Check if we use DIVE or Voodoo
608 if(me->lpVtbl != (IDirectDraw4Vtbl *) &(me->Vtbl3D))
609 {
610 // DIVE modes
611
612 dprintf(("DDRAW: EnumDisplayModes : DIVE modes\n"));
613
614 // Enumerate all modes ?
615 if (NULL==lpDDSurfaceDesc)
616 {
617 // Check if we shall report 320x200 mode
618
619 dprintf(("DDRAW: EnumDisplayModes : ALL modes\n"));
620
621 if(dwFlags && DDEDM_STANDARDVGAMODES)
622 {
623 dprintf(("DDRAW: EnumDisplayModes : STANDARDVGAMODES\n"));
624
625 DDSurfAct.dwHeight = ModesDive[0].iYRes;
626 DDSurfAct.dwWidth = ModesDive[0].iXRes;
627 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
628 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8 ;
629 if(!lpDDEnumModesCallback(&DDSurfAct,lpContext))
630 {
631 dprintf(("DDRAW: EnumDisplayModes : Enum done\n"));
632 return (DD_OK);
633 }
634 }
635 // Don't know the flag for Mode X so we skip reporting it
636
637 // Now report all our modes
638 iMode = 2;
639 fCallAgain = TRUE;
640 do
641 {
642 // if the mode fits in the current resolution report it
643 // Change this if we support Fullscreen later !!!
644
645 if(ModesDive[iMode].iXRes < me->dCaps.ulHorizontalResolution)
646 {
647 DDSurfAct.dwHeight = ModesDive[iMode].iYRes;
648 DDSurfAct.dwWidth = ModesDive[iMode].iXRes;
649 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[iMode].iBits;
650 switch(ModesDive[iMode].iBits)
651 {
652 case 8:
653 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
654 break;
655 case 16:
656 // VESA uses 565 encoding in 16 bit modes
657 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
658 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
659 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
660 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
661 break;
662 case 24:
663 // VESA uses per default RGB4
664 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
665 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
666 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
667 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x000000FF;
668 break;
669 default:
670 break;
671 }
672 dprintf( ("EnumDisplayModes : Enum Mode %dx%d @ %d\n",
673 DDSurfAct.dwHeight,
674 DDSurfAct.dwWidth,
675 DDSurfAct.ddpfPixelFormat.dwRGBBitCount));
676 fCallAgain = lpDDEnumModesCallback(&DDSurfAct,lpContext);
677 dprintf( ("EnumDisplayModes : Callback returned with %d\n",
678 fCallAgain));
679 }
680 iMode++;
681 }
682 while( (iMode < NUM_MODES_DIVE) &&
683 (ModesDive[iMode].iBits <= me->dCaps.ulDepth) &&
684 (TRUE==fCallAgain) );
685 }
686 else
687 {
688 // No, so filter modes with lpDDSurfaceDesc
689
690 // Return Error if the program want to use other than the 3 supported values
691 // for filtering
692
693 if (lpDDSurfaceDesc->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT))
694 return(DDERR_INVALIDPARAMS);
695
696 iMode = 0;
697 if( (dwFlags && DDEDM_STANDARDVGAMODES) &&
698 (
699 (((lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)&&
700 (ModesDive[iMode].iXRes==lpDDSurfaceDesc->dwWidth)
701 )||(!(lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)))&&
702 (((lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)&&
703 (ModesDive[iMode].iYRes==lpDDSurfaceDesc->dwHeight))||
704 (!(lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)))&&
705 (((lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) &&
706 (ModesDive[iMode].iBits==lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount))||
707 (!(lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)))
708 )
709 )
710 {
711 DDSurfAct.dwHeight = ModesDive[0].iYRes;
712 DDSurfAct.dwWidth = ModesDive[0].iXRes;
713 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
714 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
715 if(!lpDDEnumModesCallback(&DDSurfAct,lpContext))
716 {
717 return (DD_OK);
718 }
719 }
720 // Don't know the flag for Mode X so we skip reporting it
721
722 // Now report all our modes
723 iMode = 2;
724 fCallAgain = TRUE;
725 do
726 {
727 // if the mode fits in the current resolution and the filter applies report it
728 // Change this if we support Fullscreen later !!!
729 if( (ModesDive[iMode].iXRes < me->dCaps.ulHorizontalResolution)&&
730 (
731 (((lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)&&
732 (ModesDive[iMode].iXRes==lpDDSurfaceDesc->dwWidth))||
733 (!(lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)))&&
734 (((lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)&&
735 (ModesDive[iMode].iYRes==lpDDSurfaceDesc->dwHeight))||
736 (!(lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)))&&
737 (((lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) &&
738 (ModesDive[iMode].iBits==lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount))||
739 (!(lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)))
740 )
741 )
742 {
743 DDSurfAct.dwHeight = ModesDive[iMode].iYRes;
744 DDSurfAct.dwWidth = ModesDive[iMode].iXRes;
745 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[iMode].iBits;
746 switch(ModesDive[iMode].iBits)
747 {
748 case 8:
749 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
750 break;
751 case 16:
752 // VESA uses 565 encoding in 16 bit modes
753 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
754 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
755 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
756 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
757 break;
758 case 24:
759 // VESA uses per default RGB4
760 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
761 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
762 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
763 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x000000FF;
764 break;
765 default:
766 break;
767 }
768
769 dprintf(("Call lpDDEnumModesCallback with mode (%d,%d) bps %d", DDSurfAct.dwWidth, DDSurfAct.dwHeight, ModesDive[iMode].iBits));
770 fCallAgain = lpDDEnumModesCallback(&DDSurfAct,lpContext);
771 }
772 iMode++;
773 }
774 while((ModesDive[iMode].iBits <= me->dCaps.ulDepth) &&
775 (iMode < NUM_MODES_DIVE) && (TRUE==fCallAgain));
776
777 }
778 }
779 else
780 {
781
782 // VOODOO modes
783
784 // Enumerate all modes ?
785 if (NULL==lpDDSurfaceDesc)
786 {
787
788 // report all our modes
789 iMode = 0;
790 fCallAgain = TRUE;
791 do
792 {
793 DDSurfAct.dwHeight = ModesVoodoo[iMode].iYRes;
794 DDSurfAct.dwWidth = ModesVoodoo[iMode].iXRes;
795 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesVoodoo[iMode].iBits;
796
797 fCallAgain = lpDDEnumModesCallback(&DDSurfAct,lpContext);
798 iMode++;
799 }
800 while((iMode < NUM_MODES_VOODOO) && (TRUE==fCallAgain));
801 }
802 else
803 {
804 // No, so filter modes with lpDDSurfaceDesc
805
806 // Return Error if the program want to use other than the 3 supported values
807 // for filtering
808
809 if (lpDDSurfaceDesc->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT))
810 {
811 return(DDERR_INVALIDPARAMS);
812 }
813
814 iMode = 2;
815 fCallAgain = TRUE;
816 // All reported mode are 16bit
817 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
818 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
819 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
820 do
821 {
822 // if the mode fits the filter applies report it
823 if(
824 (((lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)&&
825 (ModesVoodoo[iMode].iXRes==lpDDSurfaceDesc->dwWidth))||
826 (!(lpDDSurfaceDesc->dwFlags & DDSD_WIDTH)))&&
827 (((lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)&&
828 (ModesVoodoo[iMode].iYRes==lpDDSurfaceDesc->dwHeight))||
829 (!(lpDDSurfaceDesc->dwFlags & DDSD_HEIGHT)))&&
830 (((lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT) &&
831 (ModesVoodoo[iMode].iBits==lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount))||
832 (!(lpDDSurfaceDesc->dwFlags & DDSD_PIXELFORMAT)))
833 )
834 {
835 DDSurfAct.dwHeight = ModesVoodoo[iMode].iYRes;
836 DDSurfAct.dwWidth = ModesVoodoo[iMode].iXRes;
837 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesVoodoo[iMode].iBits;
838
839 fCallAgain = lpDDEnumModesCallback(&DDSurfAct,lpContext);
840 }
841 iMode++;
842 }
843 while((iMode < NUM_MODES_VOODOO) && (TRUE==fCallAgain));
844
845 }
846
847 }
848 return(DD_OK);
849}
850//******************************************************************************
851//******************************************************************************
852HRESULT WIN32API DrawEnumDisplayModes4(THIS This, DWORD dwFlags, LPDDSURFACEDESC2 lpDDSurfaceDesc2,
853 LPVOID lpContext, LPDDENUMMODESCALLBACK2 lpDDEnumModesCallback2)
854{
855 int iMode = 0;
856 DDSURFACEDESC2 DDSurfAct;
857 BOOL fCallAgain;
858 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
859
860 dprintf(("DDRAW: EnumDisplayModes4"));
861
862 // Check for Pointer to callback function
863 if (NULL == lpDDEnumModesCallback2)
864 {
865 dprintf(("DDRAW: EnumDisplayModes4 : Error NO EnumFunction passed in\n"));
866
867 return(DDERR_GENERIC);
868 }
869
870
871 // Setting up the surface
872 // During enum we report resolution and bitdepth, maybe we should
873 // also report back : Caps and Pitch
874 memset(&DDSurfAct,0,sizeof(DDSURFACEDESC2));
875 DDSurfAct.dwSize = sizeof(DDSURFACEDESC2);
876 DDSurfAct.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT ;
877 // Only report the bitdepth hope this is ok this way, we must set the BitMask fields
878
879 DDSurfAct.ddpfPixelFormat.dwSize = sizeof (DDPIXELFORMAT);
880 DDSurfAct.ddpfPixelFormat.dwFlags = DDPF_RGB;
881
882 // Check if we use DIVE or Voodoo
883 if(me->lpVtbl != (IDirectDraw4Vtbl *) &(me->Vtbl3D))
884 {
885 // DIVE modes
886
887 dprintf(("DDRAW: EnumDisplayModes : DIVE modes\n"));
888
889 // Enumerate all modes ?
890 if (NULL==lpDDSurfaceDesc2)
891 {
892 // Check if we shall report 320x200 mode
893
894 dprintf(("DDRAW: EnumDisplayModes : ALL modes\n"));
895
896 if(dwFlags && DDEDM_STANDARDVGAMODES)
897 {
898 dprintf(("DDRAW: EnumDisplayModes : STANDARDVGAMODES\n"));
899
900 DDSurfAct.dwHeight = ModesDive[0].iYRes;
901 DDSurfAct.dwWidth = ModesDive[0].iXRes;
902 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
903 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8 ;
904 if(!lpDDEnumModesCallback2(&DDSurfAct,lpContext))
905 {
906 dprintf(("DDRAW: EnumDisplayModes : Enum done\n"));
907 return (DD_OK);
908 }
909 }
910 // Don't know the flag for Mode X so we skip reporting it
911
912 // Now report all our modes
913 iMode = 2;
914 fCallAgain = TRUE;
915 do
916 {
917 // if the mode fits in the current resolution report it
918 // Change this if we support Fullscreen later !!!
919
920 if(ModesDive[iMode].iXRes < me->dCaps.ulHorizontalResolution)
921 {
922 DDSurfAct.dwHeight = ModesDive[iMode].iYRes;
923 DDSurfAct.dwWidth = ModesDive[iMode].iXRes;
924 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[iMode].iBits;
925 switch(ModesDive[iMode].iBits)
926 {
927 case 8:
928 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
929 break;
930 case 16:
931 // VESA uses 565 encoding in 16 bit modes
932 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
933 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
934 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
935 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
936 break;
937 case 24:
938 // VESA uses per default RGB4
939 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
940 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
941 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
942 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x000000FF;
943 break;
944 default:
945 break;
946 }
947 dprintf( ("EnumDisplayModes : Enum Mode %dx%d @ %d\n",
948 DDSurfAct.dwHeight,
949 DDSurfAct.dwWidth,
950 DDSurfAct.ddpfPixelFormat.dwRGBBitCount));
951 fCallAgain = lpDDEnumModesCallback2(&DDSurfAct,lpContext);
952 dprintf( ("EnumDisplayModes : Callback returned with %d\n",
953 fCallAgain));
954 }
955 iMode++;
956 }
957 while( (iMode < NUM_MODES_DIVE) &&
958 (ModesDive[iMode].iBits <= me->dCaps.ulDepth) &&
959 (TRUE==fCallAgain) );
960 }
961 else
962 {
963 // No, so filter modes with lpDDSurfaceDesc2
964
965 // Return Error if the program want to use other than the 3 supported values
966 // for filtering
967
968 if (lpDDSurfaceDesc2->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT))
969 return(DDERR_INVALIDPARAMS);
970
971 iMode = 0;
972 if( (dwFlags && DDEDM_STANDARDVGAMODES) &&
973 (
974 (((lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)&&
975 (ModesDive[iMode].iXRes==lpDDSurfaceDesc2->dwWidth)
976 )||(!(lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)))&&
977 (((lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)&&
978 (ModesDive[iMode].iYRes==lpDDSurfaceDesc2->dwHeight))||
979 (!(lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)))&&
980 (((lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT) &&
981 (ModesDive[iMode].iBits==lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBBitCount))||
982 (!(lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT)))
983 )
984 )
985 {
986 DDSurfAct.dwHeight = ModesDive[0].iYRes;
987 DDSurfAct.dwWidth = ModesDive[0].iXRes;
988 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[0].iBits;
989 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
990 if(!lpDDEnumModesCallback2(&DDSurfAct,lpContext))
991 {
992 return (DD_OK);
993 }
994 }
995 // Don't know the flag for Mode X so we skip reporting it
996
997 // Now report all our modes
998 iMode = 2;
999 fCallAgain = TRUE;
1000 do
1001 {
1002 // if the mode fits in the current resolution and the filter applies report it
1003 // Change this if we support Fullscreen later !!!
1004 if( (ModesDive[iMode].iXRes < me->dCaps.ulHorizontalResolution)&&
1005 (
1006 (((lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)&&
1007 (ModesDive[iMode].iXRes==lpDDSurfaceDesc2->dwWidth))||
1008 (!(lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)))&&
1009 (((lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)&&
1010 (ModesDive[iMode].iYRes==lpDDSurfaceDesc2->dwHeight))||
1011 (!(lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)))&&
1012 (((lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT) &&
1013 (ModesDive[iMode].iBits==lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBBitCount))||
1014 (!(lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT)))
1015 )
1016 )
1017 {
1018 DDSurfAct.dwHeight = ModesDive[iMode].iYRes;
1019 DDSurfAct.dwWidth = ModesDive[iMode].iXRes;
1020 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesDive[iMode].iBits;
1021 switch(ModesDive[iMode].iBits)
1022 {
1023 case 8:
1024 DDSurfAct.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
1025 break;
1026 case 16:
1027 // VESA uses 565 encoding in 16 bit modes
1028 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
1029 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
1030 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
1031 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
1032 break;
1033 case 24:
1034 // VESA uses per default RGB4
1035 DDSurfAct.ddpfPixelFormat.dwFlags &= ~DDPF_PALETTEINDEXED8;
1036 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x00FF0000;
1037 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1038 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x000000FF;
1039 break;
1040 default:
1041 break;
1042 }
1043
1044 dprintf(("Call lpDDEnumModesCallback with mode (%d,%d) bps %d", DDSurfAct.dwWidth, DDSurfAct.dwHeight, ModesDive[iMode].iBits));
1045 fCallAgain = lpDDEnumModesCallback2(&DDSurfAct,lpContext);
1046 }
1047 iMode++;
1048 }
1049 while((ModesDive[iMode].iBits <= me->dCaps.ulDepth) &&
1050 (iMode < NUM_MODES_DIVE) && (TRUE==fCallAgain));
1051
1052 }
1053 }
1054 else
1055 {
1056
1057 // VOODOO modes
1058
1059 // Enumerate all modes ?
1060 if (NULL==lpDDSurfaceDesc2)
1061 {
1062
1063 // report all our modes
1064 iMode = 0;
1065 fCallAgain = TRUE;
1066 do
1067 {
1068 DDSurfAct.dwHeight = ModesVoodoo[iMode].iYRes;
1069 DDSurfAct.dwWidth = ModesVoodoo[iMode].iXRes;
1070 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesVoodoo[iMode].iBits;
1071
1072 fCallAgain = lpDDEnumModesCallback2(&DDSurfAct,lpContext);
1073 iMode++;
1074 }
1075 while((iMode < NUM_MODES_VOODOO) && (TRUE==fCallAgain));
1076 }
1077 else
1078 {
1079 // No, so filter modes with lpDDSurfaceDesc2
1080
1081 // Return Error if the program want to use other than the 3 supported values
1082 // for filtering
1083
1084 if (lpDDSurfaceDesc2->dwFlags & !(DDSD_WIDTH|DDSD_HEIGHT|DDSD_PIXELFORMAT))
1085 {
1086 return(DDERR_INVALIDPARAMS);
1087 }
1088
1089 iMode = 2;
1090 fCallAgain = TRUE;
1091 // All reported mode are 16bit
1092 DDSurfAct.ddpfPixelFormat.dwRBitMask = 0x0000F800;
1093 DDSurfAct.ddpfPixelFormat.dwGBitMask = 0x000007E0;
1094 DDSurfAct.ddpfPixelFormat.dwBBitMask = 0x0000001F;
1095 do
1096 {
1097 // if the mode fits the filter applies report it
1098 if(
1099 (((lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)&&
1100 (ModesVoodoo[iMode].iXRes==lpDDSurfaceDesc2->dwWidth))||
1101 (!(lpDDSurfaceDesc2->dwFlags & DDSD_WIDTH)))&&
1102 (((lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)&&
1103 (ModesVoodoo[iMode].iYRes==lpDDSurfaceDesc2->dwHeight))||
1104 (!(lpDDSurfaceDesc2->dwFlags & DDSD_HEIGHT)))&&
1105 (((lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT) &&
1106 (ModesVoodoo[iMode].iBits==lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBBitCount))||
1107 (!(lpDDSurfaceDesc2->dwFlags & DDSD_PIXELFORMAT)))
1108 )
1109 {
1110 DDSurfAct.dwHeight = ModesVoodoo[iMode].iYRes;
1111 DDSurfAct.dwWidth = ModesVoodoo[iMode].iXRes;
1112 DDSurfAct.ddpfPixelFormat.dwRGBBitCount = ModesVoodoo[iMode].iBits;
1113
1114 fCallAgain = lpDDEnumModesCallback2(&DDSurfAct,lpContext);
1115 }
1116 iMode++;
1117 }
1118 while((iMode < NUM_MODES_VOODOO) && (TRUE==fCallAgain));
1119
1120 }
1121
1122 }
1123 return(DD_OK);
1124}
1125
1126//******************************************************************************
1127//******************************************************************************
1128HRESULT WIN32API DrawEnumSurfaces(THIS, DWORD, LPDDSURFACEDESC, LPVOID,LPDDENUMSURFACESCALLBACK )
1129{
1130 dprintf(("DDRAW: EnumSurfaces NIY\n"));
1131
1132 return(DD_OK);
1133}
1134
1135//******************************************************************************
1136//******************************************************************************
1137HRESULT WIN32API DrawEnumSurfaces4(THIS, DWORD, LPDDSURFACEDESC2, LPVOID,LPDDENUMSURFACESCALLBACK2 )
1138{
1139 dprintf(("DDRAW: EnumSurfaces4 NIY\n"));
1140
1141 return(DD_OK);
1142}
1143
1144//******************************************************************************
1145//******************************************************************************
1146HRESULT WIN32API DrawFlipToGDISurface(THIS)
1147{
1148 dprintf(("DDRAW: FlipToGDISurface NIY\n"));
1149
1150 return(DD_OK);
1151}
1152
1153//******************************************************************************
1154//******************************************************************************
1155HRESULT WIN32API DrawGetCaps(THIS This, LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
1156{
1157 DWORD dwSize;
1158 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1159
1160 dprintf(("DDRAW: DDGetCaps %x %x %x", This, lpDDDriverCaps, lpDDHELCaps));
1161
1162 if( (NULL==lpDDDriverCaps) && (NULL==lpDDHELCaps) )
1163 return(DDERR_INVALIDPARAMS);
1164
1165 if(NULL!=lpDDDriverCaps)
1166 {
1167 // Caller want Driver Caps
1168
1169 dprintf(("DDRAW: Driver\n"));
1170
1171 if( (sizeof(DDCAPS)!=lpDDDriverCaps->dwSize) &&
1172 (sizeof(DDCAPS_DX5)!=lpDDDriverCaps->dwSize) &&
1173 (sizeof(DDCAPS_DX3)!=lpDDDriverCaps->dwSize) )
1174 {
1175 dprintf( ("Size %d Not supported ",
1176 lpDDDriverCaps->dwSize));
1177 return(DDERR_INVALIDPARAMS);
1178 }
1179 // Clear structure so we only have to set the supported flags
1180
1181 dwSize = lpDDDriverCaps->dwSize;
1182 memset( lpDDDriverCaps,
1183 0,
1184 lpDDDriverCaps->dwSize);
1185
1186
1187 // Reset the size
1188 lpDDDriverCaps->dwSize = dwSize;
1189
1190 // Now report the CAPs back which we support
1191 lpDDDriverCaps->dwCaps = DDCAPS_BLT | // We do blitting
1192 DDCAPS_BLTSTRETCH |
1193 DDCAPS_BLTCOLORFILL | // We do colorfills
1194 DDCAPS_BLTDEPTHFILL |
1195 DDCAPS_COLORKEY | // We support Colorkeying
1196 DDCAPS_COLORKEYHWASSIST | // But we (may) use the CPU
1197 DDCAPS_GDI | // Maybe check if we are on Voodoo ?
1198 DDCAPS_PALETTEVSYNC | // Got VSync
1199// DDCAPS_READSCANLINE |
1200 DDCAPS_BLTFOURCC;
1201
1202 lpDDDriverCaps->dwCaps2 = DDCAPS2_CERTIFIED | // Who cares so say yes
1203 DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1204 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1205 DDCAPS2_NONLOCALVIDMEM | // All surfaces are in memory
1206 DDCAPS2_WIDESURFACES; // Any size you want!
1207
1208 lpDDDriverCaps->dwCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1209
1210 lpDDDriverCaps->dwFXCaps = DDFXCAPS_BLTMIRRORUPDOWN |
1211 DDFXCAPS_BLTMIRRORLEFTRIGHT; // DIVE supports this, do we also ?
1212 // Maybe later add stretching support?
1213
1214 lpDDDriverCaps->dwPalCaps = DDPCAPS_8BIT | // Only 8 Bits pals
1215 DDPCAPS_ALLOW256 | // But all 256 colors
1216 DDPCAPS_VSYNC | // Vsync yet
1217 DDPCAPS_PRIMARYSURFACE; //
1218 lpDDDriverCaps->dwVidMemTotal = me->dCaps.ulApertureSize; // total video memory
1219 lpDDDriverCaps->dwVidMemFree = me->dCaps.ulApertureSize; // total free video memory
1220 lpDDDriverCaps->dwNumFourCCCodes = MAX_FOURCC_CODES; // number of supported FOURCC codes
1221/*
1222 ToDo: must finde out ow the array is used for this
1223 lpDDDriverCaps->dwRops[DD_ROP_SPACE] = SRCCOPY |
1224 BLACKNESS |
1225 WHITENESS; // Raster OPs implemented
1226*/
1227 lpDDDriverCaps->dwSVBCaps = DDCAPS_BLT | // We do blitting
1228 DDCAPS_BLTCOLORFILL | // We do colorfills
1229 DDCAPS_COLORKEY | // We support Colorkeying
1230 DDCAPS_COLORKEYHWASSIST;
1231 lpDDDriverCaps->dwSVBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1232 lpDDDriverCaps->dwSVBFXCaps = DDCAPS_BLT | // We do blitting
1233 DDCAPS_BLTCOLORFILL | // We do colorfills
1234 DDCAPS_COLORKEY | // We support Colorkeying
1235 DDCAPS_COLORKEYHWASSIST;
1236/*
1237 ToDo: must finde out ow the array is used for this
1238 lpDDDriverCaps->dwSVBRops[DD_ROP_SPACE] = SRCCOPY |
1239 BLACKNESS |
1240 WHITENESS; // Raster OPs implemented
1241*/
1242 lpDDDriverCaps->dwVSBCaps = DDCAPS_BLT | // We do blitting
1243 DDCAPS_BLTCOLORFILL | // We do colorfills
1244 DDCAPS_COLORKEY | // We support Colorkeying
1245 DDCAPS_COLORKEYHWASSIST;
1246 lpDDDriverCaps->dwVSBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1247 lpDDDriverCaps->dwVSBFXCaps = DDCAPS_BLT | // We do blitting
1248 DDCAPS_BLTCOLORFILL | // We do colorfills
1249 DDCAPS_COLORKEY | // We support Colorkeying
1250 DDCAPS_COLORKEYHWASSIST;
1251/*
1252 ToDo: must finde out ow the array is used for this
1253 lpDDDriverCaps->dwVSBRops[DD_ROP_SPACE] = SRCCOPY |
1254 BLACKNESS |
1255 WHITENESS; // Raster OPs implemented
1256*/
1257 lpDDDriverCaps->dwSSBCaps = DDCAPS_BLT | // We do blitting
1258 DDCAPS_BLTCOLORFILL | // We do colorfills
1259 DDCAPS_COLORKEY | // We support Colorkeying
1260 DDCAPS_COLORKEYHWASSIST;
1261 lpDDDriverCaps->dwSSBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1262 lpDDDriverCaps->dwSSBFXCaps = DDCAPS_BLT | // We do blitting
1263 DDCAPS_BLTCOLORFILL | // We do colorfills
1264 DDCAPS_COLORKEY | // We support Colorkeying
1265 DDCAPS_COLORKEYHWASSIST;
1266/*
1267 ToDo: must finde out ow the array is used for this
1268 lpDDDriverCaps->dwSSBRops[SRCCOPY] = 1;
1269 lpDDDriverCaps->dwSSBRops[BLACKNESS] = 1;
1270 lpDDDriverCaps->dwSSBRops[WHITENESS] = 1; // Raster OPs implemented
1271*/
1272 // These are ony in >DX5
1273 if(dwSize>sizeof(DDCAPS_DX3))
1274 {
1275 lpDDDriverCaps->dwSVBCaps2 = //DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1276 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1277 DDCAPS2_WIDESURFACES; // Any size you want!
1278 lpDDDriverCaps->dwNLVBCaps = DDCAPS_BLT | // We do blitting
1279 DDCAPS_BLTCOLORFILL | // We do colorfills
1280 DDCAPS_COLORKEY | // We support Colorkeying
1281 DDCAPS_COLORKEYHWASSIST;
1282 lpDDDriverCaps->dwNLVBCaps2 = //DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1283 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1284 DDCAPS2_WIDESURFACES; // Any size you want!
1285 lpDDDriverCaps->dwNLVBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1286 lpDDDriverCaps->dwNLVBFXCaps = DDCAPS_BLT | // We do blitting
1287 DDCAPS_BLTCOLORFILL | // We do colorfills
1288 DDCAPS_COLORKEY | // We support Colorkeying
1289 DDCAPS_COLORKEYHWASSIST;
1290 lpDDDriverCaps->dwNLVBRops[DD_ROP_SPACE];// ToDo: Again the array ...
1291
1292 // General Surface caps only in DX6
1293 if(dwSize>sizeof(DDCAPS_DX5))
1294 {
1295 lpDDDriverCaps->ddsCaps.dwCaps = DDSCAPS_ALPHA | DDSCAPS_BACKBUFFER |
1296 DDSCAPS_COMPLEX | DDSCAPS_FLIP |
1297 DDSCAPS_FRONTBUFFER | DDSCAPS_LOCALVIDMEM |
1298 DDSCAPS_NONLOCALVIDMEM | DDSCAPS_OFFSCREENPLAIN |
1299 // DDSCAPS_OVERLAY |
1300 DDSCAPS_PALETTE | DDSCAPS_PRIMARYSURFACE |
1301 DDSCAPS_SYSTEMMEMORY |DDSCAPS_VIDEOMEMORY |
1302 DDSCAPS_VISIBLE;
1303
1304 #ifdef USE_OPENGL
1305 lpDDDriverCaps->dwCaps |= DDCAPS_3D | DDCAPS_ZBLTS;
1306 // ToDO find and put the value for DDCAPS2_NO2DDURING3DSCENE in ddraw.h
1307 // lpDDDriverCaps->dwCaps2 |= DDCAPS2_NO2DDURING3DSCENE;
1308 lpDDDriverCaps->ddsCaps.dwCaps |= DDSCAPS_3DDEVICE | DDSCAPS_MIPMAP |
1309 DDSCAPS_TEXTURE | DDSCAPS_ZBUFFER;
1310 #endif
1311 }
1312 }
1313
1314
1315 }
1316
1317 if(NULL!=lpDDHELCaps)
1318 {
1319 // Caller wants HEL Caps
1320 dprintf(("DDRAW: CHEL\n"));
1321
1322 //SvL: PowerDVD uses size 316
1323 if( (sizeof(DDCAPS) != lpDDHELCaps->dwSize) &&
1324 (sizeof(DDCAPS_DX5) != lpDDHELCaps->dwSize) &&
1325 (sizeof(DDCAPS_DX3) != lpDDHELCaps->dwSize) )
1326 {
1327 dprintf( ("Size %d Not supported ",
1328 lpDDHELCaps->dwSize));
1329 return(DDERR_INVALIDPARAMS);
1330 }
1331 // Clear structure so we only have to set the supported flags
1332
1333 dwSize = lpDDHELCaps->dwSize;
1334 memset( lpDDHELCaps,
1335 0,
1336 lpDDHELCaps->dwSize);
1337
1338 // Reset the size
1339 lpDDHELCaps->dwSize = dwSize;
1340
1341 // Now report the CAPs back which we support
1342 lpDDHELCaps->dwCaps = DDCAPS_BLT | // We do blitting
1343 DDCAPS_BLTCOLORFILL | // We do colorfills
1344 DDCAPS_COLORKEY | // We support Colorkeying
1345//SvL: This is the emulation layer; no hw support here
1346// DDCAPS_COLORKEYHWASSIST | // But we (may) use the CPU
1347 DDCAPS_GDI | // Maybe check if we are on Voodoo ?
1348 DDCAPS_PALETTEVSYNC | // Got VSync
1349 DDCAPS_BLTFOURCC;
1350
1351 lpDDHELCaps->dwCaps2 = DDCAPS2_CERTIFIED | // Who cares so say yes
1352 DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1353 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1354 DDCAPS2_NONLOCALVIDMEM | // All surfaces are in memory
1355 DDCAPS2_WIDESURFACES; // Any size you want!
1356
1357 lpDDHELCaps->dwCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1358
1359 lpDDHELCaps->dwFXCaps = DDFXCAPS_BLTMIRRORUPDOWN |
1360 DDFXCAPS_BLTMIRRORLEFTRIGHT; // DIVE supports this, do we also ?
1361 // Maybe later add stretching support?
1362
1363 lpDDHELCaps->dwPalCaps = DDPCAPS_8BIT | // Only 8 Bits pals
1364 DDPCAPS_ALLOW256 | // But all 256 colors
1365 DDPCAPS_VSYNC | // Vsync yet
1366 DDPCAPS_PRIMARYSURFACE;
1367
1368 //Video memory for emulation layer must be 0 (verified in NT)
1369 lpDDHELCaps->dwVidMemTotal = 0; // total video memory
1370 lpDDHELCaps->dwVidMemFree = 0; // total free video memory
1371
1372 lpDDHELCaps->dwNumFourCCCodes = MAX_FOURCC_CODES; // number of supported FOURCC codes
1373 lpDDHELCaps->dwRops[DD_ROP_SPACE]; // supported raster ops
1374 lpDDHELCaps->dwSVBCaps = DDCAPS_BLT | // We do blitting
1375 DDCAPS_BLTCOLORFILL | // We do colorfills
1376 DDCAPS_COLORKEY | // We support Colorkeying
1377 DDCAPS_COLORKEYHWASSIST;
1378 lpDDHELCaps->dwSVBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1379 lpDDHELCaps->dwSVBFXCaps; // .
1380 lpDDHELCaps->dwSVBRops[DD_ROP_SPACE]; // .
1381 lpDDHELCaps->dwVSBCaps = DDCAPS_BLT | // We do blitting
1382 DDCAPS_BLTCOLORFILL | // We do colorfills
1383 DDCAPS_COLORKEY | // We support Colorkeying
1384 DDCAPS_COLORKEYHWASSIST;
1385 lpDDHELCaps->dwVSBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1386 lpDDHELCaps->dwVSBFXCaps; // .
1387 lpDDHELCaps->dwVSBRops[DD_ROP_SPACE]; // .
1388 lpDDHELCaps->dwSSBCaps = DDCAPS_BLT | // We do blitting
1389 DDCAPS_BLTCOLORFILL | // We do colorfills
1390 DDCAPS_COLORKEY | // We support Colorkeying
1391 DDCAPS_COLORKEYHWASSIST;
1392 lpDDHELCaps->dwSSBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1393 lpDDHELCaps->dwSSBFXCaps; // .
1394 lpDDHELCaps->dwSSBRops[DD_ROP_SPACE]; // .
1395 // These are ony in >DX5
1396 if(dwSize>sizeof(DDCAPS_DX3))
1397 {
1398 lpDDHELCaps->dwSVBCaps2 = DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1399 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1400 DDCAPS2_WIDESURFACES; // Any size you want!
1401 lpDDHELCaps->dwNLVBCaps = DDCAPS_BLT | // We do blitting
1402 DDCAPS_BLTCOLORFILL | // We do colorfills
1403 DDCAPS_COLORKEY | // We support Colorkeying
1404 DDCAPS_COLORKEYHWASSIST;
1405 lpDDHELCaps->dwNLVBCaps2 = DDCAPS2_CANRENDERWINDOWED | // Better check for Voodoo ?!
1406 DDCAPS2_COPYFOURCC | // yepp memcpy will do this
1407 DDCAPS2_WIDESURFACES; // Any size you want!
1408 lpDDHELCaps->dwNLVBCKeyCaps = DDCKEYCAPS_SRCBLT; // Only source transparent blitting
1409 lpDDHELCaps->dwNLVBFXCaps; // .
1410 lpDDHELCaps->dwNLVBRops[DD_ROP_SPACE];// .
1411 }
1412
1413 }
1414
1415 return(DD_OK);
1416}
1417//******************************************************************************
1418//******************************************************************************
1419HRESULT WIN32API DrawGetDisplayMode(THIS This, LPDDSURFACEDESC lpDDSurfaceDesc)
1420{
1421 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1422
1423 dprintf(("DDRAW: GetDisplayMode %x %x", This, lpDDSurfaceDesc));
1424
1425 // Check Parameter
1426 if(NULL==lpDDSurfaceDesc)
1427 return(DDERR_INVALIDPARAMS);
1428
1429 if(sizeof(DDSURFACEDESC)!=lpDDSurfaceDesc->dwSize)
1430 return(DDERR_INVALIDPARAMS);
1431
1432 // We report back the DIVE caps. maybe we should set up a local DDSURFACEDESC
1433 // for the object so we can change the values when we switch modes (or say so)
1434 // as a program may use this function to check the values after a mode change
1435 // An other reason to to so is Voodoo supports maybe more functions
1436
1437 // Tell what we report
1438 lpDDSurfaceDesc->dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
1439 lpDDSurfaceDesc->dwHeight = me->dCaps.ulHorizontalResolution;
1440 lpDDSurfaceDesc->dwWidth = me->dCaps.ulVerticalResolution;
1441 // Set the PixelFormat
1442 lpDDSurfaceDesc->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
1443
1444 lpDDSurfaceDesc->ddpfPixelFormat.dwFourCC = me->dCaps.fccColorEncoding;
1445 lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = me->dCaps.ulDepth;
1446 lpDDSurfaceDesc->ddpfPixelFormat.dwRGBAlphaBitMask = 0; // No Alpha support
1447 switch(me->dCaps.ulDepth)
1448 {
1449 case 4:
1450 // Assume that no one will run OS/2 PM with less then 16 colors and try
1451 // to start a DirectX program ;)
1452 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED4;
1453 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0;
1454 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0;
1455 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0;
1456 break;
1457 case 8:
1458 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8 |
1459 DDPF_FOURCC;
1460 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0;
1461 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0;
1462 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0;
1463 break;
1464 case 15:
1465 case 16:
1466 lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount = 16; // No sure about 15Bit modes
1467 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1468 if (FOURCC_R555 == me->dCaps.fccColorEncoding)
1469 {
1470 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00007C00;
1471 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000003E0;
1472 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;
1473 }
1474 else
1475 {
1476 if(FOURCC_R565 == me->dCaps.fccColorEncoding)
1477 {
1478 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;
1479 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000007E0;
1480 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000001F;
1481 }
1482 else
1483 {
1484 // R664
1485 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x0000F800;
1486 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x000003F0;
1487 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x0000000F;
1488 }
1489 }
1490 break;
1491 case 24:
1492 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1493 if(FOURCC_RGB3 == me->dCaps.fccColorEncoding)
1494 {
1495 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
1496 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1497 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;
1498 }
1499 else
1500 {
1501 // BGR3
1502 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x000000FF;
1503 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1504 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x00FF0000;
1505 }
1506 break;
1507 case 32:
1508 lpDDSurfaceDesc->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1509 if(FOURCC_RGB4 == me->dCaps.fccColorEncoding)
1510 {
1511 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
1512 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1513 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x000000FF;
1514 }
1515 else
1516 {
1517 // BGR4
1518 lpDDSurfaceDesc->ddpfPixelFormat.dwRBitMask = 0x000000FF;
1519 lpDDSurfaceDesc->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1520 lpDDSurfaceDesc->ddpfPixelFormat.dwBBitMask = 0x00FF0000;
1521 }
1522 break;
1523 default:
1524 dprintf(("DDRAW: Unsupported mode\n"));
1525 return(DDERR_UNSUPPORTEDMODE);
1526 }
1527
1528 return(DD_OK);
1529}
1530//******************************************************************************
1531//******************************************************************************
1532HRESULT WIN32API DrawGetDisplayMode4(THIS This, LPDDSURFACEDESC2 lpDDSurfaceDesc2)
1533{
1534 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1535
1536 dprintf(("DDRAW: GetDisplayMode4 %x %x", This, lpDDSurfaceDesc2));
1537
1538 // Check Parameter
1539 if(NULL==lpDDSurfaceDesc2)
1540 return(DDERR_INVALIDPARAMS);
1541
1542 if(sizeof(DDSURFACEDESC)!=lpDDSurfaceDesc2->dwSize)
1543 return(DDERR_INVALIDPARAMS);
1544
1545 // We report back the DIVE caps. maybe we should set up a local DDSURFACEDESC
1546 // for the object so we can change the values when we switch modes (or say so)
1547 // as a program may use this function to check the values after a mode change
1548 // An other reason to to so is Voodoo supports maybe more functions
1549
1550 // Tell what we report
1551 lpDDSurfaceDesc2->dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
1552 lpDDSurfaceDesc2->dwHeight = me->dCaps.ulHorizontalResolution;
1553 lpDDSurfaceDesc2->dwWidth = me->dCaps.ulVerticalResolution;
1554 // Set the PixelFormat
1555 lpDDSurfaceDesc2->ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
1556
1557 lpDDSurfaceDesc2->ddpfPixelFormat.dwFourCC = me->dCaps.fccColorEncoding;
1558 lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBBitCount = me->dCaps.ulDepth;
1559 lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBAlphaBitMask = 0; // No Alpha support
1560 switch(me->dCaps.ulDepth)
1561 {
1562 case 4:
1563 // Assume that no one will run OS/2 PM with less then 16 colors and try
1564 // to start a DirectX program ;)
1565 lpDDSurfaceDesc2->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED4;
1566 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0;
1567 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0;
1568 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0;
1569 break;
1570 case 8:
1571 lpDDSurfaceDesc2->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8 |
1572 DDPF_FOURCC;
1573 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0;
1574 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0;
1575 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0;
1576 break;
1577 case 15:
1578 case 16:
1579 lpDDSurfaceDesc2->ddpfPixelFormat.dwRGBBitCount = 16; // No sure about 15Bit modes
1580 lpDDSurfaceDesc2->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1581 if (FOURCC_R555 == me->dCaps.ulDepth)
1582 {
1583 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x00007C00;
1584 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x000003E0;
1585 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x0000001F;
1586 }
1587 else
1588 {
1589 if(FOURCC_R565 == me->dCaps.fccColorEncoding)
1590 {
1591 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x0000F800;
1592 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x000007E0;
1593 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x0000001F;
1594 }
1595 else
1596 {
1597 // R664
1598 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x0000F800;
1599 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x000003F0;
1600 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x0000000F;
1601 }
1602 }
1603 break;
1604 case 24:
1605 lpDDSurfaceDesc2->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1606 if(FOURCC_RGB3 == me->dCaps.fccColorEncoding)
1607 {
1608 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
1609 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1610 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x000000FF;
1611 }
1612 else
1613 {
1614 // BGR3
1615 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x000000FF;
1616 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1617 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x00FF0000;
1618 }
1619 break;
1620 case 32:
1621 lpDDSurfaceDesc2->ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_FOURCC;
1622 if(FOURCC_RGB4 == me->dCaps.fccColorEncoding)
1623 {
1624 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x00FF0000;
1625 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1626 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x000000FF;
1627 }
1628 else
1629 {
1630 // BGR4
1631 lpDDSurfaceDesc2->ddpfPixelFormat.dwRBitMask = 0x000000FF;
1632 lpDDSurfaceDesc2->ddpfPixelFormat.dwGBitMask = 0x0000FF00;
1633 lpDDSurfaceDesc2->ddpfPixelFormat.dwBBitMask = 0x00FF0000;
1634 }
1635 break;
1636 default:
1637 dprintf(("DDRAW: Unsupported mode\n"));
1638 return(DDERR_UNSUPPORTEDMODE);
1639 }
1640
1641 return(DD_OK);
1642}
1643//******************************************************************************
1644//******************************************************************************
1645HRESULT WIN32API DrawGetFourCCCodes(THIS This, LPDWORD lpNumCodes, LPDWORD lpCodes)
1646{
1647// DWORD dwFCC[MAX_FOURCC_CODES] = {FOURCC_LUT8,FOURCC_R565,FOURCC_RGB3,FOURCC_YUY2};
1648 DWORD dwFCC[MAX_FOURCC_CODES] = {FOURCC_LUT8,FOURCC_R565,FOURCC_R555,FOURCC_RGB3};
1649
1650 dprintf(("DDRAW: GetFourCCCodes %x %x %x", This, lpNumCodes, lpCodes));
1651
1652 if(NULL==lpNumCodes)
1653 return(DDERR_INVALIDPARAMS);
1654
1655 if(NULL==lpCodes)
1656 {
1657 *lpNumCodes = MAX_FOURCC_CODES; // LUT8, R565, RGB3 are the FourCC we support for now
1658 }
1659 else
1660 {
1661 for(int i=0;(i<MAX_FOURCC_CODES)&&(i<*lpNumCodes);i++)
1662 {
1663 *lpCodes = dwFCC[i];
1664 lpCodes++;
1665 }
1666 *lpNumCodes = MAX_FOURCC_CODES;
1667 }
1668 return(DD_OK);
1669}
1670//******************************************************************************
1671//******************************************************************************
1672HRESULT WIN32API DrawGetGDISurface(THIS, LPDIRECTDRAWSURFACE FAR *)
1673{
1674 dprintf(("DDRAW: GetGDISurface NYI\n"));
1675
1676 return(DD_OK);
1677}
1678//******************************************************************************
1679//******************************************************************************
1680HRESULT WIN32API DrawGetGDISurface4(THIS, LPDIRECTDRAWSURFACE4 FAR *)
1681{
1682 dprintf(("DDRAW: GetGDISurface NYI\n"));
1683
1684 return(DD_OK);
1685}
1686//******************************************************************************
1687//******************************************************************************
1688HRESULT WIN32API DrawGetMonitorFrequency(THIS This, LPDWORD lpdwFreq)
1689{
1690 ULONG ulTime1, ulTime2;
1691 DWORD dwFlags = DDWAITVB_BLOCKBEGIN;
1692 dprintf(("DDRAW: GetMonitorFrequency\n"));
1693 if(NULL==lpdwFreq)
1694 return(DDERR_INVALIDPARAMS);
1695
1696
1697
1698 if(DD_OK==DrawWaitForVerticalBlank(This, dwFlags, 0))
1699 {
1700 ulTime1 = GetTickCount();
1701 // Timer has an accuracy of 4 ms so call it al least 4 times
1702 DrawWaitForVerticalBlank(This, dwFlags, 0);
1703 DrawWaitForVerticalBlank(This, dwFlags, 0);
1704 DrawWaitForVerticalBlank(This, dwFlags, 0);
1705 DrawWaitForVerticalBlank(This, dwFlags, 0);
1706 ulTime2 = GetTickCount();
1707 ulTime2 -= ulTime1;
1708 if(ulTime2) // paranoid check to avoid DIV0
1709 *lpdwFreq = 4000 / ulTime2;
1710 else
1711 *lpdwFreq = 70;
1712 }
1713 else
1714 {
1715 // Assume 70 Hz maybe better return DDERR_UNSUPPORTED if this function isn't mandatory
1716 *lpdwFreq = 70;
1717 }
1718
1719
1720
1721 return(DD_OK);
1722}
1723//******************************************************************************
1724//******************************************************************************
1725HRESULT WIN32API DrawGetScanLine(THIS, LPDWORD lpdwLine)
1726{
1727// BOOL bVertBlank;
1728 dprintf(("DDRAW: GetScanLine\n"));
1729 // ToDO find a way to get this position, so for now simply return DDERR_UNSUPPORTED
1730 // as we indicated in DDCAPS we don't support this.
1731
1732 return(DDERR_UNSUPPORTED);
1733
1734 //the following code could be used if we implement this
1735 /*
1736 if(NULL==lpdwLine)
1737 return(DDERR_INVALIDPARAMS);
1738 DrawGetVertcalBlackStatus(This,&bVertBlank);
1739 if(bVertBlank)
1740 return (DDERR_VERTICALBLANKINPROGRESS);
1741 *lpdwLine = GetLine(); // GetLine would be the function which gets us the line
1742 return(DD_OK);
1743 */
1744}
1745//******************************************************************************
1746//******************************************************************************
1747HRESULT WIN32API DrawGetVerticalBlankStatus(THIS , LPBOOL lpbIsInVB)
1748{
1749// int rc;
1750 dprintf(("DDRAW: GetVerticalBlankStatus\n"));
1751 if(NULL==lpbIsInVB)
1752 return(DDERR_INVALIDPARAMS);
1753
1754 #if 0
1755 rc = io_init1();
1756
1757
1758 if(0==rc) // try to get IOPL for the thread
1759 {
1760 *lpbIsInVB = (c_inb1(0x3da)&0x08)!=0;
1761
1762 io_exit1(); // reset IOPL
1763
1764 return(DD_OK);
1765 }
1766 #else
1767 *lpbIsInVB = ! (*lpbIsInVB);
1768 #endif
1769 return(DDERR_UNSUPPORTED);
1770}
1771//******************************************************************************
1772//******************************************************************************
1773HRESULT WIN32API DrawInitialize(THIS, GUID FAR *)
1774{
1775 dprintf(("DDRAW: Initialize\n"));
1776
1777 return(DD_OK);
1778}
1779//******************************************************************************
1780//******************************************************************************
1781HRESULT WIN32API DrawRestoreDisplayMode(THIS This)
1782{
1783 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1784
1785 dprintf(("DDRAW: RestoreDisplayMode"));
1786
1787 // FSDDRAW additions
1788 ULONG ulModeInd;
1789 /* restore previous screen mode */
1790 if ((bUseFSDD) && (me->bInFullScreen))
1791 {
1792 SetSVGAMode(me->oldwidth, me->oldheight, me->oldbpp, 0xFF, &ulModeInd, NULL);
1793 RestorePM();
1794 /* restore DIVE caps entries */
1795 me->dCaps.ulScanLineBytes = me->oldscanlines;
1796 me->dCaps.ulHorizontalResolution = me->oldwidth;
1797 me->dCaps.ulVerticalResolution = me->oldheight;
1798 me->dCaps.ulDepth = me->oldbpp;
1799 }
1800
1801 return(DD_OK);
1802}
1803//******************************************************************************
1804//******************************************************************************
1805HRESULT WIN32API DrawSetCooperativeLevel(THIS This, HWND hwndClient, DWORD dwFlags)
1806{
1807 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1808
1809 dprintf(("DDRAW: SetCooperativeLevel: hwnd %X, Flags %X\n", hwndClient, dwFlags));
1810 me->dwCoopMode = dwFlags;
1811 if(!(DDSCL_NORMAL & dwFlags))
1812 {
1813 // client window req. for all none DDSCL_NORMAL modes
1814 if(NULL==hwndClient)
1815 return(DDERR_INVALIDPARAMS);
1816 }
1817 me->hwndClient = hwndClient;
1818 #if 0
1819 OS2DDSubclassWindow(hwndClient);
1820 #endif
1821 return(DD_OK);
1822}
1823//******************************************************************************
1824//Backwards compatibility, what's that??
1825//******************************************************************************
1826HRESULT WIN32API DrawSetDisplayMode2(THIS This, DWORD dwWidth, DWORD dwHeight,
1827 DWORD dwBPP, DWORD dwRefreshRate,
1828 DWORD dwFlags)
1829{
1830 ULONG rc;
1831 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1832 SETUP_BLITTER sBlt;
1833
1834 dprintf(("DDRAW: SetDisplayMode2 to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP));
1835
1836 me->screenwidth = dwWidth;
1837 me->screenheight = dwHeight;
1838 me->screenbpp = dwBPP;
1839
1840 if(me->dwCoopMode & DDSCL_FULLSCREEN)
1841 {
1842 // FSDDRAW additions
1843 ULONG ulModeInd;
1844
1845 SetWindowPos(me->hwndClient, HWND_TOP,0,0,dwWidth,dwHeight,0);
1846 SetCursorPos(dwWidth / 2, dwHeight / 2);
1847
1848 if ((bUseFSDD) && (ModeInSVGAModeTable(dwWidth,dwHeight,dwBPP)))
1849 {
1850 KillPM();
1851
1852 rc = SetSVGAMode(dwWidth, dwHeight, dwBPP, 0xFF, &ulModeInd, NULL);
1853
1854 if (!rc) // When mode switched successfully
1855 {
1856 /* save old screen values */
1857 me->bInFullScreen=TRUE;
1858 me->oldwidth = me->dCaps.ulHorizontalResolution;
1859 me->oldheight = me->dCaps.ulVerticalResolution;
1860 me->oldscanlines = me->dCaps.ulScanLineBytes;
1861 me->oldbpp = me->dCaps.ulDepth;
1862
1863 /* now 'fix' some DIVE caps entries */
1864 me->dCaps.ulScanLineBytes = dwWidth * (dwBPP >> 3); /* FIX: use real value */
1865 me->dCaps.ulHorizontalResolution = dwWidth;
1866 me->dCaps.ulVerticalResolution = dwHeight;
1867 me->dCaps.ulDepth = dwBPP;
1868 }
1869 else
1870 // Display must be return to PM Session
1871 RestorePM();
1872 }
1873 }
1874
1875 memset(&sBlt,0,sizeof(sBlt));
1876 sBlt.ulStructLen = sizeof(sBlt);
1877 sBlt.fccSrcColorFormat = FOURCC_SCRN;
1878 sBlt.ulSrcWidth = dwWidth;
1879 sBlt.ulSrcHeight = dwHeight;
1880 sBlt.ulSrcPosX = 0;
1881 sBlt.ulSrcPosY = 0;
1882 sBlt.fccDstColorFormat = FOURCC_SCRN;
1883 sBlt.ulDstWidth = dwWidth;
1884 sBlt.ulDstHeight = dwHeight;
1885 sBlt.lDstPosX = 0;
1886 sBlt.lDstPosY = 0;
1887 sBlt.lScreenPosX = 0;
1888 sBlt.lScreenPosY = me->dCaps.ulVerticalResolution-dwHeight;
1889 sBlt.ulNumDstRects = DIVE_FULLY_VISIBLE;
1890
1891 rc = DiveSetupBlitter( me->hDive,
1892 &sBlt);
1893 dprintf((" DiveSetupBlitter rc=%d",rc));
1894
1895 return(DD_OK);
1896}
1897//******************************************************************************
1898//******************************************************************************
1899HRESULT WIN32API DrawSetDisplayMode(THIS This, DWORD dwWidth, DWORD dwHeight,
1900 DWORD dwBPP)
1901{
1902 ULONG rc;
1903 OS2IDirectDraw *me = (OS2IDirectDraw *)This;
1904 SETUP_BLITTER sBlt;
1905
1906 dprintf(("DDRAW: SetDisplayMode to %dx%d with %d bits colors\n", dwWidth, dwHeight, dwBPP));
1907
1908 me->screenwidth = dwWidth;
1909 me->screenheight = dwHeight;
1910 me->screenbpp = dwBPP;
1911
1912 if(me->dwCoopMode & DDSCL_FULLSCREEN)
1913 {
1914 // FSDDRAW additions
1915 ULONG ulModeInd;
1916
1917 SetWindowPos(me->hwndClient, HWND_TOP,0,0,dwWidth,dwHeight,0);
1918 SetCursorPos(dwWidth / 2, dwHeight / 2);
1919
1920 if ((bUseFSDD) && (ModeInSVGAModeTable(dwWidth,dwHeight,dwBPP)))
1921 {
1922 KillPM();
1923
1924 rc = SetSVGAMode(dwWidth, dwHeight, dwBPP, 0xFF, &ulModeInd, NULL);
1925
1926 if (!rc) // When mode switched successfully
1927 {
1928 /* save old screen values */
1929 me->bInFullScreen=TRUE;
1930 me->oldwidth = me->dCaps.ulHorizontalResolution;
1931 me->oldheight = me->dCaps.ulVerticalResolution;
1932 me->oldscanlines = me->dCaps.ulScanLineBytes;
1933 me->oldbpp = me->dCaps.ulDepth;
1934
1935 /* now 'fix' some DIVE caps entries */
1936 me->dCaps.ulScanLineBytes = dwWidth * (dwBPP >> 3); /* FIX: use real value */
1937 me->dCaps.ulHorizontalResolution = dwWidth;
1938 me->dCaps.ulVerticalResolution = dwHeight;
1939 me->dCaps.ulDepth = dwBPP;
1940 }
1941 else
1942 // Display must be return to PM Session
1943 RestorePM();
1944 }
1945 }
1946
1947 memset(&sBlt,0,sizeof(sBlt));
1948 sBlt.ulStructLen = sizeof(sBlt);
1949 sBlt.fccSrcColorFormat = FOURCC_SCRN;
1950 sBlt.ulSrcWidth = dwWidth;
1951 sBlt.ulSrcHeight = dwHeight;
1952 sBlt.ulSrcPosX = 0;
1953 sBlt.ulSrcPosY = 0;
1954 sBlt.fccDstColorFormat = FOURCC_SCRN;
1955 sBlt.ulDstWidth = dwWidth;
1956 sBlt.ulDstHeight = dwHeight;
1957 sBlt.lDstPosX = 0;
1958 sBlt.lDstPosY = 0;
1959 sBlt.lScreenPosX = 0;
1960 sBlt.lScreenPosY = me->dCaps.ulVerticalResolution-dwHeight;
1961 sBlt.ulNumDstRects = DIVE_FULLY_VISIBLE;
1962
1963 rc = DiveSetupBlitter( me->hDive,
1964 &sBlt);
1965 dprintf((" DiveSetupBlitter rc=%d",rc));
1966
1967 return(DD_OK);
1968}
1969//******************************************************************************
1970//******************************************************************************
1971HRESULT WIN32API DrawWaitForVerticalBlank(THIS, DWORD dwFlags, HANDLE hEvent)
1972{
1973// HRESULT rc;
1974// int rci;
1975// USHORT sel;
1976 dprintf(("DDRAW: WaitForVerticalBlank\n"));
1977
1978 if(DDWAITVB_BLOCKBEGINEVENT == dwFlags) // This parameter isn't support in DX
1979 return (DDERR_UNSUPPORTED);
1980
1981 return DD_OK;
1982
1983#if 0
1984 rci = InitIO();
1985
1986 if(rci) // try to get IOPL for the thread
1987 {
1988 dprintf(("DDRAW: No IOPL\n"));
1989 return (DDERR_UNSUPPORTED); // we failed so return error that we don't support this
1990 }
1991 // AT this point we should have IOPL so lets use it!
1992 dprintf(("DDRAW: IOPL 3!\n"));
1993
1994 rc = DDERR_INVALIDPARAMS; // set returnvalue to fail
1995
1996 if(DDWAITVB_BLOCKBEGIN == dwFlags)
1997 {
1998 dprintf(("DDRAW: BLOCKBEGIN\n"));
1999
2000 while ((c_inb1(0x3da)&0x08)!=0); // Wait for end of vert. retrace if one is running
2001 while ((c_inb1(0x3da)&0x08)==0); // Wait for new start of retrace
2002 rc = DD_OK;
2003 }
2004
2005 if(DDWAITVB_BLOCKEND == dwFlags)
2006 {
2007 dprintf(("DDRAW: BLOCKEND\n"));
2008 rc = DD_OK;
2009 if((c_inb1(0x3da)&0x08)!=0) // Are we in a vert. retrace
2010 {
2011 while ((c_inb1(0x3da)&0x08)!=0); // Wait for end of retrace
2012 }
2013 else
2014 {
2015 while ((c_inb1(0x3da)&0x08)==0); // Wait for new start of retrace
2016 while ((c_inb1(0x3da)&0x08)!=0); // Wait for end of vert. retrace
2017 }
2018
2019 }
2020
2021
2022 // io_exit1();
2023
2024
2025 return (rc);
2026#endif
2027}
2028
2029//******************************************************************************
2030//*** Added in the v2 interface ***
2031//******************************************************************************
2032HRESULT WIN32API DrawGetAvailableVidMem(THIS, LPDDSCAPS lpDDSCaps,
2033 LPDWORD lpdwTotal, LPDWORD lpdwFree)
2034{
2035 dprintf(("DDRAW: GetAvailableVidMem\n"));
2036
2037 // Check parameters
2038 if(NULL==lpDDSCaps)
2039 return(DDERR_INVALIDPARAMS);
2040
2041 if((NULL==lpdwTotal)&&(NULL==lpdwFree))
2042 return(DDERR_INVALIDPARAMS);
2043
2044 if(NULL!=lpdwTotal)
2045 *lpdwTotal = 2048 *1024;
2046
2047 if(NULL!=lpdwFree)
2048 *lpdwFree = 2048 *1024;
2049
2050 return(DD_OK);
2051}
2052//******************************************************************************
2053//
2054//******************************************************************************
2055HRESULT WIN32API DrawGetAvailableVidMem4(THIS, LPDDSCAPS2 lpDDSCaps2,
2056 LPDWORD lpdwTotal, LPDWORD lpdwFree)
2057{
2058 dprintf(("DDRAW: GetAvailableVidMem\n"));
2059
2060 // Check parameters
2061 if(NULL==lpDDSCaps2)
2062 return(DDERR_INVALIDPARAMS);
2063
2064 if((NULL==lpdwTotal)&&(NULL==lpdwFree))
2065 return(DDERR_INVALIDPARAMS);
2066
2067 if(NULL!=lpdwTotal)
2068 *lpdwTotal = 2048 *1024;
2069
2070 if(NULL!=lpdwFree)
2071 *lpdwFree = 2048 *1024;
2072
2073 return(DD_OK);
2074}
2075//******************************************************************************
2076//*** Added in the v4 interface ***
2077//******************************************************************************
2078HRESULT WIN32API DrawGetSurfaceFromDC(THIS, HDC hdc, LPDIRECTDRAWSURFACE4 *)
2079{
2080 dprintf(("DDRAW: GetSurfaceFromDC NYI\n"));
2081
2082 return(DD_OK);
2083}
2084//******************************************************************************
2085//******************************************************************************
2086HRESULT WIN32API DrawRestoreAllSurfaces(THIS)
2087{
2088 dprintf(("DDRAW: RestoreAllSurfaces\n"));
2089
2090 return(DD_OK);
2091}
2092//******************************************************************************
2093//******************************************************************************
2094HRESULT WIN32API DrawTestCooperativeLevel(THIS)
2095{
2096 dprintf(("DDRAW: TestCooperativeLevel\n"));
2097
2098 return(DD_OK);
2099}
2100//******************************************************************************
2101//******************************************************************************
2102HRESULT WIN32API DrawGetDeviceIdentifier( THIS, LPDDDEVICEIDENTIFIER lpdddi,
2103 DWORD dwFlags)
2104{
2105 dprintf(("DDRAW: GetDeviceIdentifier Flags = %d\n",dwFlags));
2106 if(NULL==lpdddi)
2107 return DDERR_INVALIDPARAMS;
2108
2109
2110
2111 memset( lpdddi,
2112 0,
2113 sizeof(DDDEVICEIDENTIFIER));
2114 // ToDo: Cretae a GUID and put some better data inside
2115 strcpy( lpdddi->szDriver,
2116 "OS/2 DIVE Driver");
2117 strcpy( lpdddi->szDescription,
2118 "ODIN DD Emulation Driver");
2119
2120
2121
2122 return(DD_OK);
2123}
2124//******************************************************************************
2125//******************************************************************************
2126VOID OS2IDirectDraw::SwitchDisplay(HWND hwnd)
2127{
2128 DWORD dwVType, dwVSize;
2129 HKEY hkDirectDraw2;
2130
2131
2132
2133 if (bScale)
2134 {
2135 if (ERROR_SUCCESS==RegOpenKeyA(HKEY_LOCAL_MACHINE,KEY_DIRECT2DRAW,&hkDirectDraw2))
2136 {
2137 dwVSize = 4;
2138 dwVType = REG_DWORD;
2139 if (ERROR_SUCCESS!=RegQueryValueExA( hkDirectDraw2, "Fullscreen", NULL, &dwVType,
2140 (LPBYTE)&bScale, &dwVSize))
2141 bScale = FALSE;
2142 }
2143 else
2144 bScale = FALSE;
2145 }
2146
2147
2148}
2149//******************************************************************************
2150//******************************************************************************
2151
Note: See TracBrowser for help on using the repository browser.