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

Last change on this file since 2638 was 2638, checked in by hugh, 26 years ago

Bugfixes at many places

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