File format details

Bin file format

Note that all 16 and 32 values below are little endian format.

The .bin files are structured as follows:

0x0000 to 0x00FF is the script name.
0x0100 is the length of op codes.
0x0104 is the start position of op codes.

0x0108 is the number of values.
0x010C is the base address.
0x0110 is the start position of values.


Notes: Base address is always 0x02F8 unless compiled with an old compiler like the debug scripts and refinery explosion and start of opcodes is always 0x0114.

0x0114 the op codes then follow.

0x{start of values} then the datatypes and initial variable values.

0x{after that} the static values assigned to variables.

Op codes for the VM

The Op codes are single byte codes that the VM runs are detailed below.
Push is followed by a 16 bit little endian address of a value or a function pointer.

0x01 OP_PUSH (value address or function pointer)
0x02 OP_GETTOP
0x03 OP_DISCARD
0x04 OP_PRINT
0x05 OP_JMP (offset to jump by)
0x06 OP_JMPF (offset to jump by)
0x07 OP_CONCAT
0x08 JUMPTARGET
0x09 OP_FUNCTION
0x0A OP_MINUS
0x0B OP_DIVIDE
0x0C OP_MULTIPLY
0x0D OP_LESS_THAN
0x0E OP_LESS_THAN_OR_EQUAL
0x0F OP_MORE_THAN
0x10 OP_MORE_THAN_OR_EQUAL
0x11 OP_NOT_EQUAL
0x12 OP_EQUAL
0x13 OP_NEG

0x15 OP_NOT
0x16 OP_AND
0x17 OP_OR

Value definitions

The values are defined in the file by a datatype and then a default value.

The data type is defined by a single byte as follows:
0x01 Float
0x02 Int
0x03 String
0x05 Character
0x07 Point
0x08 Quaternion


Character, String, Point and Quaternion are followed by a 32 bit address of a value.
What is at the address depends on data type:
For String the value is a 0x00 terminated string.
For Character there is a 32 bit value, then a 0x00 terminated string (name) then another 32 bit value.
For Point there are 3 32 bit values for x, y and z.
For Quaternion there are 4 32 bit values of the quaternion.

For Float and Int values the 32 bit value directly follows the datatype byte.

2 Character data type values are defined at the start of the values where the first is the Character that the script is active for ("Me") and the second is the player character ("Player").

No comments:

Post a comment