JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
* config.h: added CONDERROR and NULLERROR macros.
[vor.git] / debug.c
1 #include "debug.h"
2
3 #include <stdio.h>
4
5 void
6 printf_surface(SDL_Surface *s, char *name)
7 {
8         printf("SDL_Surface *%s = {\n", name);
9                 printf("\tflags = 0x%x;\n", s->flags);
10                 printf("\tformat = {\n");
11                         printf("\t\tBitsPerPixel = %d;\n", s->format->BitsPerPixel);
12                         printf("\t\tBytesPerPixel = %d;\n", s->format->BytesPerPixel);
13                         printf("\t\tmasks = 0x%x, 0x%x, 0x%x, 0x%x;\n", s->format->Rmask, s->format->Gmask,
14                                         s->format->Bmask, s->format->Amask);
15                         printf("\t\tshifts = %d, %d, %d, %d;\n", s->format->Rshift, s->format->Gshift,
16                                         s->format->Bshift, s->format->Ashift);
17                         printf("\t\tlosses = %d, %d, %d, %d;\n", s->format->Rloss, s->format->Gloss,
18                                         s->format->Bloss, s->format->Aloss);
19                         printf("\t\tcolorkey = %d;\n", s->format->colorkey);
20                         printf("\t\talpha = %d;\n", s->format->alpha);
21                 printf("\t};\n");
22                 printf("\tw, h = %d, %d;\n", s->w, s->h);
23                 printf("\tpitch = %d;\n", s->pitch);
24         printf("};\n");
25 }
26
27 void
28 printb(uint32_t n, int bits)
29 {
30         int i;
31
32         for(i=0; i<bits; i++) {
33                 if(n & 0x80000000) putchar('1'); else putchar('0');
34                 n = n << 1;
35         }
36 }
37
38 void
39 print_mask(struct shape *s)
40 {
41         int i, j;
42
43         for(i=0; i<s->h; i++) {
44                 for(j=0; j<s->mw-1; j++) printb(s->mask[s->mw*i+j], 32);
45                 printb(s->mask[s->mw*i+j], s->w % 32);
46                 putchar('\n');
47         }
48         putchar('\n');
49 }