ZenGin Script Binaries¶
Quick Infos
Type: Script Format
Format Name: DAT
File Extension: .DAT
Class Name: zCParser
Encoding: Binary
ZenGin DAT files contain symbols and bytecode used by the VM of the engine. DAT files are the result of Daedalus script compilation process.
Format Description¶
Compiled scripts are stored in a binary file which contains the following data. Also refer to the Datatype Reference for general information about often used datatypes.
DAT Structure
struct DatFile {
byte version;
uint symbolCount;
uint symbolIds[/* symbolCount */]; // (1)
zCPar_Symbol symbolTable[/* symbolCount */];
uint bytecodeSize;
byte bytecode[/* bytecodeSize */]; // (2)
};
- Symbol IDs sorted lexicographically
- Read bytecode page for more info about this data.
Symbol¶
struct zCPar_Symbol {
byte isNamed; // (1)
SymbolName name;
SymbolParameters params;
SymbolCodeSpan span;
SymbolData data;
int parent; // (2)
};
- Does this symbol have a name
- Parent type,
-1
meansNone
Symbol Name¶
Symbol Parameters¶
struct SymbolParameters {
int offset; // (1)
uint count: 12; // (2)
zPAR_TYPE type: 4;
zPAR_FLAG flags: 6;
uint space: 1;
uint reserved: 9;
};
enum zPAR_TYPE: uint {
VOID = 0,
FLOAT = 1,
INT = 2,
STRING = 3,
CLASS = 4,
FUNC = 5,
PROTOTYPE = 6,
INSTANCE = 7,
};
// Parameter bitflags
enum zPAR_FLAG: uint {
CONST = 1,
RETURN = 2,
CLASSVAR = 4,
EXTERNAL = 8,
MERGED = 16
};
- Depending on
type
either Offset (ClassVar), Size (Class) or ReturnType (Func) - How many sub items does this symbol have
Symbol Code Span¶
This is span debug information, pointing at the source daedalus script
struct SymbolCodeSpan {
uint fileIndex: 19;
uint reserved: 13;
uint lineStart: 19;
uint reserved: 13;
uint lineCount: 19;
uint reserved: 13;
uint charStart: 24; // (1)
uint reserved: 8;
uint charCount: 24; // (2)
uint reserved: 8;
};
- Points to a byte of a source code file at which the span starts
- Determines how many bytes does the span starting at
charStart
has
Symbol Data¶
This depends on params.flags
, if CLASSVAR
flag is set this data will always be 0 sized.
It also depends on params.type
of the symbol.
Warning
Some mods don't terminate those strings correctly, look at this code and the issue related to it.