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

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

misc fixes for dxview + powerdvd

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