source: trunk/src/ddraw/ddraw2d.cpp

Last change on this file was 21916, checked in by dmik, 14 years ago

Merge branch gcc-kmk to trunk.

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