| 1 | #include <stdio.h> |
| 2 | #include <stddef.h> |
| 3 | |
| 4 | #include "../pico/pico_int.h" |
| 5 | |
| 6 | #define DUMP(f, prefix, type, field) \ |
| 7 | fprintf(f, "#define %-20s 0x%02x\n", \ |
| 8 | prefix #field, (int)offsetof(type, field)) |
| 9 | |
| 10 | #define DUMP_P(f, field) \ |
| 11 | fprintf(f, "#define %-20s 0x%04x\n", \ |
| 12 | "OFS_Pico_" #field, (char *)&p.field - (char *)&p) |
| 13 | |
| 14 | #define DUMP_PS(f, s1, field) \ |
| 15 | fprintf(f, "#define %-20s 0x%04x\n", \ |
| 16 | "OFS_Pico_" #s1 "_" #field, (char *)&p.s1.field - (char *)&p) |
| 17 | |
| 18 | #define DUMP_EST(f, field) \ |
| 19 | DUMP(f, "OFS_EST_", struct PicoEState, field) |
| 20 | |
| 21 | #define DUMP_PMEM(f, field) \ |
| 22 | DUMP(f, "OFS_PMEM_", struct PicoMem, field) |
| 23 | |
| 24 | extern struct Pico p; |
| 25 | |
| 26 | int main(int argc, char *argv[]) |
| 27 | { |
| 28 | char buf[128]; |
| 29 | FILE *f; |
| 30 | |
| 31 | snprintf(buf, sizeof(buf), "pico/pico_int_o%d.h", sizeof(void *) * 8); |
| 32 | f = fopen(buf, "w"); |
| 33 | if (!f) { |
| 34 | perror("fopen"); |
| 35 | return 1; |
| 36 | } |
| 37 | |
| 38 | fprintf(f, "/* autogenerated by %s, do not edit */\n", argv[0]); |
| 39 | DUMP_PS(f, video, reg); |
| 40 | DUMP_PS(f, m, rotate); |
| 41 | DUMP_PS(f, m, z80Run); |
| 42 | DUMP_PS(f, m, dirtyPal); |
| 43 | DUMP_PS(f, m, hardware); |
| 44 | DUMP_PS(f, m, z80_reset); |
| 45 | DUMP_PS(f, m, sram_reg); |
| 46 | DUMP_P (f, sv); |
| 47 | DUMP_PS(f, sv, data); |
| 48 | DUMP_PS(f, sv, start); |
| 49 | DUMP_PS(f, sv, end); |
| 50 | DUMP_PS(f, sv, flags); |
| 51 | DUMP_P (f, rom); |
| 52 | DUMP_P (f, romsize); |
| 53 | DUMP_EST(f, DrawScanline); |
| 54 | DUMP_EST(f, rendstatus); |
| 55 | DUMP_EST(f, DrawLineDest); |
| 56 | DUMP_EST(f, HighCol); |
| 57 | DUMP_EST(f, HighPreSpr); |
| 58 | DUMP_EST(f, Pico); |
| 59 | DUMP_EST(f, PicoMem_vram); |
| 60 | DUMP_EST(f, PicoMem_cram); |
| 61 | DUMP_EST(f, PicoIn.opt); |
| 62 | DUMP_EST(f, Draw2FB); |
| 63 | DUMP_EST(f, HighPal); |
| 64 | DUMP_PMEM(f, vram); |
| 65 | DUMP_PMEM(f, vsram); |
| 66 | fclose(f); |
| 67 | |
| 68 | return 0; |
| 69 | } |