28
edits
(added all sections except exb) |
(added exb section) |
||
Line 1,427: | Line 1,427: | ||
==== 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. Because the section is self-contained, all offsets in this section are local to the section. The EXB section is shared with ASB files ('''A'''nimation '''S'''equence '''B'''inary). | ||
// | ===== Section Structure ===== | ||
EXB is essentially its own format and allows for the storage of custom functions in files. | |||
====== Section Order ====== | |||
# 0x2C-Byte Header | |||
# Command Info Table | |||
# Instructions Table | |||
# Parameter Region | |||
# Signature Table | |||
# String Pool | |||
===== Sub-Sections ===== | |||
====== Header ====== | |||
{| class="wikitable" | |||
|+EXB Header | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|char[4] | |||
|Magic - “EXB “ | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Version (0x02) | |||
|- | |||
|0x08 | |||
|0x04 | |||
|u32 | |||
|Static Memory Allocation Size | |||
|- | |||
|0x0C | |||
|0x04 | |||
|u32 | |||
|Parameter EXB Field Entry Count | |||
|- | |||
|0x10 | |||
|0x04 | |||
|u32 | |||
|32-bit Scratch Allocation Size | |||
|- | |||
|0x14 | |||
|0x04 | |||
|u32 | |||
|64-bit Scratch Allocation Size | |||
|- | |||
|0x18 | |||
|0x04 | |||
|u32 | |||
|Command Info Offset | |||
|- | |||
|0x1C | |||
|0x04 | |||
|u32 | |||
|Command Table Offset | |||
|- | |||
|0x20 | |||
|0x04 | |||
|u32 | |||
|Signature Table Offset | |||
|- | |||
|0x24 | |||
|0x04 | |||
|u32 | |||
|Parameter Region Offset | |||
|- | |||
|0x28 | |||
|0x04 | |||
|u32 | |||
|String Pool Offset | |||
|} | |||
====== Command Info Table ====== | |||
This section contains an array of command (function) info entries. The first four bytes specify the entry count. | |||
{| class="wikitable" | |||
|+Command Info Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x04 | |||
|s32 | |||
|Base Index Pre-Command Entry | |||
|- | |||
|0x04 | |||
|0x04 | |||
|u32 | |||
|Pre-Entry Static Memory Usage | |||
|- | |||
|0x08 | |||
|0x04 | |||
|u32 | |||
|Instruction Base Index | |||
|- | |||
|0x0C | |||
|0x04 | |||
|u32 | |||
|Instruction Count | |||
|- | |||
|0x10 | |||
|0x04 | |||
|u32 | |||
|Static Memory Size | |||
|- | |||
|0x14 | |||
|0x02 | |||
|u16 | |||
|32-bit Scratch Memory Size | |||
|- | |||
|0x16 | |||
|0x02 | |||
|u16 | |||
|64-bit Scratch Memory Size | |||
|- | |||
|0x18 | |||
|0x02 | |||
|u16 | |||
|Output Data Type Enum | |||
|- | |||
|0x1A | |||
|0x02 | |||
|u16 | |||
|Input Data Type Enum | |||
|} | |||
{| class="wikitable" | |||
|+Data Type Enum | |||
!Value (Hex) | |||
!Value (Dec) | |||
!Data Type | |||
|- | |||
|0x0 | |||
|0 | |||
|No Data | |||
|- | |||
|0x1 | |||
|1 | |||
|Immediate Value/From User | |||
|- | |||
|0x02 | |||
|2 | |||
|bool | |||
|- | |||
|0x03 | |||
|3 | |||
|int | |||
|- | |||
|0x04 | |||
|4 | |||
|float | |||
|- | |||
|0x05 | |||
|5 | |||
|string | |||
|- | |||
|0x06 | |||
|6 | |||
|vector3f | |||
|} | |||
====== Instructions Table ====== | |||
This section contains an array of instruction entries which are read by the EXB command processor. The first four bytes specify the entry count. | |||
{| class="wikitable" | |||
|+Instruction Entry | |||
!Offset | |||
!Size | |||
!Type | |||
!Description | |||
|- | |||
|0x00 | |||
|0x01 | |||
|u8 | |||
|Instruction Type | |||
|- | |||
|0x01 | |||
|0x01 | |||
|u8 | |||
|Data Type Enum | |||
|- | |||
|0x02 | |||
|0x01 | |||
|u8 | |||
|Left-Hand Side Parameter Source Enum | |||
|- | |||
|0x03 | |||
|0x01 | |||
|u8 | |||
|Right-Hand Side Parameter Source Enum | |||
|- | |||
|0x04 | |||
|0x02 | |||
|u16 | |||
|Left-Hand Side Parameter Value | |||
|- | |||
|0x06 | |||
|0x02 | |||
|u16 | |||
|Right-Hand Side Parameter Value | |||
|} | |||
For UserDefined type instructions, the bytes at offset 0x02-0x04 become a u16 static memory index and the bytes at 0x04-0x08 become a u32 index into the function signatures table. | |||
{| class="wikitable" | |||
|+Instruction Types | |||
!Value (Hex) | |||
!Value (Dec) | |||
!Instruction Type | |||
|- | |||
|0x01 | |||
|1 | |||
|Terminator | |||
|- | |||
|0x02 | |||
|2 | |||
|Store | |||
|- | |||
|0x03 | |||
|3 | |||
|Negate | |||
|- | |||
|0x04 | |||
|4 | |||
|NegateBool | |||
|- | |||
|0x05 | |||
|5 | |||
|Add | |||
|- | |||
|0x06 | |||
|6 | |||
|Subtract | |||
|- | |||
|0x07 | |||
|7 | |||
|Multiply | |||
|- | |||
|0x08 | |||
|8 | |||
|Divide | |||
|- | |||
|0x09 | |||
|9 | |||
|Modulus | |||
|- | |||
|0x0A | |||
|10 | |||
|Increment | |||
|- | |||
|0x0B | |||
|11 | |||
|Decrement | |||
|- | |||
|0x0C | |||
|12 | |||
|ScalarMultiplyVec3f | |||
|- | |||
|0x0D | |||
|13 | |||
|ScalarDivideVec3f | |||
|- | |||
|0x0E | |||
|14 | |||
|LeftShift | |||
|- | |||
|0x0F | |||
|15 | |||
|RightShift | |||
|- | |||
|0x10 | |||
|16 | |||
|LessThan | |||
|- | |||
|0x11 | |||
|17 | |||
|LessThanEqual | |||
|- | |||
|0x12 | |||
|18 | |||
|GreaterThan | |||
|- | |||
|0x13 | |||
|19 | |||
|GreaterThanEqual | |||
|- | |||
|0x14 | |||
|20 | |||
|Equal | |||
|- | |||
|0x15 | |||
|21 | |||
|NotEqual | |||
|- | |||
|0x16 | |||
|22 | |||
|AND | |||
|- | |||
|0x17 | |||
|23 | |||
|XOR | |||
|- | |||
|0x18 | |||
|24 | |||
|OR | |||
|- | |||
|0x19 | |||
|25 | |||
|LogicalAND | |||
|- | |||
|0x1A | |||
|26 | |||
|LogicalOR | |||
|- | |||
|0x1B | |||
|27 | |||
|UserFunction | |||
|- | |||
|0x1C | |||
|28 | |||
|JumpIfLHSZero | |||
|- | |||
|0x1D | |||
|29 | |||
|Jump | |||
|} | |||
UserFunctions are mapped to a function in the executable by function signature. There are two types of these functions: direct and object. Direct functions are straightforward functions that take up to two arguments and are matched using the function signature. Function objects can take additional arguments and are indexed at runtime. | |||
{| class="wikitable" | |||
|+Data Type Enum | |||
!Value (Hex) | |||
!Value (Dec) | |||
!Data Type | |||
|- | |||
|0x0 | |||
|0 | |||
|No Data | |||
|- | |||
|0x1 | |||
|1 | |||
|Immediate Value/From User | |||
|- | |||
|0x02 | |||
|2 | |||
|bool | |||
|- | |||
|0x03 | |||
|3 | |||
|int | |||
|- | |||
|0x04 | |||
|4 | |||
|float | |||
|- | |||
|0x05 | |||
|5 | |||
|string | |||
|- | |||
|0x06 | |||
|6 | |||
|vector3f | |||
|} | |||
{| class="wikitable" | |||
|+Parameter Source Enum | |||
!Value (Hex) | |||
!Value (Dec) | |||
!Parameter Source | |||
|- | |||
|0x00 | |||
|0 | |||
|Immediate Parameters | |||
|- | |||
|0x01 | |||
|1 | |||
|Immediate Parameters (String) | |||
|- | |||
|0x02 | |||
|2 | |||
|Static Memory | |||
|- | |||
|0x03 | |||
|3 | |||
|Parameters Region | |||
|- | |||
|0x04 | |||
|4 | |||
|Parameters Region (String) | |||
|- | |||
|0x05 | |||
|5 | |||
|Output Value | |||
|- | |||
|0x06 | |||
|6 | |||
|Input Value | |||
|- | |||
|0x07 | |||
|7 | |||
|32-bit Scratch | |||
|- | |||
|0x08 | |||
|8 | |||
|64-bit Scratch | |||
|- | |||
|0x09 | |||
|9 | |||
|UserOutput | |||
|- | |||
|0x0A | |||
|10 | |||
|UserInput | |||
|} | |||
UserCallback is a class that contains virtual functions providing memory allocation. The input value is passed from the calling node and the output value is passed back. | |||
====== Parameter Region ====== | |||
The parameter region is a region that stores the values for parameters values that are too large to fit into two bytes. Parameters that get their values from this section instead store an offset relative to the beginning of the parameter region to the start of the value. | |||
====== Signatures Table ====== | |||
This section is an array of u32 string offsets for each function signature. | |||
====== String Pool ====== | |||
The string pool is an array of null-terminated strings encoded with UTF-8. All string offsets in this section are relative to the beginning of the string pool. | |||
==== Embedded AINB Files ==== | ==== Embedded AINB Files ==== |
edits