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

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

Fixes to let RA run

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