source: trunk/src/ddraw/new/OS2DDRAW.CPP@ 3345

Last change on this file since 3345 was 3345, checked in by mike, 25 years ago

Experimental fullscreen DDraw

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