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

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

Cleanup

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