ECL Bytecode Format

Table of Contents

Back

This is how the ECL format is interpreted in KaECL. It may differ from the official implementation.

General Structure

The ECL bytecode is made up of 3 Sections:

Header

Section Size Notes
Magic 4 Contains "SCPT"
Unknown 2 Unknown
Include Size 2 Size of the Include Section
Include Offset 4 Absolute offset of the include Section
Zero 4  
Sub Count 4  
Zero* 16 See lower section

*In KaECL, this section is used for metadata:

Section Size Notes
Magic 4 Contains "KECL"
Version 2 Contains the game ID this script is made for. 0 for UniECL
Debug flag 2 Indicates the file contains debug information
Debug offset 4 If there is debug information, this points to the offset of the debug header
Unused 4 Reserved for future use

Include

ANMI

Defines the ANM files to use. File IDs start at 1.

Section Size Notes
Magic 4 Contains "ANMI"
Count 4  
Files - Zero-terminated list of Strings. Length is a multiple of 4.

ECLI

Defines the ECL files to use.

Section Size Notes
Magic 4 Contains "ECLI"
Count 4  
Files - Zero-terminated list of Strings. Length is a multiple of 4.

Code

Section Size Notes
Sub Offset 4 * Sub Count Absolute offset of the header for each sub.
Sub Names - Zero-Terminated list of Strings
Sub Headers -  

Sub Header

Section Size Notes
Magic 4 Contains "ECLH"
Data Offset 4 Relative offset from the Sub Header to Sub Data.
Zero 8  

Sub data starts at the offset and contains a list of instructions:

Section Size Notes
Time 4 Time at which the instruction should be executed.
ID 2 Instruction ID
Size 2 Instruction size (header + parameters)
Parameter Mask 2 Binary switch that indicates the use of a variable as a parameter
Rank Mask 1 Instruction will be ignored if the mask does not match the rank
Parameter Count 1  
Zero 4  
Parameters - Parameters have different sizes depending on their type.
  • Parameter Types
    • (S)

      Integer type of size 4

    • (f)

      Floating point type of size 4

    • (m)

      String, The format is as follows:

      Section Size Notes
      Size 4 Size of the string
      String - Zero-Terminated string
  • Variable Types and using Variables as Arguments

    There are 3 Types of Variables:

    Type Range Description
    Local >= 1 Variables local to a Sub. IDs are an exponent of 2 (1, 2, 4, …)
    Global (-8000) - (-10000) Variables local either to the game or an entity.
    Stack (-1) - (-10) The result of the last 10 pushes to stack. The stack only saves up to 10 Results and is Global to the Game

    To use a Variable you have to set the Param Mask and then pass the Variable ID in the correct Format for the Argument (either as an Integer or a floating point number).

Last Update: 2019-03-27 Mi 04:04

Validate