-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
rgbds.hexpat
132 lines (119 loc) · 2.4 KB
/
rgbds.hexpat
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma author ISSOtm <[email protected]>
#pragma description Object files for the RGBDS Game Boy assembly toolchain
// Documentation: https://rgbds.gbdev.io/docs/rgbds.5
#pragma magic [ 52 47 42 39 ] @ 0x00
#pragma endian little
#include <std/string.pat>
using LONG = u32;
using BYTE = u8;
using STRING = std::string::NullString;
char magic[4] @ 0;
LONG revNum @ $;
LONG nbSym @ $;
LONG nbSect @ $;
namespace fstack {
enum Type : BYTE {
REPT,
File,
Macro,
};
struct Node {
LONG parentID;
LONG parentLineNo;
Type type;
if (type != Type::REPT) {
STRING name;
} else {
LONG depth;
LONG iters[depth];
}
};
LONG nbNodes @ $;
Node nodes[nbNodes] @ $;
}
namespace sym {
enum Type : BYTE {
Local,
Import,
Exported,
};
struct Symbol {
STRING name;
Type type;
if (type != Type::Import) {
LONG nodeID;
LONG lineNo;
LONG sectionID;
LONG value;
}
};
Symbol symbols[nbSym] @ $;
}
namespace sect {
enum PatchType : BYTE {
DB,
DW,
DL,
JR,
};
struct Patch {
LONG nodeID;
LONG lineNo;
LONG ofs;
LONG pcSectID;
LONG pcOfs;
PatchType type;
LONG rpnSize;
BYTE rpn[rpnSize];
};
enum Type : BYTE {
WRAM0,
VRAM,
ROMX,
ROM0,
HRAM,
WRAMX,
SRAM,
OAM,
};
bitfield Attrs {
Type type : 6;
bool isFragment : 1;
bool isUnion : 1;
};
struct Section {
STRING name;
LONG size;
Attrs attrs;
LONG address;
LONG bank;
BYTE alignment;
LONG alignOfs;
if (attrs.type == Type::ROMX || attrs.type == Type::ROM0) {
BYTE data[size];
LONG nbPatches;
Patch patches[nbPatches];
}
};
Section sections[nbSect] @ $;
}
namespace assert {
enum Type : BYTE {
Warn,
Err,
Fatal,
};
struct Assertion {
LONG nodeID;
LONG lineNo;
LONG ofs;
LONG pcSectID;
LONG pcOfs;
Type type;
LONG rpnSize;
BYTE rpn[rpnSize];
STRING msg;
};
LONG nbAsserts @ $;
Assertion assertions[nbAsserts] @ $;
}