public Bytecode(Reader reader) { int scriptCodePos = 0; int jumpTablePos = 0; // Bytecode for (int scriptCodeSize = reader.ReadInt32(); scriptCodeSize > 0;) { int buffer = reader.ReadByte(); int blockSize = buffer & 0x7F; if ((buffer & 0x80) == 0) { for (int i = 0; i < blockSize; i++) { scriptCode[scriptCodePos++] = reader.ReadByte(); } scriptCodeSize -= blockSize; } else { for (int i = 0; i < blockSize; i++) { scriptCode[scriptCodePos++] = reader.ReadInt32(); } scriptCodeSize -= blockSize; } } for (int jumpTableSize = reader.ReadInt32(); jumpTableSize > 0;) { int buffer = reader.ReadByte(); int blockSize = buffer & 0x7F; if ((buffer & 0x80) == 0) { for (int i = 0; i < blockSize; i++) { jumpTable[jumpTablePos++] = reader.ReadByte(); } jumpTableSize -= blockSize; } else { for (int i = 0; i < blockSize; i++) { jumpTable[jumpTablePos++] = reader.ReadInt32(); } jumpTableSize -= blockSize; } } // Scripts int scriptCount = reader.ReadInt16(); for (int i = 0; i < scriptCount; i++) { ScriptInfo info = new ScriptInfo(); info.scriptCodePos_main = reader.ReadInt32(); info.scriptCodePos_draw = reader.ReadInt32(); info.scriptCodePos_startup = reader.ReadInt32(); scripts.Add(info); } foreach (ScriptInfo info in scripts) { info.jumpTablePos_main = reader.ReadInt32(); info.jumpTablePos_draw = reader.ReadInt32(); info.jumpTablePos_startup = reader.ReadInt32(); } // Functions int functionCount = reader.ReadInt16(); for (int i = 0; i < functionCount; i++) { FunctionScript info = new FunctionScript(); info.scriptCodePos = reader.ReadInt32(); functionList.Add(info); } foreach (FunctionScript info in functionList) { info.jumpTablePos = reader.ReadInt32(); } scriptCodeLength = scriptCodePos; jumpTableLength = jumpTablePos; }