2 /* DirectDraw Base Functions
4 * Copyright 1997-1999 Marcus Meissner
5 * Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
6 * Copyright 2000 TransGaming Technologies Inc.
17 #include "wine/exception.h"
18 #include "ddraw_private.h"
20 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(ddraw
);
24 /******************************************************************************
25 * debug output functions
33 #define FE(x) { x, #x }
39 void (*func
)(const void *);
43 #define ME(x,f,e) { x, #x, (void (*)(const void *))(f), offsetof(STRUCT, e) }
45 static void DDRAW_dump_flags(DWORD flags
, const flag_info
* names
,
50 for (i
=0; i
< num_names
; i
++)
51 if (names
[i
].val
& flags
)
52 DPRINTF("%s ", names
[i
].name
);
57 static void DDRAW_dump_members(DWORD flags
, const void* data
,
58 const member_info
* mems
, size_t num_mems
)
62 for (i
=0; i
< num_mems
; i
++)
64 if (mems
[i
].val
& flags
)
66 DPRINTF(" - %s : ", mems
[i
].name
);
67 mems
[i
].func((const char *)data
+ mems
[i
].offset
);
73 void DDRAW_dump_DDBLTFX(DWORD flagmask
)
75 static const flag_info flags
[] =
77 FE(DDBLTFX_ARITHSTRETCHY
),
78 FE(DDBLTFX_MIRRORLEFTRIGHT
),
79 FE(DDBLTFX_MIRRORUPDOWN
),
80 FE(DDBLTFX_NOTEARING
),
81 FE(DDBLTFX_ROTATE180
),
82 FE(DDBLTFX_ROTATE270
),
84 FE(DDBLTFX_ZBUFFERRANGE
),
85 FE(DDBLTFX_ZBUFFERBASEDEST
)
88 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
91 void DDRAW_dump_DDBLTFAST(DWORD flagmask
)
93 static const flag_info flags
[] =
95 FE(DDBLTFAST_NOCOLORKEY
),
96 FE(DDBLTFAST_SRCCOLORKEY
),
97 FE(DDBLTFAST_DESTCOLORKEY
),
101 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
104 void DDRAW_dump_DDBLT(DWORD flagmask
)
106 static const flag_info flags
[] =
109 FE(DDBLT_ALPHADESTCONSTOVERRIDE
),
110 FE(DDBLT_ALPHADESTNEG
),
111 FE(DDBLT_ALPHADESTSURFACEOVERRIDE
),
112 FE(DDBLT_ALPHAEDGEBLEND
),
114 FE(DDBLT_ALPHASRCCONSTOVERRIDE
),
115 FE(DDBLT_ALPHASRCNEG
),
116 FE(DDBLT_ALPHASRCSURFACEOVERRIDE
),
122 FE(DDBLT_KEYDESTOVERRIDE
),
124 FE(DDBLT_KEYSRCOVERRIDE
),
126 FE(DDBLT_ROTATIONANGLE
),
128 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE
),
129 FE(DDBLT_ZBUFFERDESTOVERRIDE
),
130 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE
),
131 FE(DDBLT_ZBUFFERSRCOVERRIDE
),
136 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
139 void DDRAW_dump_DDSCAPS(const DDSCAPS2
*in
)
141 static const flag_info flags
[] =
143 FE(DDSCAPS_RESERVED1
),
145 FE(DDSCAPS_BACKBUFFER
),
148 FE(DDSCAPS_FRONTBUFFER
),
149 FE(DDSCAPS_OFFSCREENPLAIN
),
152 FE(DDSCAPS_PRIMARYSURFACE
),
153 FE(DDSCAPS_PRIMARYSURFACELEFT
),
154 FE(DDSCAPS_SYSTEMMEMORY
),
156 FE(DDSCAPS_3DDEVICE
),
157 FE(DDSCAPS_VIDEOMEMORY
),
159 FE(DDSCAPS_WRITEONLY
),
162 FE(DDSCAPS_LIVEVIDEO
),
166 FE(DDSCAPS_RESERVED2
),
167 FE(DDSCAPS_ALLOCONLOAD
),
168 FE(DDSCAPS_VIDEOPORT
),
169 FE(DDSCAPS_LOCALVIDMEM
),
170 FE(DDSCAPS_NONLOCALVIDMEM
),
171 FE(DDSCAPS_STANDARDVGAMODE
),
172 FE(DDSCAPS_OPTIMIZED
)
175 DDRAW_dump_flags(in
->dwCaps
, flags
, sizeof(flags
)/sizeof(flags
[0]));
178 void DDRAW_dump_pixelformat_flag(DWORD flagmask
)
180 static const flag_info flags
[] =
182 FE(DDPF_ALPHAPIXELS
),
185 FE(DDPF_PALETTEINDEXED4
),
186 FE(DDPF_PALETTEINDEXEDTO8
),
187 FE(DDPF_PALETTEINDEXED8
),
193 FE(DDPF_PALETTEINDEXED1
),
194 FE(DDPF_PALETTEINDEXED2
),
198 DDRAW_dump_flags(flagmask
, flags
, sizeof(flags
)/sizeof(flags
[0]));
201 void DDRAW_dump_paletteformat(DWORD dwFlags
)
203 static const flag_info flags
[] =
206 FE(DDPCAPS_8BITENTRIES
),
208 FE(DDPCAPS_INITIALIZE
),
209 FE(DDPCAPS_PRIMARYSURFACE
),
210 FE(DDPCAPS_PRIMARYSURFACELEFT
),
211 FE(DDPCAPS_ALLOW256
),
218 DDRAW_dump_flags(dwFlags
, flags
, sizeof(flags
)/sizeof(flags
[0]));
221 void DDRAW_dump_pixelformat(const DDPIXELFORMAT
*pf
) {
223 DDRAW_dump_pixelformat_flag(pf
->dwFlags
);
224 if (pf
->dwFlags
& DDPF_FOURCC
) {
225 DPRINTF(", dwFourCC code '%c%c%c%c' (0x%08lx) - %ld bits per pixel",
226 (unsigned char)( pf
->dwFourCC
&0xff),
227 (unsigned char)((pf
->dwFourCC
>> 8)&0xff),
228 (unsigned char)((pf
->dwFourCC
>>16)&0xff),
229 (unsigned char)((pf
->dwFourCC
>>24)&0xff),
234 if (pf
->dwFlags
& DDPF_RGB
) {
236 DPRINTF(", RGB bits: %ld, ", pf
->u1
.dwRGBBitCount
);
237 switch (pf
->u1
.dwRGBBitCount
) {
238 case 4: cmd
= "%1lx"; break;
239 case 8: cmd
= "%02lx"; break;
240 case 16: cmd
= "%04lx"; break;
241 case 24: cmd
= "%06lx"; break;
242 case 32: cmd
= "%08lx"; break;
243 default: ERR("Unexpected bit depth !\n"); cmd
= "%d"; break;
245 DPRINTF(" R "); DPRINTF(cmd
, pf
->u2
.dwRBitMask
);
246 DPRINTF(" G "); DPRINTF(cmd
, pf
->u3
.dwGBitMask
);
247 DPRINTF(" B "); DPRINTF(cmd
, pf
->u4
.dwBBitMask
);
248 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
) {
249 DPRINTF(" A "); DPRINTF(cmd
, pf
->u5
.dwRGBAlphaBitMask
);
251 if (pf
->dwFlags
& DDPF_ZPIXELS
) {
252 DPRINTF(" Z "); DPRINTF(cmd
, pf
->u5
.dwRGBZBitMask
);
255 if (pf
->dwFlags
& DDPF_ZBUFFER
) {
256 DPRINTF(", Z bits : %ld", pf
->u1
.dwZBufferBitDepth
);
258 if (pf
->dwFlags
& DDPF_ALPHA
) {
259 DPRINTF(", Alpha bits : %ld", pf
->u1
.dwAlphaBitDepth
);
264 void DDRAW_dump_colorkeyflag(DWORD ck
)
266 static const flag_info flags
[] =
268 FE(DDCKEY_COLORSPACE
),
270 FE(DDCKEY_DESTOVERLAY
),
272 FE(DDCKEY_SRCOVERLAY
)
275 DDRAW_dump_flags(ck
, flags
, sizeof(flags
)/sizeof(flags
[0]));
278 static void DDRAW_dump_DWORD(const void *in
) {
279 DPRINTF("%ld", *((const DWORD
*) in
));
281 static void DDRAW_dump_PTR(const void *in
) {
282 DPRINTF("%p", *((const void **) in
));
284 void DDRAW_dump_DDCOLORKEY(const DDCOLORKEY
*ddck
) {
285 DPRINTF(" Low : %ld - High : %ld", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
288 void DDRAW_dump_surface_desc(const DDSURFACEDESC2
*lpddsd
)
290 #define STRUCT DDSURFACEDESC2
291 static const member_info members
[] =
293 ME(DDSD_CAPS
, DDRAW_dump_DDSCAPS
, ddsCaps
),
294 ME(DDSD_HEIGHT
, DDRAW_dump_DWORD
, dwHeight
),
295 ME(DDSD_WIDTH
, DDRAW_dump_DWORD
, dwWidth
),
296 ME(DDSD_PITCH
, DDRAW_dump_DWORD
, u1
.lPitch
),
297 ME(DDSD_LINEARSIZE
, DDRAW_dump_DWORD
, u1
.dwLinearSize
),
298 ME(DDSD_BACKBUFFERCOUNT
, DDRAW_dump_DWORD
, dwBackBufferCount
),
299 ME(DDSD_MIPMAPCOUNT
, DDRAW_dump_DWORD
, u2
.dwMipMapCount
),
300 ME(DDSD_REFRESHRATE
, DDRAW_dump_DWORD
, u2
.dwRefreshRate
),
301 ME(DDSD_ALPHABITDEPTH
, DDRAW_dump_DWORD
, dwAlphaBitDepth
),
302 ME(DDSD_LPSURFACE
, DDRAW_dump_PTR
, lpSurface
),
303 ME(DDSD_CKDESTOVERLAY
, DDRAW_dump_DDCOLORKEY
, u3
.ddckCKDestOverlay
),
304 ME(DDSD_CKDESTBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKDestBlt
),
305 ME(DDSD_CKSRCOVERLAY
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcOverlay
),
306 ME(DDSD_CKSRCBLT
, DDRAW_dump_DDCOLORKEY
, ddckCKSrcBlt
),
307 ME(DDSD_PIXELFORMAT
, DDRAW_dump_pixelformat
, u4
.ddpfPixelFormat
)
310 DDRAW_dump_members(lpddsd
->dwFlags
, lpddsd
, members
,
311 sizeof(members
)/sizeof(members
[0]));
314 void DDRAW_dump_cooperativelevel(DWORD cooplevel
)
316 static const flag_info flags
[] =
318 FE(DDSCL_FULLSCREEN
),
319 FE(DDSCL_ALLOWREBOOT
),
320 FE(DDSCL_NOWINDOWCHANGES
),
322 FE(DDSCL_ALLOWMODEX
),
324 FE(DDSCL_SETFOCUSWINDOW
),
325 FE(DDSCL_SETDEVICEWINDOW
),
326 FE(DDSCL_CREATEDEVICEWINDOW
)
332 DDRAW_dump_flags(cooplevel
, flags
, sizeof(flags
)/sizeof(flags
[0]));