Datasheet: Difference between revisions
Jump to navigation
Jump to search
document datasheets
imported>Leoetlino m (fix section order) |
imported>Leoetlino (document datasheets) |
||
Line 1: | Line 1: | ||
{{File format|name=Datasheet|version=1|magic=gsht|endianness=little}} | {{File format|name=Datasheet|version=1|magic=gsht|endianness=little}} | ||
'''GSHT''' (G?sheet) is a custom Grezzo binary serialization file format that is used to store structured, strongly typed data. GSHT documents are called '''datasheets'''. | '''GSHT''' (G?sheet) is a custom Grezzo binary serialization file format that is used to store structured, strongly typed data. GSHT documents are called '''datasheets'''. | ||
A datasheet contains structure type information followed by arrays of structures. Optionally, one of the structure fields may be declared as a key field, in which case the contents are a dictionary rather than a array. | |||
== Format == | == Format == | ||
{{ | Documents are little endian and their sizes are always 0x10-byte aligned. | ||
=== Header === | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
|0x0 | |||
|char[4] | |||
|Magic (<code>GSHT</code> or <code>gsht</code>) | |||
|- | |||
|0x4 | |||
|int | |||
|Version (must be 1) | |||
|- | |||
|0xC | |||
|u8 | |||
|Bool type size (must be 1) | |||
|- | |||
|0xD | |||
|u8 | |||
|Pointer size (must be 8) | |||
|- | |||
|0xE | |||
|u8 | |||
|?{{Check}} | |||
|- | |||
|0x10 | |||
|const char* | |||
|Name | |||
|- | |||
|0x18 | |||
|u32 | |||
|Number of main fields | |||
|- | |||
|0x1C | |||
|u32 | |||
|Number of fields in total | |||
|- | |||
|0x20 | |||
|Value* | |||
|Values | |||
|- | |||
|0x28 | |||
|u32 | |||
|Number of values | |||
|- | |||
|0x2C | |||
|u32 | |||
|Value size | |||
|} | |||
=== Field === | |||
<syntaxhighlight lang="c++"> | |||
enum class Type : u16 { | |||
Struct = 0, | |||
Bool = 1, | |||
Int = 2, | |||
Float = 3, | |||
String = 4, | |||
}; | |||
enum class Flag : u16 { | |||
IsNullable = 1 << 0, | |||
IsArray = 1 << 1, | |||
IsKey = 1 << 2, | |||
b3 = 1 << 3, | |||
IsEnum = 1 << 4, | |||
b5 = 1 << 5, | |||
}; | |||
</syntaxhighlight> | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
|0x0 | |||
|const char* | |||
|Name (must be non-null) | |||
|- | |||
|0x8 | |||
|const char* | |||
|Type name | |||
|- | |||
|0x10 | |||
|Field::Type | |||
|Type | |||
|- | |||
|0x11 | |||
|u8 | |||
|?{{Check}} | |||
|- | |||
|0x12 | |||
|Field::Flag | |||
|Flags | |||
|- | |||
|0x14 | |||
|u16 | |||
|Value offset | |||
|- | |||
|0x16 | |||
|u16 | |||
|Value blob size | |||
|- | |||
|0x18 | |||
|u16 | |||
|Value size | |||
|- | |||
|0x1A | |||
|u16 | |||
|Structure field count | |||
|- | |||
|0x20 | |||
|Field* | |||
|Structure fields | |||
|- | |||
|0x28 | |||
|Field* | |||
|Parent (filled in during parsing; always 0xdeadbeefdeadbeef when serialized) | |||
|} | |||
Fields must be properly aligned to 0x30 byte boundaries. | |||
Key fields cannot be arrays or Nullable types. | |||
Key fields must be of type String or Int. | |||
=== Value === | |||
{| class="wikitable" | |||
|+Field data serialization | |||
!Type | |||
!Serialized data format | |||
|- | |||
|Nullable<T> (non-strings) | |||
|<code>struct { T* data; }</code> (nullptr if no value) | |||
|- | |||
|Array<T> | |||
|<code>struct { T* data; u32 size; }</code> (aligned to 0x10 bytes{{Check}}) | |||
|- | |||
|Struct | |||
|<code>struct { Fields...; }</code> | |||
|- | |||
|Bool | |||
|bool (1-byte) | |||
|- | |||
|Int | |||
|s32 | |||
|- | |||
|Float | |||
|f32 | |||
|- | |||
|String | |||
|<code>struct { const char* data; u32 length; }</code> (aligned to 0x10 bytes) | |||
|} | |||
A value is simply serialized data for the structure formed of main fields. | |||
== Usage in ''Link's Awakening'' == | == Usage in ''Link's Awakening'' == | ||
Line 10: | Line 165: | ||
Text versions of datasheets are available in the [https://github.com/leoetlino/la-re-notes/tree/master/data/datasheets leoetlino/la-re-notes] repository on GitHub. | Text versions of datasheets are available in the [https://github.com/leoetlino/la-re-notes/tree/master/data/datasheets leoetlino/la-re-notes] repository on GitHub. | ||
[[Category:File formats]] | [[Category:File formats]] |