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

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

Fixed bug in pageflipping, constructor colorfill

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