forked from notaz/picodrive
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathmkoffsets.c
69 lines (58 loc) · 1.58 KB
/
mkoffsets.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <stdio.h>
#include <stddef.h>
#include <pico/pico_int.h>
#define DUMP(f, prefix, type, field) \
fprintf(f, "#define %-20s 0x%02x\n", \
prefix #field, (int)offsetof(type, field))
#define DUMP_P(f, field) \
fprintf(f, "#define %-20s 0x%04x\n", \
"OFS_Pico_" #field, (char *)&p.field - (char *)&p)
#define DUMP_PS(f, s1, field) \
fprintf(f, "#define %-20s 0x%04x\n", \
"OFS_Pico_" #s1 "_" #field, (char *)&p.s1.field - (char *)&p)
#define DUMP_EST(f, field) \
DUMP(f, "OFS_EST_", struct PicoEState, field)
#define DUMP_PMEM(f, field) \
DUMP(f, "OFS_PMEM_", struct PicoMem, field)
extern struct Pico p;
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_PS(f, video, reg);
DUMP_PS(f, m, rotate);
DUMP_PS(f, m, z80Run);
DUMP_PS(f, m, dirtyPal);
DUMP_PS(f, m, hardware);
DUMP_PS(f, m, z80_reset);
DUMP_PS(f, m, sram_reg);
DUMP_P (f, sv);
DUMP_PS(f, sv, data);
DUMP_PS(f, sv, start);
DUMP_PS(f, sv, end);
DUMP_PS(f, sv, flags);
DUMP_P (f, rom);
DUMP_P (f, romsize);
DUMP_EST(f, DrawScanline);
DUMP_EST(f, rendstatus);
DUMP_EST(f, DrawLineDest);
DUMP_EST(f, HighCol);
DUMP_EST(f, HighPreSpr);
DUMP_EST(f, Pico);
DUMP_EST(f, PicoMem_vram);
DUMP_EST(f, PicoMem_cram);
DUMP_EST(f, PicoOpt);
DUMP_EST(f, Draw2FB);
DUMP_EST(f, HighPal);
DUMP_PMEM(f, vram);
DUMP_PMEM(f, vsram);
fclose(f);
return 0;
}