2 /* DirectDraw Base Functions
4 * Copyright 1997-1999 Marcus Meissner
5 * Copyright 1998 Lionel Ulmer (most of Direct3D stuff)
22 #include "wine/exception.h"
25 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(ddraw
);
33 /******************************************************************************
34 * debug output functions
36 void _dump_DDBLTFX(DWORD flagmask
) {
42 #define FE(x) { x, #x},
43 FE(DDBLTFX_ARITHSTRETCHY
)
44 FE(DDBLTFX_MIRRORLEFTRIGHT
)
45 FE(DDBLTFX_MIRRORUPDOWN
)
50 FE(DDBLTFX_ZBUFFERRANGE
)
51 FE(DDBLTFX_ZBUFFERBASEDEST
)
54 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
55 if (flags
[i
].mask
& flagmask
)
56 DPRINTF("%s ",flags
[i
].name
);
60 void _dump_DDBLTFAST(DWORD flagmask
) {
66 #define FE(x) { x, #x},
67 FE(DDBLTFAST_NOCOLORKEY
)
68 FE(DDBLTFAST_SRCCOLORKEY
)
69 FE(DDBLTFAST_DESTCOLORKEY
)
73 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
74 if (flags
[i
].mask
& flagmask
)
75 DPRINTF("%s ",flags
[i
].name
);
79 void _dump_DDBLT(DWORD flagmask
) {
85 #define FE(x) { x, #x},
87 FE(DDBLT_ALPHADESTCONSTOVERRIDE
)
88 FE(DDBLT_ALPHADESTNEG
)
89 FE(DDBLT_ALPHADESTSURFACEOVERRIDE
)
90 FE(DDBLT_ALPHAEDGEBLEND
)
92 FE(DDBLT_ALPHASRCCONSTOVERRIDE
)
94 FE(DDBLT_ALPHASRCSURFACEOVERRIDE
)
100 FE(DDBLT_KEYDESTOVERRIDE
)
102 FE(DDBLT_KEYSRCOVERRIDE
)
104 FE(DDBLT_ROTATIONANGLE
)
106 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE
)
107 FE(DDBLT_ZBUFFERDESTOVERRIDE
)
108 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE
)
109 FE(DDBLT_ZBUFFERSRCOVERRIDE
)
114 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
115 if (flags
[i
].mask
& flagmask
)
116 DPRINTF("%s ",flags
[i
].name
);
120 void _dump_DDSCAPS(void *in
) {
126 #define FE(x) { x, #x},
127 FE(DDSCAPS_RESERVED1
)
129 FE(DDSCAPS_BACKBUFFER
)
132 FE(DDSCAPS_FRONTBUFFER
)
133 FE(DDSCAPS_OFFSCREENPLAIN
)
136 FE(DDSCAPS_PRIMARYSURFACE
)
137 FE(DDSCAPS_PRIMARYSURFACELEFT
)
138 FE(DDSCAPS_SYSTEMMEMORY
)
141 FE(DDSCAPS_VIDEOMEMORY
)
143 FE(DDSCAPS_WRITEONLY
)
146 FE(DDSCAPS_LIVEVIDEO
)
150 FE(DDSCAPS_RESERVED2
)
151 FE(DDSCAPS_ALLOCONLOAD
)
152 FE(DDSCAPS_VIDEOPORT
)
153 FE(DDSCAPS_LOCALVIDMEM
)
154 FE(DDSCAPS_NONLOCALVIDMEM
)
155 FE(DDSCAPS_STANDARDVGAMODE
)
156 FE(DDSCAPS_OPTIMIZED
)
159 DWORD flagmask
= *((DWORD
*) in
);
160 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
161 if (flags
[i
].mask
& flagmask
)
162 DPRINTF("%s ",flags
[i
].name
);
165 void _dump_pixelformat_flag(DWORD flagmask
) {
171 #define FE(x) { x, #x},
175 FE(DDPF_PALETTEINDEXED4
)
176 FE(DDPF_PALETTEINDEXEDTO8
)
177 FE(DDPF_PALETTEINDEXED8
)
183 FE(DDPF_PALETTEINDEXED1
)
184 FE(DDPF_PALETTEINDEXED2
)
188 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
189 if (flags
[i
].mask
& flagmask
)
190 DPRINTF("%s ",flags
[i
].name
);
193 void _dump_paletteformat(DWORD dwFlags
) {
199 #define FE(x) { x, #x},
201 FE(DDPCAPS_8BITENTRIES
)
203 FE(DDPCAPS_INITIALIZE
)
204 FE(DDPCAPS_PRIMARYSURFACE
)
205 FE(DDPCAPS_PRIMARYSURFACELEFT
)
213 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
214 if (flags
[i
].mask
& dwFlags
)
215 DPRINTF("%s ",flags
[i
].name
);
219 void _dump_pixelformat(void *in
) {
220 LPDDPIXELFORMAT pf
= (LPDDPIXELFORMAT
) in
;
223 _dump_pixelformat_flag(pf
->dwFlags
);
224 if (pf
->dwFlags
& DDPF_FOURCC
)
225 DPRINTF(", dwFourCC : %ld", pf
->dwFourCC
);
226 if (pf
->dwFlags
& DDPF_RGB
) {
228 DPRINTF(", RGB bits: %ld, ", pf
->u
.dwRGBBitCount
);
229 switch (pf
->u
.dwRGBBitCount
) {
230 case 4: cmd
= "%1lx"; break;
231 case 8: cmd
= "%02lx"; break;
232 case 16: cmd
= "%04lx"; break;
233 case 24: cmd
= "%06lx"; break;
234 case 32: cmd
= "%08lx"; break;
235 default: ERR("Unexpected bit depth !\n"); cmd
= "%d"; break;
237 DPRINTF(" R "); DPRINTF(cmd
, pf
->u1
.dwRBitMask
);
238 DPRINTF(" G "); DPRINTF(cmd
, pf
->u2
.dwGBitMask
);
239 DPRINTF(" B "); DPRINTF(cmd
, pf
->u3
.dwBBitMask
);
240 if (pf
->dwFlags
& DDPF_ALPHAPIXELS
)
241 DPRINTF(" A "); DPRINTF(cmd
, pf
->u4
.dwRGBAlphaBitMask
);
242 if (pf
->dwFlags
& DDPF_ZPIXELS
)
243 DPRINTF(" Z "); DPRINTF(cmd
, pf
->u4
.dwRGBZBitMask
);
245 if (pf
->dwFlags
& DDPF_ZBUFFER
)
246 DPRINTF(", Z bits : %ld", pf
->u
.dwZBufferBitDepth
);
247 if (pf
->dwFlags
& DDPF_ALPHA
)
248 DPRINTF(", Alpha bits : %ld", pf
->u
.dwAlphaBitDepth
);
252 void _dump_colorkeyflag(DWORD ck
) {
258 #define FE(x) { x, #x},
259 FE(DDCKEY_COLORSPACE
)
261 FE(DDCKEY_DESTOVERLAY
)
263 FE(DDCKEY_SRCOVERLAY
)
266 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
267 if (flags
[i
].mask
& ck
)
268 DPRINTF("%s ",flags
[i
].name
);
271 static void _dump_DWORD(void *in
) {
272 DPRINTF("%ld", *((DWORD
*) in
));
274 static void _dump_PTR(void *in
) {
275 DPRINTF("%p", *((void **) in
));
277 void _dump_DDCOLORKEY(void *in
) {
278 DDCOLORKEY
*ddck
= (DDCOLORKEY
*) in
;
280 DPRINTF(" Low : %ld - High : %ld", ddck
->dwColorSpaceLowValue
, ddck
->dwColorSpaceHighValue
);
283 void _dump_surface_desc(DDSURFACEDESC
*lpddsd
) {
288 void (*func
)(void *);
290 } flags
[16], *fe
= flags
;
291 #define FE(x,f,e) do { fe->mask = x; fe->name = #x; fe->func = f; fe->elt = (void *) &(lpddsd->e); fe++; } while(0)
292 FE(DDSD_CAPS
, _dump_DDSCAPS
, ddsCaps
);
293 FE(DDSD_HEIGHT
, _dump_DWORD
, dwHeight
);
294 FE(DDSD_WIDTH
, _dump_DWORD
, dwWidth
);
295 FE(DDSD_PITCH
, _dump_DWORD
, lPitch
);
296 FE(DDSD_BACKBUFFERCOUNT
, _dump_DWORD
, dwBackBufferCount
);
297 FE(DDSD_ZBUFFERBITDEPTH
, _dump_DWORD
, u
.dwZBufferBitDepth
);
298 FE(DDSD_ALPHABITDEPTH
, _dump_DWORD
, dwAlphaBitDepth
);
299 FE(DDSD_PIXELFORMAT
, _dump_pixelformat
, ddpfPixelFormat
);
300 FE(DDSD_CKDESTOVERLAY
, _dump_DDCOLORKEY
, ddckCKDestOverlay
);
301 FE(DDSD_CKDESTBLT
, _dump_DDCOLORKEY
, ddckCKDestBlt
);
302 FE(DDSD_CKSRCOVERLAY
, _dump_DDCOLORKEY
, ddckCKSrcOverlay
);
303 FE(DDSD_CKSRCBLT
, _dump_DDCOLORKEY
, ddckCKSrcBlt
);
304 FE(DDSD_MIPMAPCOUNT
, _dump_DWORD
, u
.dwMipMapCount
);
305 FE(DDSD_REFRESHRATE
, _dump_DWORD
, u
.dwRefreshRate
);
306 FE(DDSD_LINEARSIZE
, _dump_DWORD
, u1
.dwLinearSize
);
307 FE(DDSD_LPSURFACE
, _dump_PTR
, u1
.lpSurface
);
310 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
311 if (flags
[i
].mask
& lpddsd
->dwFlags
) {
312 DPRINTF(" - %s : ",flags
[i
].name
);
313 flags
[i
].func(flags
[i
].elt
);
317 void _dump_cooperativelevel(DWORD cooplevel
) {
323 #define FE(x) { x, #x},
325 FE(DDSCL_ALLOWREBOOT
)
326 FE(DDSCL_NOWINDOWCHANGES
)
330 FE(DDSCL_SETFOCUSWINDOW
)
331 FE(DDSCL_SETDEVICEWINDOW
)
332 FE(DDSCL_CREATEDEVICEWINDOW
)
336 if (TRACE_ON(ddraw
)) {
338 for (i
=0;i
<sizeof(flags
)/sizeof(flags
[0]);i
++)
339 if (flags
[i
].mask
& cooplevel
)
340 DPRINTF("%s ",flags
[i
].name
);