Datasheet

From ZeldaMods (Link's Awakening)
Revision as of 10:40, 28 October 2019 by imported>Leoetlino (document datasheets)
Jump to navigation Jump to search
Datasheet
File format
Magic gsht
Endianness little
Version 1
This article is about the file format in general. For actual values, check the game RomFS.

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

Documents are little endian and their sizes are always 0x10-byte aligned.

Header

Offset Type Description
0x0 char[4] Magic (GSHT or gsht)
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

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,
};
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

Field data serialization
Type Serialized data format
Nullable<T> (non-strings) struct { T* data; } (nullptr if no value)
Array<T> struct { T* data; u32 size; } (aligned to 0x10 bytes[check])
Struct struct { Fields...; }
Bool bool (1-byte)
Int s32
Float f32
String struct { const char* data; u32 length; } (aligned to 0x10 bytes)

A value is simply serialized data for the structure formed of main fields.

Usage in Link's Awakening

Datasheets are extensively used to configure game logic and to store miscellaneous data. They are located in rom:/region_common/datasheets and their file extension is .gsheet.

Text versions of datasheets are available in the leoetlino/la-re-notes repository on GitHub.