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"
30 DEFAULT_DEBUG_CHANNEL(ddraw);
32 /******************************************************************************
33 * debug output functions
35 void _dump_DDBLTFX(DWORD flagmask) {
41 #define FE(x) { x, #x},
42 FE(DDBLTFX_ARITHSTRETCHY)
43 FE(DDBLTFX_MIRRORLEFTRIGHT)
44 FE(DDBLTFX_MIRRORUPDOWN)
49 FE(DDBLTFX_ZBUFFERRANGE)
50 FE(DDBLTFX_ZBUFFERBASEDEST)
53 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
54 if (flags[i].mask & flagmask)
55 DPRINTF("%s ",flags[i].name);
59 void _dump_DDBLTFAST(DWORD flagmask) {
65 #define FE(x) { x, #x},
66 FE(DDBLTFAST_NOCOLORKEY)
67 FE(DDBLTFAST_SRCCOLORKEY)
68 FE(DDBLTFAST_DESTCOLORKEY)
72 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
73 if (flags[i].mask & flagmask)
74 DPRINTF("%s ",flags[i].name);
78 void _dump_DDBLT(DWORD flagmask) {
84 #define FE(x) { x, #x},
86 FE(DDBLT_ALPHADESTCONSTOVERRIDE)
87 FE(DDBLT_ALPHADESTNEG)
88 FE(DDBLT_ALPHADESTSURFACEOVERRIDE)
89 FE(DDBLT_ALPHAEDGEBLEND)
91 FE(DDBLT_ALPHASRCCONSTOVERRIDE)
93 FE(DDBLT_ALPHASRCSURFACEOVERRIDE)
99 FE(DDBLT_KEYDESTOVERRIDE)
101 FE(DDBLT_KEYSRCOVERRIDE)
103 FE(DDBLT_ROTATIONANGLE)
105 FE(DDBLT_ZBUFFERDESTCONSTOVERRIDE)
106 FE(DDBLT_ZBUFFERDESTOVERRIDE)
107 FE(DDBLT_ZBUFFERSRCCONSTOVERRIDE)
108 FE(DDBLT_ZBUFFERSRCOVERRIDE)
113 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
114 if (flags[i].mask & flagmask)
115 DPRINTF("%s ",flags[i].name);
119 void _dump_DDSCAPS(void *in) {
125 #define FE(x) { x, #x},
126 FE(DDSCAPS_RESERVED1)
128 FE(DDSCAPS_BACKBUFFER)
131 FE(DDSCAPS_FRONTBUFFER)
132 FE(DDSCAPS_OFFSCREENPLAIN)
135 FE(DDSCAPS_PRIMARYSURFACE)
136 FE(DDSCAPS_PRIMARYSURFACELEFT)
137 FE(DDSCAPS_SYSTEMMEMORY)
140 FE(DDSCAPS_VIDEOMEMORY)
142 FE(DDSCAPS_WRITEONLY)
145 FE(DDSCAPS_LIVEVIDEO)
149 FE(DDSCAPS_RESERVED2)
150 FE(DDSCAPS_ALLOCONLOAD)
151 FE(DDSCAPS_VIDEOPORT)
152 FE(DDSCAPS_LOCALVIDMEM)
153 FE(DDSCAPS_NONLOCALVIDMEM)
154 FE(DDSCAPS_STANDARDVGAMODE)
155 FE(DDSCAPS_OPTIMIZED)
158 DWORD flagmask = *((DWORD *) in);
159 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
160 if (flags[i].mask & flagmask)
161 DPRINTF("%s ",flags[i].name);
164 void _dump_pixelformat_flag(DWORD flagmask) {
170 #define FE(x) { x, #x},
174 FE(DDPF_PALETTEINDEXED4)
175 FE(DDPF_PALETTEINDEXEDTO8)
176 FE(DDPF_PALETTEINDEXED8)
182 FE(DDPF_PALETTEINDEXED1)
183 FE(DDPF_PALETTEINDEXED2)
187 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
188 if (flags[i].mask & flagmask)
189 DPRINTF("%s ",flags[i].name);
192 void _dump_paletteformat(DWORD dwFlags) {
198 #define FE(x) { x, #x},
200 FE(DDPCAPS_8BITENTRIES)
202 FE(DDPCAPS_INITIALIZE)
203 FE(DDPCAPS_PRIMARYSURFACE)
204 FE(DDPCAPS_PRIMARYSURFACELEFT)
212 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
213 if (flags[i].mask & dwFlags)
214 DPRINTF("%s ",flags[i].name);
218 void _dump_pixelformat(void *in) {
219 LPDDPIXELFORMAT pf = (LPDDPIXELFORMAT) in;
222 _dump_pixelformat_flag(pf->dwFlags);
223 if (pf->dwFlags & DDPF_FOURCC) {
224 DPRINTF(", dwFourCC : %c%c%c%c",
225 (unsigned char)((pf->dwFourCC>>24)&0xff),
226 (unsigned char)((pf->dwFourCC>>16)&0xff),
227 (unsigned char)((pf->dwFourCC>> 8)&0xff),
228 (unsigned char)( pf->dwFourCC &0xff)
231 if (pf->dwFlags & DDPF_RGB) {
233 DPRINTF(", RGB bits: %ld, ", pf->u.dwRGBBitCount);
234 switch (pf->u.dwRGBBitCount) {
235 case 4: cmd = "%1lx"; break;
236 case 8: cmd = "%02lx"; break;
237 case 16: cmd = "%04lx"; break;
238 case 24: cmd = "%06lx"; break;
239 case 32: cmd = "%08lx"; break;
240 default: ERR("Unexpected bit depth !\n"); cmd = "%d"; break;
242 DPRINTF(" R "); DPRINTF(cmd, pf->u1.dwRBitMask);
243 DPRINTF(" G "); DPRINTF(cmd, pf->u2.dwGBitMask);
244 DPRINTF(" B "); DPRINTF(cmd, pf->u3.dwBBitMask);
245 if (pf->dwFlags & DDPF_ALPHAPIXELS) {
246 DPRINTF(" A "); DPRINTF(cmd, pf->u4.dwRGBAlphaBitMask);
248 if (pf->dwFlags & DDPF_ZPIXELS) {
249 DPRINTF(" Z "); DPRINTF(cmd, pf->u4.dwRGBZBitMask);
252 if (pf->dwFlags & DDPF_ZBUFFER) {
253 DPRINTF(", Z bits : %ld", pf->u.dwZBufferBitDepth);
255 if (pf->dwFlags & DDPF_ALPHA) {
256 DPRINTF(", Alpha bits : %ld", pf->u.dwAlphaBitDepth);
261 void _dump_colorkeyflag(DWORD ck) {
267 #define FE(x) { x, #x},
268 FE(DDCKEY_COLORSPACE)
270 FE(DDCKEY_DESTOVERLAY)
272 FE(DDCKEY_SRCOVERLAY)
275 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
276 if (flags[i].mask & ck)
277 DPRINTF("%s ",flags[i].name);
280 static void _dump_DWORD(void *in) {
281 DPRINTF("%ld", *((DWORD *) in));
283 static void _dump_PTR(void *in) {
284 DPRINTF("%p", *((void **) in));
286 void _dump_DDCOLORKEY(void *in) {
287 DDCOLORKEY *ddck = (DDCOLORKEY *) in;
289 DPRINTF(" Low : %ld - High : %ld", ddck->dwColorSpaceLowValue, ddck->dwColorSpaceHighValue);
292 void _dump_surface_desc(DDSURFACEDESC *lpddsd) {
297 void (*func)(void *);
299 } flags[16], *fe = flags;
300 #define FE(x,f,e) do { fe->mask = x; fe->name = #x; fe->func = f; fe->elt = (void *) &(lpddsd->e); fe++; } while(0)
301 FE(DDSD_CAPS, _dump_DDSCAPS, ddsCaps);
302 FE(DDSD_HEIGHT, _dump_DWORD, dwHeight);
303 FE(DDSD_WIDTH, _dump_DWORD, dwWidth);
304 FE(DDSD_PITCH, _dump_DWORD, lPitch);
305 FE(DDSD_BACKBUFFERCOUNT, _dump_DWORD, dwBackBufferCount);
306 FE(DDSD_ZBUFFERBITDEPTH, _dump_DWORD, u.dwZBufferBitDepth);
307 FE(DDSD_ALPHABITDEPTH, _dump_DWORD, dwAlphaBitDepth);
308 FE(DDSD_PIXELFORMAT, _dump_pixelformat, ddpfPixelFormat);
309 FE(DDSD_CKDESTOVERLAY, _dump_DDCOLORKEY, ddckCKDestOverlay);
310 FE(DDSD_CKDESTBLT, _dump_DDCOLORKEY, ddckCKDestBlt);
311 FE(DDSD_CKSRCOVERLAY, _dump_DDCOLORKEY, ddckCKSrcOverlay);
312 FE(DDSD_CKSRCBLT, _dump_DDCOLORKEY, ddckCKSrcBlt);
313 FE(DDSD_MIPMAPCOUNT, _dump_DWORD, u.dwMipMapCount);
314 FE(DDSD_REFRESHRATE, _dump_DWORD, u.dwRefreshRate);
315 FE(DDSD_LINEARSIZE, _dump_DWORD, u1.dwLinearSize);
316 FE(DDSD_LPSURFACE, _dump_PTR, u1.lpSurface);
319 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
320 if (flags[i].mask & lpddsd->dwFlags) {
321 DPRINTF(" - %s : ",flags[i].name);
322 flags[i].func(flags[i].elt);
326 void _dump_cooperativelevel(DWORD cooplevel) {
332 #define FE(x) { x, #x},
334 FE(DDSCL_ALLOWREBOOT)
335 FE(DDSCL_NOWINDOWCHANGES)
339 FE(DDSCL_SETFOCUSWINDOW)
340 FE(DDSCL_SETDEVICEWINDOW)
341 FE(DDSCL_CREATEDEVICEWINDOW)
345 if (TRACE_ON(ddraw)) {
347 for (i=0;i<sizeof(flags)/sizeof(flags[0]);i++)
348 if (flags[i].mask & cooplevel)
349 DPRINTF("%s ",flags[i].name);