Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Changes in the new GameMaker: Studio bytecode format (0x0F)

THIS IS OUTDATED, USE THE DOCUMENT HERE INSTEAD!

Changes in the new GameMaker: Studio bytecode format (0x0F)

An implementation can be found here.

New ReferenceDef format

NOTE: Builds on Mirrawrs' documentation/this page on the Acolyte wiki and my correction/completion.

VariableDefinition (array in the VARI chunk, read to end)

uint NameOffset;
uint _pad0; // unknown, some flags?
uint _pad1; // unknown
uint Occurrences;
uint FirstAddress; // probably

FUNC : ListChunk<FunctionDefinition>

//NOTE: The lenght of the array is included in the chunk.
uint NameOffset;
uint Occurrences;
uint FirstAddress;

New CodeEntry format

CODE : ListChunk<CodeEntry>

uint Name;
uint Length;
uint Unknown; // seems to be '1' (always)
int BytecodeOffset; // offset to the code's bytecode, RELATIVE TO THIS VALUE (i.e. reinterpret_cast<byte*>(&codeEntry->BytecodeOffset) + codeEntry->BytecodeOffset)
uint Unknown; // seems to be '0' (always)

New Bytecode format

ComparisonType

The ComparisonType is the third byte of a DoubleTypeInstruction, only used when the OpCode is Cmp.

LowerThan   = 1, // <
LTOrEqual   = 2, // <=
Equality    = 3, // ==
Inequality  = 4, // !=
GTOrEqual   = 5, // >=
GreaterThan = 6  // >

OpCodes

Conv    = 0x07,
Mul     = 0x08,
Div     = 0x09,
Rem     = 0x0A,
Mod     = 0x0B,
Add     = 0x0C,
Sub     = 0x0D,
And     = 0x0E,
Or      = 0x0F,
Xor     = 0x10,
Neg     = 0x11,
Not     = 0x12,
Shl     = 0x13,
Shr     = 0x14,
Cmp     = 0x15, // the third byte of the DoubleTypeInstruction holds the comparison type
Set     = 0x45,
Dup     = 0x86,
Ret     = 0x9C,
Exit    = 0x9D,
Pop     = 0x9E,
Br      = 0xB6,
Brt     = 0xB7,
Brf     = 0xB8,
PushEnv = 0xBA,
PopEnv  = 0xBB,
PushCst = 0xC0, // push constant
PushGlb = 0xC2, // push global variable
PushVar = 0xC3, // push other variable
PushI16 = 0x84, // push int16
                // NOTE: the push type is preserved from the previous version, so the program can check for any of these values
                //       instead of every kind separate and then checking the actual type
Call    = 0xD9,
Break   = 0xFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.