Byaml

From EPD Wiki
Revision as of 06:54, 9 May 2023 by Watertoon (talk | contribs) (Add category.)
Jump to navigation Jump to search

Byaml is Nintendo EPD's binary take on Yet Another Markup Language. Version 4 through 7 are supported by Nintendo's library as of the 3d All Stars menu.

Header

Version 4-7
Offset Size Type Description
0x0 0x2 u16 Magic ("YB" in little-endian, "BY" in big-endian)
0x2 0x2 u16 Version (4-7)
0x4 0x4 u32 Key table offset (to ByamlContainer)
0x8 0x4 u32 String table offset (to ByamlContainer)
0xc 0x4 u32 Root container offset (to ByamlContainer)

Byaml Container

Version 4-7
Offset Size Type Description
0x0 0x1 u8 (NodeDataType Enum) Container data type
0x1 0x3 u24 Count of container elements
NodeDataType specific data

Node Data Types

u8 enum of data types that can appear. "Value" describes what the Value in a NodeDataType + Value pair means. These pairs are found in every container type.

Version 7
Name(unofficial) Value Container "Value" Description
HashArray 0x20-0x2f Value is an absolute offset to a ByamlContainer of the Hash Array type
HashArrayWithRemap 0x30-0x3f Same as above but when accessing elements by index that index is remapped
StringIndex 0xa0 Value is an index into the string table
BinaryData 0xa1 Value is an absolute offset from the header to size of binary data followed by the binary data
BinaryDataWithAlignment 0xa2 Same as above but pointing to the size of the binary data, followed by alignment, followed by binary data
Array 0xc0 Value is an absolute offset to a ByamlContainer of the Array type
Dictionary 0xc1 Value is an absolute offset to a ByamlContainer of the Dictionary type
Key/StringTable 0xc2 (Only found in ByamlContainer pointed to by header)
DictionaryWithRemap 0xc4 Value is an absolute offset to a ByamlContainer of the Dictionary with remap type
RelocatedKey/StringTable 0xc5 (Only found in ByamlContainer pointed to by header)
MonoTypedArray 0xc8 Value is an absolute offset to a ByamlContainer of the Array with remap type
Bool 0xd0 Value is a bool
S32 0xd1 Value is a signed 32-bit integer
F32 0xd2 Value is a 32-bit floating point number
U32 0xd3 Value is a unsigned 32-bit integer
S64 0xd4 Value is an absolute offset to a signed 64-bit integer
U64 0xd5 Value is an absolute offset to a unsigned 64-bit integer
F64 0xd6 Value is an absolute offset to a 64-bit floating point number
Null 0xff Value is 0 (null)

Key/String Tables (0xc2, 0xc5)

Only pointed to by the header, these tables are responsible for storing strings. The key table is used for dictionary containers and is sorted, the string table is for string data.

Key/String Table (0xc2)

Version 4-7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0x4 * ByamlContainer count u32 String offset array, offsets relative to string table header
string data Array of strings

Relocated Key/String Table (0xc2) (TODO)

Version 7
Offset Size Type Description
0x0 0x4 ByamlContainer

Hash Array (0x20-0x2f)

Recent container types first appearing (to writer's knowledge) in the code of the byaml library in the 3d All Stars menu. NodeDataType + Value pairs can be accessed through hash values and indices.

Hash Pair

Version 7
Offset Size Type Description
0x0 (NodeDataType & 0xf) * 0x4 u32[N] Hash
0x4 u32 Value

Hash Array (0x20-0x2f)

Version 7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0xN * ByamlContainer count HashPair Hash + value array sorted by hash
0x1 * ByamlContainer count u8 NodeDataType for HashPair value

Hash Array With Remap (0x30-0x3f)

Version 7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0xN * ByamlContainer count HashPair Hash + value array sorted by hash
0x1 * ByamlContainer count u8 NodeDataType for HashPair value
0x1 * ByamlContainer count (if count < 0x100),

0x2 * ByamlContainer count (if count < 0x10000), 0x4 * ByamlContainer count (else)

u8, u16, u32 Index remap table

Array (0xc0, 0xc8)

Container types where NodeDataType + Value pairs can be accessed through indices.

Array (0xc0)

Version 4-7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0x1 * ByamlContainer count u8 NodeDataType array matching index of value
0x4 * ByamlContainer count u32 Value array

Mono-Typed Array (0xc8)

Version 7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0x1 u8 NodeDataType for every array value
0x8 0x4 * ByamlContainer count u32 Value array

Dictionary (0xc1, 0xc4)

Container types where NodeDataType + Value pairs can be accessed through a string key or indices.

Byaml Dictionary Pair

Version 4-7
Offset Size Type Description
0x0 0x3 u24 Key table index
0x1 0x1 u8 Node Data Type
0x4 0x4 u32 Value

Dictionary (0xc1)

Version 4-7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0x8 * ByamlContainer count ByamlDictionaryPair Dictionary pair array sorted by key index

Dictionary With Remap (0xc4)

Version 7
Offset Size Type Description
0x0 0x4 ByamlContainer
0x4 0x8 * ByamlContainer count ByamlDictionaryPair Dictionary pair array sorted by key index
0x1 * ByamlContainer count (if count < 0x100),

0x2 * ByamlContainer count (if count < 0x10000), 0x4 * ByamlContainer count (else)

u8, u16, u32 Index remap table