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

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

ddraw: Don't define CINTERFACE twice.

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