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

Last change on this file since 3595 was 3595, checked in by sandervl, 25 years ago

HEL GetDevCaps fix

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