summaryrefslogtreecommitdiff
path: root/tools/assets/descriptor/spec.md
blob: 241483f3f50ea83ad14368a28b432219c6971b0e (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
This document describes the expected structure of xml files describing assets.

# Top elements

## `Root`

```xml
<Root>
    ...
</Root>
```

This is the root element in the file, containing exclusively `<File>` and `<ExternalFile>` elements as direct children.

## `File`

```xml
<File Name="baserom_file" Segment="11">
    ...
</File>
```

A `<File>` contains resources elements as children.

- Required attributes: `Name`
- Optional attributes: `Segment`

`Name` is the name of the baserom file from which the data is to be extracted.

`Segment` (decimal) is the segment number for the file.

## `ExternalFile`

```xml
<ExternalFile OutPath="assets/name"/>
```

Declare the `<File>`s in the xml may reference symbols from an external file.

The external file is located by matching its name against the list of assets in the version's `config.yml`.

For example, `baseroms/gc-eu/config.yml` contains

```yml
assets:
- name: objects/gameplay_keep
  xml_path: assets/xml/objects/gameplay_keep.xml
```

then `<ExternalFile OutPath="assets/objects/gameplay_keep/"/>` refers to that gameplay_keep entry, which uses the `gameplay_keep.xml` xml file when extracting assets for version gc-eu.


# Resource elements

Resource elements describe resources. Resources are pieces of data corresponding to a symbol each.

One attribute is required on all resource elements: `Name`.

- `Name` is the name of the symbol associated to the resource.

Another attribute, optional, is common to all resource elements: `Offset`.

If `Offset` is set to a (hexadecimal) number such as `Offset="0x421"`, it specifies the location of the resource in bytes from the start of the file data.

If `Offset` is not set, the resource is assumed to start where the previous resource ended, or at 0 if the resource is the first in the `<File>`.

`Offset` can also be set to be a relative offset like `Offset=".+0x421"`, which makes the resource location be that many bytes after the end of the previous resource.

## `Blob`

```xml
<Blob Name="gNameBlob" Size="0x421" Offset="0x1230">
```

Unstructured binary data.

- Required attributes: `Size`

`Size` is the size of the binary blob in bytes.

## `DList`

```xml
<DList Name="gNameDL" Offset="0x1230" Length="123" Ucode="f3dex2" RawPointers="0x08000000,0x09000000"/>
```

A display list.

- Optional attributes: `Length`, `Ucode`, `RawPointers`

`Length` can be set to indicate the length (amount of `Gfx` double-words) of the dlist. If not set, the dlist length is automatic.

`Ucode` (defaults to `f3dex2`) picks the graphics microcode for which to disassemble the dlist. It may be `f3dex` or `f3dex2`.

`RawPointers` (defaults to an empty value) is a comma-separated list of values the display list uses as raw pointers ("hex" instead of a symbol). The purpose of this attribute is to silence extraction warnings.

## `Mtx`

```xml
<Mtx Name="gNameMtx" Offset="0x1230"/>
```

A fixed-point matrix.

## `Texture`

```xml
<Texture Name="gNameTex" Format="rgba16" Width="16" Height="16" Offset="0x1230"/>
<Texture Name="gNameTex" Format="ci8" Width="16" Height="16" Offset="0x1230" Tlut="gNameTLUT"/>
<Texture Name="gNameTex" Format="ci8" Width="16" Height="16" Offset="0x1230" TlutOffset="0x2340"/>
<Texture Name="gNameTex" Format="ci8" Width="16" Height="16" Offset="0x1230" ExternalTlut="baserom_file" ExternalTlutOffset="0x2340"/>
```

A texture, an image in one of the native N64 formats.

- Required attributes for all formats: `Format`, `Width`, `Height`
- Required attributes for CI formats (`ci4`, `ci8`): `Tlut`, or `TlutOffset`, or `ExternalTlut` and `ExternalTlutOffset`

`Format` is the format of the texture, one of `rgba32`, `rgba16`, `i4`, `i8`, `ia4`, `ia8`, `ia16`, `ci4` or `ci8`.

`Width` and `Height` specify the dimensions of the texture.

For CI formats, the TLUT (Texture Look Up Table, or palette) must be specified with either `Tlut` or `TlutOffset` if the TLUT is in the same file as the texture, or both of `ExternalTlut` and `ExternalTlutOffset` if the TLUT is in a different file. `ExternalTlut` is the name of the baserom file where the TLUT is. In both cases, the TLUT must also be declared as a resource.

## `Array`

```xml
<Array Name="gNameVtx" Count="42" Offset="0x1230">
    <Vtx/>
</Array>
<Array Name="gNameVec3sArray" Count="42" Offset="0x1230">
    <Vector Type="s16" Dimensions="3"/>
</Array>
<Array Name="gNameS16Array" Count="42" Offset="0x1230">
    <Scalar Type="s16"/>
</Array>
```

An array of vertices, vectors or scalars. The child element determines the array's element type.

- Required attributes: `Count`

`Count` is the length of the array.

The child element may be one of `<Vtx/>` (for `Vtx[]`), `<Vector Type="s16" Dimensions="3"/>` (for `Vec3s[]`) or `<Scalar Type="s16">` (for `s16[]`).

## `Scene`

```xml
<Scene Name="name" Offset="0x1230"/>
```

Scene commands.

## `Room`

```xml
<Room Name="name" Offset="0x1230"/>
```

Room commands.

## `Collision`

```xml
<Collision Name="gNameCol" Offset="0x1230"/>
```

Collision header.

## `Cutscene`

```xml
<Cutscene Name="gNameCs" Offset="0x1230"/>
```

Cutscene script.

## `Path`

```xml
<Path Name="gNamePathList" Offset="0x1230" NumPaths="12"/>
```

Path list.

- Required attributes: `NumPaths`

`NumPaths` is the length of the path list.

## `Skeleton`

```xml
<Skeleton Name="gNameSkel" Type="Normal" LimbType="Standard" LimbNone="NAME_LIMB_NONE" LimbMax="NAME_LIMB_MAX" EnumName="NameLimb" Offset="0x1230"/>
```

Skeleton header.

- Required attributes: `Type`, `LimbType`
- Optional attributes: `LimbNone`, `LimbMax`, `EnumName`

`Type` is the type of the skeleton, one of `Normal`, `Flex` or `Curve`.

`LimbType` is the type of limb used in the skeleton, one of `Standard`, `LOD`, `Skin`, `Curve` or `Legacy`.

Not all skeleton types are compatible with all limb types:

`LimbType` | Compatible skeleton `Type`
-----------|---------------------------
`Standard` | `Normal`, `Flex`
`LOD`      | `Normal`, `Flex`
`Skin`     | `Normal`
`Curve`    | `Curve`
`Legacy`   | none

`LimbNone`, `LimbMax`, `EnumName` can be set to override the corresponding names in the generated limb enum:

```c
typedef enum NameLimb {
    NAME_LIMB_NONE,
    ...
    NAME_LIMB_MAX
} NameLimb;
```

## `LimbTable`

```xml
<LimbTable Name="gNameLimbs" LimbType="Standard" Count="12" Offset="0x1230"/>
```

Limb table.

- Required attributes: `LimbType`, `Count`

`LimbType` is one of `Standard`, `LOD`, `Skin`, `Curve` or `Legacy`.

`Count` is the amount of limbs.

## `Limb`

```xml
<Limb Name="gNameLimb" LimbType="Standard" EnumName="NAME_LIMB_NAME" Offset="0x1230"/>
```

Limb of a skeleton.

- Required attributes: `LimbType`
- Optional attributes: `EnumName`

`LimbType` is one of `Standard`, `LOD`, `Skin`, `Curve` or `Legacy`.

`EnumName` can be set to override the limb name in the generated limb enum.

## `Animation`

```xml
<Animation Name="gNameAnim" Offset="0x1230"/>
```

Animation header.

## `CurveAnimation`

```xml
<CurveAnimation Name="gNameAnim" SkelOffset="0x120" Offset="0x1230"/>
```

Curve animation header.

- Required attributes: `SkelOffset`

`SkelOffset` is the offset of the skeleton which uses this animation. The skeleton must also be declared as a resource.

## `LegacyAnimation`

```xml
<LegacyAnimation Name="gNameAnim" Offset="0x1230"/>
```

Legacy animation header.

## `PlayerAnimation`

```xml
<PlayerAnimation Name="gNamePlayerAnim" Offset="0x1230"/>
```

Player animation header.

## `PlayerAnimationData`

```xml
<PlayerAnimationData Name="gNamePlayerAnimData" FrameCount="20" Offset="0x1230"/>
```

Player animation data.

- Required attributes: `FrameCount`

`FrameCount` is the amount of frames in the animation.