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

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

Fixed Bug in colorconversion, didn't iterate
ddex1.exe from the DX samples now works,
but bitmap is still mirrored up/down

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