887 lines
34 KiB
JavaScript
887 lines
34 KiB
JavaScript
'use strict';
|
|
|
|
// ─── Bytecode action opcodes (hex values) ───
|
|
const ACTION_END = 0x00;
|
|
const ACTION_NEXTFRAME = 0x04;
|
|
const ACTION_PREVFRAME = 0x05;
|
|
const ACTION_PLAY = 0x06;
|
|
const ACTION_STOP = 0x07;
|
|
const ACTION_TOGGLEQUALITY = 0x08;
|
|
const ACTION_STOPSOUNDS = 0x09;
|
|
const ACTION_ADD = 0x0A;
|
|
const ACTION_SUBTRACT = 0x0B;
|
|
const ACTION_MULTIPLY = 0x0C;
|
|
const ACTION_DIVIDE = 0x0D;
|
|
const ACTION_EQUAL = 0x0E;
|
|
const ACTION_LESSTHAN = 0x0F;
|
|
const ACTION_LOGICALAND = 0x10;
|
|
const ACTION_LOGICALOR = 0x11;
|
|
const ACTION_LOGICALNOT = 0x12;
|
|
const ACTION_STRINGEQ = 0x13;
|
|
const ACTION_STRINGLENGTH = 0x14;
|
|
const ACTION_SUBSTRING = 0x15;
|
|
const ACTION_POP = 0x17;
|
|
const ACTION_INT = 0x18;
|
|
const ACTION_GETVARIABLE = 0x1C;
|
|
const ACTION_SETVARIABLE = 0x1D;
|
|
const ACTION_SETTARGETEXPRESSION = 0x20;
|
|
const ACTION_STRINGCONCAT = 0x21;
|
|
const ACTION_GETPROPERTY = 0x22;
|
|
const ACTION_SETPROPERTY = 0x23;
|
|
const ACTION_DUPLICATECLIP = 0x24;
|
|
const ACTION_REMOVECLIP = 0x25;
|
|
const ACTION_TRACE = 0x26;
|
|
const ACTION_STARTDRAGMOVIE = 0x27;
|
|
const ACTION_STOPDRAGMOVIE = 0x28;
|
|
const ACTION_STRINGCOMPARE = 0x29;
|
|
const ACTION_THROW = 0x2A;
|
|
const ACTION_CASTOP = 0x2B;
|
|
const ACTION_IMPLEMENTSOP = 0x2C;
|
|
const ACTION_RANDOM = 0x30;
|
|
const ACTION_MBLENGTH = 0x31;
|
|
const ACTION_ORD = 0x32;
|
|
const ACTION_CHR = 0x33;
|
|
const ACTION_GETTIMER = 0x34;
|
|
const ACTION_MBSUBSTRING = 0x35;
|
|
const ACTION_MBORD = 0x36;
|
|
const ACTION_MBCHR = 0x37;
|
|
const ACTION_DELETE = 0x3A;
|
|
const ACTION_DELETE2 = 0x3B;
|
|
const ACTION_DEFINELOCAL = 0x3C;
|
|
const ACTION_CALLFUNCTION = 0x3D;
|
|
const ACTION_RETURN = 0x3E;
|
|
const ACTION_MODULO = 0x3F;
|
|
const ACTION_NEW = 0x40;
|
|
const ACTION_VAR = 0x41;
|
|
const ACTION_INITARRAY = 0x42;
|
|
const ACTION_INITOBJECT = 0x43;
|
|
const ACTION_TYPEOF = 0x44;
|
|
const ACTION_TARGETPATH = 0x45;
|
|
const ACTION_ENUMERATE = 0x46;
|
|
const ACTION_NEWADD = 0x47;
|
|
const ACTION_NEWLESSTHAN = 0x48;
|
|
const ACTION_NEWEQUALS = 0x49;
|
|
const ACTION_TONUMBER = 0x4A;
|
|
const ACTION_TOSTRING = 0x4B;
|
|
const ACTION_DUP = 0x4C;
|
|
const ACTION_SWAP = 0x4D;
|
|
const ACTION_GETMEMBER = 0x4E;
|
|
const ACTION_SETMEMBER = 0x4F;
|
|
const ACTION_INCREMENT = 0x50;
|
|
const ACTION_DECREMENT = 0x51;
|
|
const ACTION_CALLMETHOD = 0x52;
|
|
const ACTION_NEWMETHOD = 0x53;
|
|
const ACTION_INSTANCEOF = 0x54;
|
|
const ACTION_ENUM2 = 0x55;
|
|
const ACTION_BITWISEAND = 0x60;
|
|
const ACTION_BITWISEOR = 0x61;
|
|
const ACTION_BITWISEXOR = 0x62;
|
|
const ACTION_SHIFTLEFT = 0x63;
|
|
const ACTION_SHIFTRIGHT = 0x64;
|
|
const ACTION_SHIFTRIGHT2 = 0x65;
|
|
const ACTION_STRICTEQ = 0x66;
|
|
const ACTION_GREATER = 0x67;
|
|
const ACTION_STRINGGREATER = 0x68;
|
|
const ACTION_EXTENDS = 0x69;
|
|
const ACTION_WAITFORFRAME = 0x8A;
|
|
const ACTION_WAITFORFRAMEEXPRESSION = 0x8D;
|
|
const ACTION_SETREGISTER = 0x87;
|
|
const ACTION_CONSTANTPOOL = 0x88;
|
|
const ACTION_PUSHDATA = 0x96;
|
|
const ACTION_BRANCHALWAYS = 0x99;
|
|
const ACTION_GETURL2 = 0x9A;
|
|
const ACTION_DEFINEFUNCTION = 0x9B;
|
|
const ACTION_BRANCHIFTRUE = 0x9D;
|
|
const ACTION_CALLFRAME = 0x9E;
|
|
const ACTION_GOTOEXPRESSION = 0x9F;
|
|
const ACTION_GOTOFRAME = 0x81;
|
|
const ACTION_GETURL = 0x83;
|
|
const ACTION_SETTARGET = 0x8B;
|
|
const ACTION_GOTOLABEL = 0x8C;
|
|
const ACTION_DEFINEFUNCTION2 = 0x8E;
|
|
const ACTION_TRY = 0x8F;
|
|
const ACTION_WITH = 0x94;
|
|
|
|
// EA-specific opcodes
|
|
const EA_ACTION56 = 0x56;
|
|
const EA_ACTION58 = 0x58;
|
|
const EA_PUSHZERO = 0x59;
|
|
const EA_PUSHONE = 0x5A;
|
|
const EA_CALLFUNCTIONPOP = 0x5B;
|
|
const EA_CALLFUNCTION = 0x5C;
|
|
const EA_CALLMETHODPOP = 0x5D;
|
|
const EA_CALLMETHOD = 0x5E;
|
|
const EA_PUSHTHIS = 0x70;
|
|
const EA_PUSHGLOBAL = 0x71;
|
|
const EA_ZEROVARIABLE = 0x72;
|
|
const EA_PUSHTRUE = 0x73;
|
|
const EA_PUSHFALSE = 0x74;
|
|
const EA_PUSHNULL = 0x75;
|
|
const EA_PUSHUNDEFINED = 0x76;
|
|
const EA_ACTION77 = 0x77;
|
|
const EA_PUSHSTRING = 0xA1;
|
|
const EA_PUSHCONSTANT = 0xA2;
|
|
const EA_PUSHWORDCONSTANT = 0xA3;
|
|
const EA_GETSTRINGVAR = 0xA4;
|
|
const EA_GETSTRINGMEMBER = 0xA5;
|
|
const EA_SETSTRINGVAR = 0xA6;
|
|
const EA_SETSTRINGMEMBER = 0xA7;
|
|
const EA_PUSHVALUEOFVAR = 0xAE;
|
|
const EA_GETNAMEDMEMBER = 0xAF;
|
|
const EA_CALLNAMEDFUNCTIONPOP = 0xB0;
|
|
const EA_CALLNAMEDFUNCTION = 0xB1;
|
|
const EA_CALLNAMEDMETHODPOP = 0xB2;
|
|
const EA_CALLNAMEDMETHOD = 0xB3;
|
|
const EA_PUSHFLOAT = 0xB4;
|
|
const EA_PUSHBYTE = 0xB5;
|
|
const EA_PUSHSHORT = 0xB6;
|
|
const EA_PUSHLONG = 0xB7;
|
|
const EA_BRANCHIFFALSE = 0xB8;
|
|
const EA_PUSHREGISTER = 0xB9;
|
|
|
|
// ─── Flag enums ───
|
|
|
|
const PlaceObjectFlags = {
|
|
Move: 1,
|
|
HasCharacter: 2,
|
|
HasMatrix: 4,
|
|
HasColorTransform: 8,
|
|
HasRatio: 16,
|
|
HasName: 32,
|
|
HasClipDepth: 64,
|
|
HasClipAction: 128
|
|
};
|
|
|
|
const ClipEventFlags = {
|
|
KeyUp: 0x800000,
|
|
KeyDown: 0x400000,
|
|
MouseUp: 0x200000,
|
|
MouseDown: 0x100000,
|
|
MouseMove: 0x080000,
|
|
Unload: 0x040000,
|
|
EnterFrame: 0x020000,
|
|
Load: 0x010000,
|
|
DragOver: 0x008000,
|
|
RollOut: 0x004000,
|
|
RollOver: 0x002000,
|
|
ReleaseOutside: 0x001000,
|
|
Release: 0x000800,
|
|
Press: 0x000400,
|
|
DragOut: 0x000200,
|
|
Data: 0x000100,
|
|
Construct: 0x000004,
|
|
KeyPress: 0x000002,
|
|
Initialize: 0x000001
|
|
};
|
|
|
|
const ButtonRecordFlags = {
|
|
None: 0,
|
|
StateUp: 1,
|
|
StateOver: 2,
|
|
StateDown: 4,
|
|
StateHit: 8
|
|
};
|
|
|
|
const ButtonActionFlags = {
|
|
IdleToOverUp: 1,
|
|
OverUpToIdle: 2,
|
|
OverUpToOverDown: 4,
|
|
OverDownToOverUp: 8,
|
|
OverDownToOutDown: 16,
|
|
OutDownToOverDown: 32,
|
|
IdleToOverDown: 128,
|
|
OverDownToIdle: 256
|
|
};
|
|
|
|
const ButtonInput = {
|
|
MouseButton0: 0,
|
|
Left: 1,
|
|
Right: 2,
|
|
Home: 3,
|
|
End: 4,
|
|
Insert: 5,
|
|
Delete: 6,
|
|
BackSpace: 8,
|
|
Enter: 13,
|
|
Unknown: 240
|
|
};
|
|
|
|
const FunctionPreloadFlags = {
|
|
PreloadExtern: 0x010000,
|
|
PreloadParent: 0x008000,
|
|
PreloadRoot: 0x004000,
|
|
SupressSuper: 0x002000,
|
|
PreloadSuper: 0x001000,
|
|
SupressArguments: 0x000800,
|
|
PreloadArguments: 0x000400,
|
|
SupressThis: 0x000200,
|
|
PreloadThis: 0x000100,
|
|
PreloadGlobal: 0x000001
|
|
};
|
|
|
|
// ─── Action name tables ───
|
|
// New/shorter style names (default)
|
|
const ActionNames = [
|
|
"actionEnd", // 0x00
|
|
"", // 0x01
|
|
"", // 0x02
|
|
"", // 0x03
|
|
"ActionNextFrame", // 0x04
|
|
"ActionPrevFrame", // 0x05
|
|
"play", // 0x06
|
|
"stop", // 0x07
|
|
"ActionToggleQuality", // 0x08
|
|
"ActionStopSounds", // 0x09
|
|
"ActionAdd", // 0x0A
|
|
"ActionSubtract", // 0x0B
|
|
"ActionMultiply", // 0x0C
|
|
"ActionDivide", // 0x0D
|
|
"ActionEqual", // 0x0E
|
|
"ActionLessThan", // 0x0F
|
|
"ActionLogicalAnd", // 0x10
|
|
"ActionLogicalOr", // 0x11
|
|
"ActionLogicalNot", // 0x12
|
|
"ActionStringEq", // 0x13
|
|
"ActionStringLength", // 0x14
|
|
"ActionSubString", // 0x15
|
|
"", // 0x16
|
|
"ActionPop", // 0x17
|
|
"ActionInt", // 0x18
|
|
"", // 0x19
|
|
"", // 0x1A
|
|
"", // 0x1B
|
|
"ActionGetVariable", // 0x1C
|
|
"ActionSetVariable", // 0x1D
|
|
"", // 0x1E
|
|
"", // 0x1F
|
|
"ActionSetTargetExpression", // 0x20
|
|
"ActionStringConcat", // 0x21
|
|
"ActionGetProperty", // 0x22
|
|
"ActionSetProperty", // 0x23
|
|
"ActionDuplicateClip", // 0x24
|
|
"ActionRemoveClip", // 0x25
|
|
"ActionTrace", // 0x26
|
|
"ActionStartDrag", // 0x27
|
|
"ActionStopDrag", // 0x28
|
|
"ActionStringCompare", // 0x29
|
|
"ActionThrow", // 0x2A
|
|
"ActionCastOp", // 0x2B
|
|
"ActionImplementsOp", // 0x2C
|
|
"", // 0x2D
|
|
"", // 0x2E
|
|
"", // 0x2F
|
|
"ActionRandom", // 0x30
|
|
"ActionMBLength", // 0x31
|
|
"ActionOrd", // 0x32
|
|
"ActionChr", // 0x33
|
|
"ActionGetTimer", // 0x34
|
|
"ActionMBSubString", // 0x35
|
|
"ActionMBOrd", // 0x36
|
|
"ActionMBChr", // 0x37
|
|
"", // 0x38
|
|
"", // 0x39
|
|
"ActionDelete", // 0x3A
|
|
"ActionDelete2", // 0x3B
|
|
"ActionDefineLocal", // 0x3C
|
|
"ActionCallFunction", // 0x3D
|
|
"ActionReturn", // 0x3E
|
|
"ActionModulo", // 0x3F
|
|
"ActionNew", // 0x40
|
|
"ActionVar", // 0x41
|
|
"ActionInitArray", // 0x42
|
|
"ActionInitObject", // 0x43
|
|
"ActionTypeOf", // 0x44
|
|
"ActionTargetPath", // 0x45
|
|
"ActionEnumerate", // 0x46
|
|
"ActionNewAdd", // 0x47
|
|
"ActionNewLessThan", // 0x48
|
|
"ActionNewEquals", // 0x49
|
|
"ActionToNumber", // 0x4A
|
|
"ActionToString", // 0x4B
|
|
"ActionDup", // 0x4C
|
|
"ActionSwap", // 0x4D
|
|
"ActionGetMember", // 0x4E
|
|
"ActionSetMember", // 0x4F
|
|
"ActionIncrement", // 0x50
|
|
"ActionDecrement", // 0x51
|
|
"ActionCallMethod", // 0x52
|
|
"ActionNewMethod", // 0x53
|
|
"ActionInstanceOf", // 0x54
|
|
"ActionEnum2", // 0x55
|
|
"EAUnknownAction56", // 0x56
|
|
"", // 0x57
|
|
"EAUnknownAction58", // 0x58
|
|
"EAPushZero", // 0x59
|
|
"EAPushOne", // 0x5A
|
|
"EACallFunctionPop", // 0x5B
|
|
"callset", // 0x5C
|
|
"callmethodpop", // 0x5D
|
|
"callmethodset", // 0x5E
|
|
"", // 0x5F
|
|
"bitand", // 0x60
|
|
"bitor", // 0x61
|
|
"xor", // 0x62
|
|
"lsh", // 0x63
|
|
"rsh", // 0x64
|
|
"unsignedrsh", // 0x65
|
|
"stricteq", // 0x66
|
|
"gt", // 0x67
|
|
"strgt", // 0x68
|
|
"extends", // 0x69
|
|
"", // 0x6A
|
|
"", // 0x6B
|
|
"", // 0x6C
|
|
"", // 0x6D
|
|
"", // 0x6E
|
|
"", // 0x6F
|
|
"pushthis", // 0x70
|
|
"pushglobal", // 0x71
|
|
"zerovar", // 0x72
|
|
"pushtrue", // 0x73
|
|
"pushfalse", // 0x74
|
|
"pushnull", // 0x75
|
|
"pushundefined", // 0x76
|
|
"", // 0x77
|
|
"", // 0x78
|
|
"", // 0x79
|
|
"", // 0x7A
|
|
"", // 0x7B
|
|
"", // 0x7C
|
|
"", // 0x7D
|
|
"", // 0x7E
|
|
"", // 0x7F
|
|
"", // 0x80
|
|
"gotoframe", // 0x81
|
|
"", // 0x82
|
|
"geturl", // 0x83
|
|
"", // 0x84
|
|
"", // 0x85
|
|
"", // 0x86
|
|
"setreg", // 0x87
|
|
"ActionConstantPool", // 0x88
|
|
"", // 0x89
|
|
"waitforframe", // 0x8A
|
|
"settarget", // 0x8B
|
|
"gotolabel", // 0x8C
|
|
"waitforframeexpr", // 0x8D
|
|
"ActionDefineFunction2", // 0x8E
|
|
"try", // 0x8F
|
|
"", // 0x90
|
|
"", // 0x91
|
|
"", // 0x92
|
|
"", // 0x93
|
|
"with", // 0x94
|
|
"", // 0x95
|
|
"pushdata", // 0x96
|
|
"", // 0x97
|
|
"", // 0x98
|
|
"jump", // 0x99
|
|
"geturl2", // 0x9A
|
|
"ActionDefineFunction", // 0x9B
|
|
"", // 0x9C
|
|
"jumptrue", // 0x9D
|
|
"callframe", // 0x9E
|
|
"gotoexpr", // 0x9F
|
|
"", // 0xA0
|
|
"pushstr", // 0xA1
|
|
"pushconst", // 0xA2
|
|
"pushwconst", // 0xA3
|
|
"getstrvar", // 0xA4
|
|
"getstrmember", // 0xA5
|
|
"setstrvar", // 0xA6
|
|
"setstrmember", // 0xA7
|
|
"", // 0xA8
|
|
"", // 0xA9
|
|
"", // 0xAA
|
|
"", // 0xAB
|
|
"", // 0xAC
|
|
"", // 0xAD
|
|
"pushvar", // 0xAE
|
|
"getnamedmember", // 0xAF
|
|
"callnamedpop", // 0xB0
|
|
"callnamedset", // 0xB1
|
|
"callnamedmethodpop", // 0xB2
|
|
"callnamedmethodset", // 0xB3
|
|
"pushfloat", // 0xB4
|
|
"pushbyte", // 0xB5
|
|
"pushshort", // 0xB6
|
|
"pushlong", // 0xB7
|
|
"jumpfalse", // 0xB8
|
|
"pushreg" // 0xB9
|
|
];
|
|
|
|
// Old/verbose style names
|
|
const ActionNames2 = [
|
|
"ActionEnd", // 0x00
|
|
"", // 0x01
|
|
"", // 0x02
|
|
"", // 0x03
|
|
"ActionNextFrame", // 0x04
|
|
"ActionPrevFrame", // 0x05
|
|
"ActionPlay", // 0x06
|
|
"ActionStop", // 0x07
|
|
"ActionToggleQuality", // 0x08
|
|
"ActionStopSounds", // 0x09
|
|
"ActionAdd", // 0x0A
|
|
"ActionSubtract", // 0x0B
|
|
"ActionMultiply", // 0x0C
|
|
"ActionDivide", // 0x0D
|
|
"ActionEqual", // 0x0E
|
|
"ActionLessThan", // 0x0F
|
|
"ActionLogicalAnd", // 0x10
|
|
"ActionLogicalOr", // 0x11
|
|
"ActionLogicalNot", // 0x12
|
|
"ActionStringEq", // 0x13
|
|
"ActionStringLength", // 0x14
|
|
"ActionSubString", // 0x15
|
|
"", // 0x16
|
|
"ActionPop", // 0x17
|
|
"ActionInt", // 0x18
|
|
"", // 0x19
|
|
"", // 0x1A
|
|
"", // 0x1B
|
|
"ActionGetVariable", // 0x1C
|
|
"ActionSetVariable", // 0x1D
|
|
"", // 0x1E
|
|
"", // 0x1F
|
|
"ActionSetTargetExpression", // 0x20
|
|
"ActionStringConcat", // 0x21
|
|
"ActionGetProperty", // 0x22
|
|
"ActionSetProperty", // 0x23
|
|
"ActionDuplicateClip", // 0x24
|
|
"ActionRemoveClip", // 0x25
|
|
"ActionTrace", // 0x26
|
|
"ActionStartDrag", // 0x27
|
|
"ActionStopDrag", // 0x28
|
|
"ActionStringCompare", // 0x29
|
|
"ActionThrow", // 0x2A
|
|
"ActionCastOp", // 0x2B
|
|
"ActionImplementsOp", // 0x2C
|
|
"", // 0x2D
|
|
"", // 0x2E
|
|
"", // 0x2F
|
|
"ActionRandom", // 0x30
|
|
"ActionMBLength", // 0x31
|
|
"ActionOrd", // 0x32
|
|
"ActionChr", // 0x33
|
|
"ActionGetTimer", // 0x34
|
|
"ActionMBSubString", // 0x35
|
|
"ActionMBOrd", // 0x36
|
|
"ActionMBChr", // 0x37
|
|
"", // 0x38
|
|
"", // 0x39
|
|
"ActionDelete", // 0x3A
|
|
"ActionDelete2", // 0x3B
|
|
"ActionDefineLocal", // 0x3C
|
|
"ActionCallFunction", // 0x3D
|
|
"ActionReturn", // 0x3E
|
|
"ActionModulo", // 0x3F
|
|
"ActionNew", // 0x40
|
|
"ActionVar", // 0x41
|
|
"ActionInitArray", // 0x42
|
|
"ActionInitObject", // 0x43
|
|
"ActionTypeOf", // 0x44
|
|
"ActionTargetPath", // 0x45
|
|
"ActionEnumerate", // 0x46
|
|
"ActionNewAdd", // 0x47
|
|
"ActionNewLessThan", // 0x48
|
|
"ActionNewEquals", // 0x49
|
|
"ActionToNumber", // 0x4A
|
|
"ActionToString", // 0x4B
|
|
"ActionDup", // 0x4C
|
|
"ActionSwap", // 0x4D
|
|
"ActionGetMember", // 0x4E
|
|
"ActionSetMember", // 0x4F
|
|
"ActionIncrement", // 0x50
|
|
"ActionDecrement", // 0x51
|
|
"ActionCallMethod", // 0x52
|
|
"ActionNewMethod", // 0x53
|
|
"ActionInstanceOf", // 0x54
|
|
"ActionEnum2", // 0x55
|
|
"EAUnknownAction56", // 0x56
|
|
"", // 0x57
|
|
"EAUnknownAction58", // 0x58
|
|
"EAPushZero", // 0x59
|
|
"EAPushOne", // 0x5A
|
|
"EACallFunctionPop", // 0x5B
|
|
"EACallFunction", // 0x5C
|
|
"EACAllMethodPop", // 0x5D
|
|
"EACallMethod", // 0x5E
|
|
"", // 0x5F
|
|
"ActionBitwiseAnd", // 0x60
|
|
"ActionBitwiseOr", // 0x61
|
|
"ActionBitwiseXor", // 0x62
|
|
"ActionShiftLeft", // 0x63
|
|
"ActionShiftRight", // 0x64
|
|
"ActionShiftRight2", // 0x65
|
|
"ActionStrictEq", // 0x66
|
|
"ActionGreater", // 0x67
|
|
"ActionStringGreater", // 0x68
|
|
"ActionExtends", // 0x69
|
|
"", // 0x6A
|
|
"", // 0x6B
|
|
"", // 0x6C
|
|
"", // 0x6D
|
|
"", // 0x6E
|
|
"", // 0x6F
|
|
"EAPushThis", // 0x70
|
|
"EAPushGlobal", // 0x71
|
|
"EAZeroVariable", // 0x72
|
|
"EAPushTrue", // 0x73
|
|
"EAPushFalse", // 0x74
|
|
"EAPushNull", // 0x75
|
|
"EAPushUndefined", // 0x76
|
|
"", // 0x77
|
|
"", // 0x78
|
|
"", // 0x79
|
|
"", // 0x7A
|
|
"", // 0x7B
|
|
"", // 0x7C
|
|
"", // 0x7D
|
|
"", // 0x7E
|
|
"", // 0x7F
|
|
"", // 0x80
|
|
"ActionGotoFrame", // 0x81
|
|
"", // 0x82
|
|
"ActionGetURL", // 0x83
|
|
"", // 0x84
|
|
"", // 0x85
|
|
"", // 0x86
|
|
"ActionSetRegister", // 0x87
|
|
"ActionConstantPool", // 0x88
|
|
"", // 0x89
|
|
"ActionWaitForFrame", // 0x8A
|
|
"ActionSetTarget", // 0x8B
|
|
"ActionGotoLabel", // 0x8C
|
|
"ActionWaitForFrameExpression", // 0x8D
|
|
"ActionDefineFunction2", // 0x8E
|
|
"ActionTry", // 0x8F
|
|
"", // 0x90
|
|
"", // 0x91
|
|
"", // 0x92
|
|
"", // 0x93
|
|
"ActionWith", // 0x94
|
|
"", // 0x95
|
|
"ActionPushData", // 0x96
|
|
"", // 0x97
|
|
"", // 0x98
|
|
"ActionBranchAlways", // 0x99
|
|
"ActionGetURL2", // 0x9A
|
|
"ActionDefineFunction", // 0x9B
|
|
"", // 0x9C
|
|
"ActionBranchIfTrue", // 0x9D
|
|
"ActionCallFrame", // 0x9E
|
|
"ActionGotoExpression", // 0x9F
|
|
"", // 0xA0
|
|
"EAPushString", // 0xA1
|
|
"EAPushConstant", // 0xA2
|
|
"EAPushWordConstant", // 0xA3
|
|
"EAGetStringVar", // 0xA4
|
|
"EAGetStringMember", // 0xA5
|
|
"EASetStringVar", // 0xA6
|
|
"EASetStringMember", // 0xA7
|
|
"", // 0xA8
|
|
"", // 0xA9
|
|
"", // 0xAA
|
|
"", // 0xAB
|
|
"", // 0xAC
|
|
"", // 0xAD
|
|
"EAPushValueOfVar", // 0xAE
|
|
"EAGetNamedMember", // 0xAF
|
|
"EACallNamedFunctionPop", // 0xB0
|
|
"EACallNamedFunction", // 0xB1
|
|
"EACallNamedMethodPop", // 0xB2
|
|
"EACallNamedMethod", // 0xB3
|
|
"EAPushFloat", // 0xB4
|
|
"EAPushByte", // 0xB5
|
|
"EAPushShort", // 0xB6
|
|
"EAPushLong", // 0xB7
|
|
"EABranchIfFalse", // 0xB8
|
|
"EAPushRegister" // 0xB9
|
|
];
|
|
|
|
// ─── Action alignment table ───
|
|
// 1 = this action's body needs alignment to 4-byte boundary
|
|
const ActionAligns = new Array(0xB9 + 1).fill(0);
|
|
ActionAligns[ACTION_BRANCHALWAYS] = 1;
|
|
ActionAligns[ACTION_BRANCHIFTRUE] = 1;
|
|
ActionAligns[EA_BRANCHIFFALSE] = 1;
|
|
ActionAligns[ACTION_GOTOFRAME] = 1;
|
|
ActionAligns[ACTION_SETREGISTER] = 1;
|
|
ActionAligns[ACTION_WITH] = 1;
|
|
ActionAligns[ACTION_GOTOEXPRESSION] = 1;
|
|
ActionAligns[ACTION_GETURL] = 1;
|
|
ActionAligns[ACTION_CONSTANTPOOL] = 1;
|
|
ActionAligns[ACTION_PUSHDATA] = 1;
|
|
ActionAligns[ACTION_DEFINEFUNCTION2] = 1;
|
|
ActionAligns[ACTION_DEFINEFUNCTION] = 1;
|
|
ActionAligns[EA_PUSHSTRING] = 1;
|
|
ActionAligns[EA_GETSTRINGVAR] = 1;
|
|
ActionAligns[EA_GETSTRINGMEMBER] = 1;
|
|
ActionAligns[EA_SETSTRINGVAR] = 1;
|
|
ActionAligns[EA_SETSTRINGMEMBER] = 1;
|
|
ActionAligns[ACTION_SETTARGET] = 1;
|
|
ActionAligns[ACTION_GOTOLABEL] = 1;
|
|
|
|
// ─── Action size table ───
|
|
// Fixed byte size of each action (0 = unknown/empty, 1 = no additional data)
|
|
const ActionSizes = [
|
|
1, // ActionEnd 0x00
|
|
0, // (empty) 0x01
|
|
0, // (empty) 0x02
|
|
0, // (empty) 0x03
|
|
1, // ActionNextFrame 0x04
|
|
1, // ActionPrevFrame 0x05
|
|
1, // ActionPlay 0x06
|
|
1, // ActionStop 0x07
|
|
1, // ActionToggleQuality 0x08
|
|
1, // ActionStopSounds 0x09
|
|
1, // ActionAdd 0x0A
|
|
1, // ActionSubtract 0x0B
|
|
1, // ActionMultiply 0x0C
|
|
1, // ActionDivide 0x0D
|
|
1, // ActionEqual 0x0E
|
|
1, // ActionLessThan 0x0F
|
|
1, // ActionLogicalAnd 0x10
|
|
1, // ActionLogicalOr 0x11
|
|
1, // ActionLogicalNot 0x12
|
|
1, // ActionStringEq 0x13
|
|
1, // ActionStringLength 0x14
|
|
1, // ActionSubString 0x15
|
|
0, // (empty) 0x16
|
|
1, // ActionPop 0x17
|
|
1, // ActionInt 0x18
|
|
0, // 0x19
|
|
0, // 0x1A
|
|
0, // 0x1B
|
|
1, // ActionGetVariable 0x1C
|
|
1, // ActionSetVariable 0x1D
|
|
0, // 0x1E
|
|
0, // 0x1F
|
|
1, // ActionSetTargetExpression 0x20
|
|
1, // ActionStringConcat 0x21
|
|
1, // ActionGetProperty 0x22
|
|
1, // ActionSetProperty 0x23
|
|
1, // ActionDuplicateClip 0x24
|
|
1, // ActionRemoveClip 0x25
|
|
1, // ActionTrace 0x26
|
|
1, // ActionStartDrag 0x27
|
|
1, // ActionStopDrag 0x28
|
|
1, // ActionStringCompare 0x29
|
|
1, // ActionThrow 0x2A
|
|
1, // ActionCastOp 0x2B
|
|
1, // ActionImplementsOp 0x2C
|
|
0, // 0x2D
|
|
0, // 0x2E
|
|
0, // 0x2F
|
|
1, // ActionRandom 0x30
|
|
1, // ActionMBLength 0x31
|
|
1, // ActionOrd 0x32
|
|
1, // ActionChr 0x33
|
|
1, // ActionGetTimer 0x34
|
|
1, // ActionMBSubString 0x35
|
|
1, // ActionMBOrd 0x36
|
|
1, // ActionMBChr 0x37
|
|
0, // 0x38
|
|
0, // 0x39
|
|
1, // ActionDelete 0x3A
|
|
1, // ActionDelete2 0x3B
|
|
1, // ActionDefineLocal 0x3C
|
|
1, // ActionCallFunction 0x3D
|
|
1, // ActionReturn 0x3E
|
|
1, // ActionModulo 0x3F
|
|
1, // ActionNew 0x40
|
|
1, // ActionVar 0x41
|
|
1, // ActionInitArray 0x42
|
|
1, // ActionInitObject 0x43
|
|
1, // ActionTypeOf 0x44
|
|
1, // ActionTargetPath 0x45
|
|
1, // ActionEnumerate 0x46
|
|
1, // ActionNewAdd 0x47
|
|
1, // ActionNewLessThan 0x48
|
|
1, // ActionNewEquals 0x49
|
|
1, // ActionToNumber 0x4A
|
|
1, // ActionToString 0x4B
|
|
1, // ActionDup 0x4C
|
|
1, // ActionSwap 0x4D
|
|
1, // ActionGetMember 0x4E
|
|
1, // ActionSetMember 0x4F
|
|
1, // ActionIncrement 0x50
|
|
1, // ActionDecrement 0x51
|
|
1, // ActionCallMethod 0x52
|
|
1, // ActionNewMethod 0x53
|
|
1, // ActionInstanceOf 0x54
|
|
1, // ActionEnum2 0x55
|
|
1, // EAUnknownAction56 0x56
|
|
0, // 0x57
|
|
1, // EAUnknownAction58 0x58
|
|
1, // EAPushZero 0x59
|
|
1, // EAPushOne 0x5A
|
|
1, // EACallFunctionPop 0x5B
|
|
1, // EACallFunction 0x5C
|
|
1, // EACAllMethodPop 0x5D
|
|
1, // EACallMethod 0x5E
|
|
0, // 0x5F
|
|
1, // ActionBitwiseAnd 0x60
|
|
1, // ActionBitwiseOr 0x61
|
|
1, // ActionBitwiseXor 0x62
|
|
1, // ActionShiftLeft 0x63
|
|
1, // ActionShiftRight 0x64
|
|
1, // ActionShiftRight2 0x65
|
|
1, // ActionStrictEq 0x66
|
|
1, // ActionGreater 0x67
|
|
1, // ActionStringGreater 0x68
|
|
1, // ActionExtends 0x69
|
|
0, // 0x6A
|
|
0, // 0x6B
|
|
0, // 0x6C
|
|
0, // 0x6D
|
|
0, // 0x6E
|
|
0, // 0x6F
|
|
1, // EAPushThis 0x70
|
|
1, // EAPushGlobal 0x71
|
|
1, // EAZeroVariable 0x72
|
|
1, // EAPushTrue 0x73
|
|
1, // EAPushFalse 0x74
|
|
1, // EAPushNull 0x75
|
|
1, // EAPushUndefined 0x76
|
|
0, // 0x77
|
|
0, // 0x78
|
|
0, // 0x79
|
|
0, // 0x7A
|
|
0, // 0x7B
|
|
0, // 0x7C
|
|
0, // 0x7D
|
|
0, // 0x7E
|
|
0, // 0x7F
|
|
0, // 0x80
|
|
5, // ActionGotoFrame 0x81
|
|
0, // 0x82
|
|
9, // ActionGetURL 0x83
|
|
0, // 0x84
|
|
0, // 0x85
|
|
0, // 0x86
|
|
5, // ActionSetRegister 0x87
|
|
9, // ActionConstantPool 0x88
|
|
0, // 0x89
|
|
1, // ActionWaitForFrame 0x8A
|
|
5, // ActionSetTarget 0x8B
|
|
5, // ActionGotoLabel 0x8C
|
|
1, // ActionWaitForFrameExpression 0x8D
|
|
29, // ActionDefineFunction2 0x8E
|
|
1, // ActionTry 0x8F
|
|
0, // 0x90
|
|
0, // 0x91
|
|
0, // 0x92
|
|
0, // 0x93
|
|
5, // ActionWith 0x94
|
|
0, // 0x95
|
|
9, // ActionPushData 0x96
|
|
0, // 0x97
|
|
0, // 0x98
|
|
5, // ActionBranchAlways 0x99
|
|
1, // ActionGetURL2 0x9A
|
|
25, // ActionDefineFunction 0x9B
|
|
0, // 0x9C
|
|
5, // ActionBranchIfTrue 0x9D
|
|
1, // ActionCallFrame 0x9E
|
|
5, // ActionGotoExpression 0x9F
|
|
0, // 0xA0
|
|
5, // EAPushString 0xA1
|
|
2, // EAPushConstant 0xA2
|
|
3, // EAPushWordConstant 0xA3
|
|
5, // EAGetStringVar 0xA4
|
|
5, // EAGetStringMember 0xA5
|
|
5, // EASetStringVar 0xA6
|
|
5, // EASetStringMember 0xA7
|
|
0, // 0xA8
|
|
0, // 0xA9
|
|
0, // 0xAA
|
|
0, // 0xAB
|
|
0, // 0xAC
|
|
0, // 0xAD
|
|
2, // EAPushValueOfVar 0xAE
|
|
2, // EAGetNamedMember 0xAF
|
|
2, // EACallNamedFunctionPop 0xB0
|
|
2, // EACallNamedFunction 0xB1
|
|
2, // EACallNamedMethodPop 0xB2
|
|
2, // EACallNamedMethod 0xB3
|
|
5, // EAPushFloat 0xB4
|
|
2, // EAPushByte 0xB5
|
|
3, // EAPushShort 0xB6
|
|
5, // EAPushLong 0xB7
|
|
5, // EABranchIfFalse 0xB8
|
|
2 // EAPushRegister 0xB9
|
|
];
|
|
|
|
// ─── Composed helpers ───
|
|
|
|
// Selector string for action nodes that reference constants
|
|
const CONST_ACTION_SELECTOR = '[action=' + EA_PUSHCONSTANT + '],' +
|
|
'[action=' + EA_CALLNAMEDFUNCTIONPOP + '],' +
|
|
'[action=' + EA_CALLNAMEDFUNCTION + '],' +
|
|
'[action=' + EA_CALLNAMEDMETHODPOP + '],' +
|
|
'[action=' + EA_CALLNAMEDMETHOD + '],' +
|
|
'[action=' + EA_PUSHVALUEOFVAR + '],' +
|
|
'[action=' + EA_GETNAMEDMEMBER + '],' +
|
|
'[action=' + EA_PUSHWORDCONSTANT + ']';
|
|
|
|
// Selector for function-splitting tag names (used in expand)
|
|
const FUNCTION_SPLITTERS = 'definefunction2,definefunction,constantpool,end';
|
|
|
|
// System argument order for definefunction2
|
|
const SYSTEM_ARGUMENTS = ['this', 'arguments', 'super', '_root', '_parent', '_global', '_extern'];
|
|
|
|
// ─── Exports ───
|
|
module.exports = {
|
|
// opcodes
|
|
ACTION_END, ACTION_NEXTFRAME, ACTION_PREVFRAME, ACTION_PLAY, ACTION_STOP,
|
|
ACTION_TOGGLEQUALITY, ACTION_STOPSOUNDS, ACTION_ADD, ACTION_SUBTRACT,
|
|
ACTION_MULTIPLY, ACTION_DIVIDE, ACTION_EQUAL, ACTION_LESSTHAN,
|
|
ACTION_LOGICALAND, ACTION_LOGICALOR, ACTION_LOGICALNOT, ACTION_STRINGEQ,
|
|
ACTION_STRINGLENGTH, ACTION_SUBSTRING, ACTION_POP, ACTION_INT,
|
|
ACTION_GETVARIABLE, ACTION_SETVARIABLE, ACTION_SETTARGETEXPRESSION,
|
|
ACTION_STRINGCONCAT, ACTION_GETPROPERTY, ACTION_SETPROPERTY,
|
|
ACTION_DUPLICATECLIP, ACTION_REMOVECLIP, ACTION_TRACE,
|
|
ACTION_STARTDRAGMOVIE, ACTION_STOPDRAGMOVIE, ACTION_STRINGCOMPARE,
|
|
ACTION_THROW, ACTION_CASTOP, ACTION_IMPLEMENTSOP, ACTION_RANDOM,
|
|
ACTION_MBLENGTH, ACTION_ORD, ACTION_CHR, ACTION_GETTIMER,
|
|
ACTION_MBSUBSTRING, ACTION_MBORD, ACTION_MBCHR, ACTION_DELETE,
|
|
ACTION_DELETE2, ACTION_DEFINELOCAL, ACTION_CALLFUNCTION, ACTION_RETURN,
|
|
ACTION_MODULO, ACTION_NEW, ACTION_VAR, ACTION_INITARRAY, ACTION_INITOBJECT,
|
|
ACTION_TYPEOF, ACTION_TARGETPATH, ACTION_ENUMERATE, ACTION_NEWADD,
|
|
ACTION_NEWLESSTHAN, ACTION_NEWEQUALS, ACTION_TONUMBER, ACTION_TOSTRING,
|
|
ACTION_DUP, ACTION_SWAP, ACTION_GETMEMBER, ACTION_SETMEMBER,
|
|
ACTION_INCREMENT, ACTION_DECREMENT, ACTION_CALLMETHOD, ACTION_NEWMETHOD,
|
|
ACTION_INSTANCEOF, ACTION_ENUM2, ACTION_BITWISEAND, ACTION_BITWISEOR,
|
|
ACTION_BITWISEXOR, ACTION_SHIFTLEFT, ACTION_SHIFTRIGHT, ACTION_SHIFTRIGHT2,
|
|
ACTION_STRICTEQ, ACTION_GREATER, ACTION_STRINGGREATER, ACTION_EXTENDS,
|
|
ACTION_GOTOFRAME, ACTION_GETURL, ACTION_WAITFORFRAME, ACTION_SETTARGET,
|
|
ACTION_GOTOLABEL, ACTION_WAITFORFRAMEEXPRESSION, ACTION_PUSHDATA,
|
|
ACTION_BRANCHALWAYS, ACTION_GETURL2, ACTION_DEFINEFUNCTION,
|
|
ACTION_BRANCHIFTRUE, ACTION_CALLFRAME, ACTION_GOTOEXPRESSION,
|
|
ACTION_CONSTANTPOOL, ACTION_DEFINEFUNCTION2, ACTION_TRY, ACTION_WITH,
|
|
ACTION_SETREGISTER,
|
|
EA_ACTION56, EA_ACTION58, EA_PUSHZERO, EA_PUSHONE,
|
|
EA_CALLFUNCTIONPOP, EA_CALLFUNCTION, EA_CALLMETHODPOP, EA_CALLMETHOD,
|
|
EA_PUSHTHIS, EA_PUSHGLOBAL, EA_ZEROVARIABLE, EA_PUSHTRUE, EA_PUSHFALSE,
|
|
EA_PUSHNULL, EA_PUSHUNDEFINED, EA_ACTION77,
|
|
EA_PUSHSTRING, EA_PUSHCONSTANT, EA_PUSHWORDCONSTANT,
|
|
EA_GETSTRINGVAR, EA_GETSTRINGMEMBER, EA_SETSTRINGVAR, EA_SETSTRINGMEMBER,
|
|
EA_PUSHVALUEOFVAR, EA_GETNAMEDMEMBER,
|
|
EA_CALLNAMEDFUNCTIONPOP, EA_CALLNAMEDFUNCTION,
|
|
EA_CALLNAMEDMETHODPOP, EA_CALLNAMEDMETHOD,
|
|
EA_PUSHFLOAT, EA_PUSHBYTE, EA_PUSHSHORT, EA_PUSHLONG,
|
|
EA_BRANCHIFFALSE, EA_PUSHREGISTER,
|
|
|
|
// flag enums
|
|
PlaceObjectFlags, ClipEventFlags, ButtonRecordFlags,
|
|
ButtonActionFlags, ButtonInput, FunctionPreloadFlags,
|
|
|
|
// name tables
|
|
ActionNames, ActionNames2, ActionAligns, ActionSizes,
|
|
|
|
// composed helpers
|
|
CONST_ACTION_SELECTOR, FUNCTION_SPLITTERS, SYSTEM_ARGUMENTS
|
|
};
|