source: trunk/src/ddraw/ddraw2d.cpp@ 21479

Last change on this file since 21479 was 21479, checked in by dmik, 15 years ago

Get rid of dd_obj_base.h which duplicates obj_base.h creating unnecessary mess (symbol/define duplication) and conflicts when both the DDarw and other COM-related headers are included.

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