a5c475f216575f7688062bec3417c93e531a81e7
[picodrive.git] / tools / mkoffsets.c
1 #include <stdio.h>
2 #include <stddef.h>
3
4 #include "../pico/pico_int.h"
5
6 #define DUMP(f, field) \
7   fprintf(f, "#define %-20s 0x%02x\n", \
8     "OFS_" #field, \
9     (int)offsetof(struct PicoEState, field))
10
11 int main(int argc, char *argv[])
12 {
13   char buf[128];
14   FILE *f;
15
16   snprintf(buf, sizeof(buf), "pico/pico_int_o%d.h", sizeof(void *) * 8);
17   f = fopen(buf, "w");
18   if (!f) {
19     perror("fopen");
20     return 1;
21   }
22
23   fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
24   DUMP(f, DrawScanline);
25   DUMP(f, rendstatus);
26   DUMP(f, DrawLineDest);
27   DUMP(f, HighCol);
28   DUMP(f, HighPreSpr);
29   DUMP(f, Pico_video);
30   DUMP(f, Pico_vram);
31   DUMP(f, PicoOpt);
32   DUMP(f, Draw2FB);
33   DUMP(f, HighPal);
34   fclose(f);
35
36   return 0;
37 }