28
edits
(added info on all the short sections) |
(added all sections except exb) |
||
Line 3: | Line 3: | ||
=== File Structure === | === File Structure === | ||
AINB is a little endian format similar to most Switch file formats. An AINB file consists of a set of interconnected nodes which act like a syntax tree and control the behavior of actors. These nodes can also be calls to external AINB files, allowing AINB files to form entire trees of files. The root file of the tree will have <code>.root.ainb</code> as their extension while each module in the tree will have the extension <code>.module.ainb</code>. There are three primary categories of AINB files in ''TotK'': AI, Logic, and Sequence. For AI and Sequence files, the file's entry point is one or more commands which is linked to one or two child nodes. All nodes are accessed by their index (references to precondition nodes will use their precondition node index which is local to the amount of precondition nodes in the file). | AINB is a little endian format similar to most Switch file formats. An AINB file consists of a set of interconnected nodes which act like a syntax tree and control the behavior of actors. These nodes can also be calls to external AINB files, allowing AINB files to form entire trees of files. The root file of the tree will have <code>.root.ainb</code> as their extension while each module in the tree will have the extension <code>.module.ainb</code>. There are three primary categories of AINB files in ''TotK'': AI, Logic, and Sequence. For AI and Sequence files, the file's entry point is one or more commands which is linked to one or two child nodes. All nodes are accessed by their index (references to precondition nodes will use their precondition node index which is local to the amount of precondition nodes in the file). | ||
Line 29: | Line 30: | ||
# Enum Resolve Array | # Enum Resolve Array | ||
# String Pool | # String Pool | ||
=== Sections === | |||
==== File Header ==== | ==== File Header ==== | ||
Line 859: | Line 862: | ||
|0x01 | |0x01 | ||
|u8 | |u8 | ||
|Unknown Connection Type Count (Unused in TotK) | |Unknown Connection Type Count (Unused in ''TotK'') | ||
|- | |- | ||
|0x03 | |0x03 | ||
|0x01 | |0x01 | ||
|u8 | |u8 | ||
|Unknown Connection Type Base Index (Unused TotK) | |Unknown Connection Type Base Index (Unused ''TotK'') | ||
|- | |- | ||
|0x04 | |0x04 | ||
Line 985: | Line 988: | ||
==== Attachment Parameters ==== | ==== Attachment Parameters ==== | ||
This section contains an array of attachments for nodes. This section is preceded by the attachment index array which is an array of u32 indices into the entries in this section. Nodes contain an index into the index array rather than directly into this section. The section contains an array of entries followed by an array of parameter entries. | |||
{| class="wikitable" | |||
|+Attachment Parameter Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|u32 | |||
|Name Offset | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Parameters Entry Offset | |||
|- | |||
|0x08 | |||
|0x02 | |||
|u16 | |||
|EXB Function Count | |||
|- | |||
|0x0A | |||
|0x02 | |||
|u16 | |||
|EXB Input/Output Field Size | |||
|- | |||
|0x0C | |||
|0x04 | |||
|u32 | |||
|Name Hash (version 0x0407 only) | |||
|} | |||
{| class="wikitable" | |||
|+Parameter Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|u32 | |||
|Unknown (possibly related to debug) | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Int Immediate Parameter Base Index | |||
|- | |||
|0x08 | |||
|0x04 | |||
|u32 | |||
|Int Immediate Parameter Count | |||
|- | |||
|0x0C | |||
|0x04 | |||
|u32 | |||
|Bool Immediate Parameter Base Index | |||
|- | |||
|0x10 | |||
|0x04 | |||
|u32 | |||
|Bool Immediate Parameter Count | |||
|- | |||
|0x14 | |||
|0x04 | |||
|u32 | |||
|Float Immediate Parameter Base Index | |||
|- | |||
|0x18 | |||
|0x04 | |||
|u32 | |||
|Float Immediate Parameter Count | |||
|- | |||
|0x1C | |||
|0x04 | |||
|u32 | |||
|String Immediate Parameter Base Index | |||
|- | |||
|0x20 | |||
|0x04 | |||
|u32 | |||
|String Immediate Parameter Count | |||
|- | |||
|0x24 | |||
|0x04 | |||
|u32 | |||
|Vector3f Immediate Parameter Base Index | |||
|- | |||
|0x28 | |||
|0x04 | |||
|u32 | |||
|Vector3f Immediate Parameter Count | |||
|- | |||
|0x2C | |||
|0x04 | |||
|u32 | |||
|Pointer Immediate Parameter Base Index | |||
|- | |||
|0x30 | |||
|0x04 | |||
|u32 | |||
|Pointer Immediate Parameter Count | |||
|- | |||
|0x34 | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x38 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|- | |||
|0x3C | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x40 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|- | |||
|0x44 | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x48 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|- | |||
|0x4C | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x50 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|- | |||
|0x54 | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x58 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|- | |||
|0x5C | |||
|0x04 | |||
|u32 | |||
| | |||
|- | |||
|0x60 | |||
|0x04 | |||
|u32 | |||
|Unknown (contains address to next entry) | |||
|} | |||
==== Immediate Parameters ==== | ==== Immediate Parameters ==== | ||
This section contains an array of immediate parameters for nodes. The section begins with a six u32 relative offsets to the first entry for each data type. The data type order for this section is int, bool, float, string, vector3f, and pointer. | |||
{| class="wikitable" | |||
|+Parameter Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|u32 | |||
|Name Offset | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Flags | |||
|- | |||
|0x08 | |||
| | |||
| | |||
|Value | |||
|} | |||
The value is an immediate value for the data type (excluding string which is a string offset and pointer which doesn't store a value). Pointer entries also have an additional u32 class name offset at offset 0x04, pushing the flags to offset 0x08. | |||
{| class="wikitable" | |||
|+Parameter Flags | |||
!Bits | |||
!Description | |||
|- | |||
|16 | |||
|Source Index | |||
|- | |||
|1 | |||
|Is Use Index | |||
|- | |||
|1 | |||
|Is Not Local Blackboard Index | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
|Is EXB Index | |||
|- | |||
|1 | |||
|Pulse Thread Local Storage | |||
|- | |||
|1 | |||
|Set Pointer Flag Bit Zero | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|} | |||
==== Input/Output Parameters ==== | ==== Input/Output Parameters ==== | ||
This section contains an array of input and output parameter entries. Similarly to the immediate parameters section, the section begins with u32 relative offsets to the first entry of each data type. However, instead of six offsets, there are 12 - two for each data type (one input, one output). The order of parameters in this section is int input, int output, bool input, bool output, float intput, float output, string input, string output, vector3f input, vector3f output, pointer input, and pointer output. | |||
{| class="wikitable" | |||
|+Input Parameter Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|u32 | |||
|Name Offset | |||
|- | |||
|0x04 | |||
|0x02 | |||
|s16 | |||
|Input Child Node Index / Multi-Parameter Array Base Index | |||
|- | |||
|0x06 | |||
|0x02 | |||
|s16 | |||
|Input/Output Source Node Index / Multi-Parameter Count | |||
|- | |||
|0x08 | |||
|0x04 | |||
|u32 | |||
|Flags | |||
|- | |||
|0x0C | |||
| | |||
| | |||
|Default Value | |||
|} | |||
The default value is an immediate value for the data type (excluding string which is a string offset and pointer which is always an empty four bytes). Pointer entries also have an additional u32 class name offset at offset 0x04, pushing the rest of the entry back by four bytes. If the input child node index is between -32768 and -100, it corresponds to a multi-parameter array index. The multi-parameter index can be calculated as follows: <code>MultiParamIndex = -100 - Index</code>. | |||
{| class="wikitable" | |||
|+Parameter Flags | |||
!Bits | |||
!Description | |||
|- | |||
|16 | |||
|Source Index | |||
|- | |||
|1 | |||
|Is Use Index | |||
|- | |||
|1 | |||
|Is Not Local Blackboard Index | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
|Is EXB Index | |||
|- | |||
|1 | |||
|Pulse Thread Local Storage | |||
|- | |||
|1 | |||
|Set Pointer Flag Bit Zero | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|} | |||
Each output parameter entry is four bytes. | |||
{| class="wikitable" | |||
|+Output Parameter Entry | |||
!Bits | |||
!Description | |||
|- | |||
|31 | |||
|Name Offset | |||
|- | |||
|1 | |||
|Set Pointer Flag Bit Zero | |||
|} | |||
==== Multi-Parameters ==== | ==== Multi-Parameters ==== | ||
This section contains entries specifying parameters that have multiple values and the sources of those values. Each entry is eight bytes. | |||
{| class="wikitable" | |||
|+Multi-Parameter Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x02 | |||
|u16 | |||
|Node Index | |||
|- | |||
|0x02 | |||
|0x02 | |||
|u16 | |||
|Input/Output Source Parameter Index | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Flags | |||
|} | |||
{| class="wikitable" | |||
|+Parameter Flags | |||
!Bits | |||
!Description | |||
|- | |||
|16 | |||
|Source Index | |||
|- | |||
|1 | |||
|Is Use Index | |||
|- | |||
|1 | |||
|Is Not Local Blackboard Index | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
| | |||
|- | |||
|1 | |||
|Is EXB Index | |||
|- | |||
|1 | |||
|Pulse Thread Local Storage | |||
|- | |||
|1 | |||
|Set Pointer Flag Bit Zero | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|- | |||
|2 | |||
| | |||
|} | |||
==== Resident Update Array ==== | ==== Resident Update Array ==== | ||
Line 1,035: | Line 1,428: | ||
==== Expression Binary Section ==== | ==== Expression Binary Section ==== | ||
The '''EXB''' ('''Ex'''pression '''B'''inary) section is a completely self-contained section that stores custom instructions for a simple command processor. These instructions are grouped into functions that can be called by nodes to perform calculations. | The '''EXB''' ('''Ex'''pression '''B'''inary) section is a completely self-contained section that stores custom instructions for a simple command processor. These instructions are grouped into functions that can be called by nodes to perform calculations. | ||
// TODO: finish | |||
==== Embedded AINB Files ==== | ==== Embedded AINB Files ==== |
edits