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