eliminate texrels (wip)
[picodrive.git] / tools / mkoffsets.c
diff --git a/tools/mkoffsets.c b/tools/mkoffsets.c
new file mode 100644 (file)
index 0000000..4044ad3
--- /dev/null
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stddef.h>
+
+#include "../pico/pico_int.h"
+
+#define DUMP(f, field) \
+  fprintf(f, "#define %-20s 0x%02x\n", \
+    "OFS_" #field, \
+    (int)offsetof(struct PicoEState, field))
+
+int main(int argc, char *argv[])
+{
+  char buf[128];
+  FILE *f;
+
+  snprintf(buf, sizeof(buf), "pico/pico_int_o%d.h", sizeof(void *) * 8);
+  f = fopen(buf, "w");
+  if (!f) {
+    perror("fopen");
+    return 1;
+  }
+
+  fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]);
+  DUMP(f, DrawScanline);
+  DUMP(f, rendstatus);
+  DUMP(f, Pico_video);
+  DUMP(f, Pico_vram);
+  fclose(f);
+
+  return 0;
+}