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

Last change on this file since 6950 was 6950, checked in by sandervl, 24 years ago

updates for stretch blitting

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