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

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

Added ODIn lic header with ID to all files where missing

Cleaned up Surface handling by movefing colorfill and
colorconversion into own files and use functionpointers
setup during creation.

updated makefile to add files

removed inhertiance from IBASE in DDrectangle class

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