0.12.0 • Published 3 years ago

@sage-js/res-osi v0.12.0

Weekly downloads
1
License
MPL-2.0
Repository
github
Last release
3 years ago

SAGE-JS RES-OSI

The main OSI resource module for SAGE-JS.

Overview

Provides an API for working with OSI files.

Includes a number of abstract instructions that can be used to make manipulating assembly easier.

Instructions

Abstract

NameSizeArgsInfo
JumpTarget0i32uTarget for PushConstanti32JumpTarget with same ID
PushConstanti32JumpTarget5i32u i32sReplaces PushConstanti32 before JumpRelative references JumpTarget with target and offset*
BranchTarget0i32uTarget for CompareAndBranchIfFalseTarget and BranchAlwaysTarget with same ID
BranchAlwaysTarget3i32u i16sReplaces BranchAlways, with target and offset*
CompareAndBranchIfFalseTarget3i32u i16sReplaces CompareAndBranchIfFalse, with target and offset*
PushConstantStringString3sp8nReplaces PushConstantString with inline strings from string table
GetThisMemberFunctionString3sp8nReplaces GetThisMemberFunction with inline strings from symbol table
GetThisMemberValueString3sp8nReplaces GetThisMemberValue with inline strings from symbol table
SetThisMemberValueString3sp8nReplaces SetThisMemberValue with inline strings from symbol table
GetMemberFunctionString3sp8nReplaces GetMemberFunction with inline strings from symbol table
GetMemberValueString3sp8nReplaces GetMemberValue with inline strings from symbol table
SetMemberValueString3sp8nReplaces SetMemberValue with inline strings from symbol table
GetGameVariableString2sp8n sp8nReplaces GetGameVariable with inline strings from string table
SetGameVariableString2sp8n sp8nReplaces SetGameVariable with inline strings from string table
CallGameFunctionString3sp8n sp8n i8sReplaces CallGameFunction with inline strings from string table
CallGameFunctionFromStringString2sp8n i8sReplaces CallGameFunctionFromString with inline string from string table

* Instructions that jump to targets include an offset to handle jumps to point between instructions (compensates for off-by-one error in some original code).

BCL

ByteNameSizeArgsStackInfo
0x00Nop1Do nothing
0x02DebugOn1Enable debug or fail if disabled in engine
0x03DebugOff1Disable debug or fail if disabled in engine
0x04LineNumber5i16u i16uSource line, possibly for assembly line and column
0x05LineNumberAlt15i16u i16uSource line, line number, source file index
0x06LineNumberAlt25i16u i16uSource line number, unknown
0x10SetMemberValue3i16u-2Set object property by symbol index
0x11GetMemberValue3i16u-1 +1Get object property by symbol index
0x12GetMemberFunction3i16u-1 +1Get object method address by symbol index
0x13CreateObject3i16u+1Create an object by class ID
0x14MemberFunctionArgumentCheck2i8s+NCheck the arg count <= N and add N number of stack variables
0x15SetThisMemberValue3i16u-1Set this property by symbol index
0x16GetThisMemberValue3i16u+1Get this property by symbol index
0x17GetThisMemberFunction3i16u+1Get this method address by symbol index
0x18GetMemberValueFromString1-2 +1Get object property by string index
0x19GetMemberFunctionFromString1-2 +1Get object method address by string index
0x1ASetMemberValueFromString1-3Set object property by string index
0x21GetVariableValue3i16u+1Get variable by index (highest bit means global)
0x22SetVariableValue3i16u-1Set variable by index (highest bit means global)
0x23CreateStackVariables2i8s+NAdd N number of stack variables
0x24IncrementVariable3i16uIncrement variable by index (highest bit means global)
0x25DecrementVariable3i16uDecrement variable by index (highest bit means global)
0x30Pop1-1Pop a value off the stack
0x31PopN2i8s-NPop N values off the stack
0x32Swap1-2 +2Swap last 2 values on stack
0x33Pull2i8s+1Duplicate stack value by index onto stack
0x34DupN2i8s+NDuplicate last stack value N times
0x35Dup1+1Duplicate last stack value
0x40PushConstanti325i32s+1Push constant integer value
0x41PushConstanti244int24s+1Unimplemented
0x42PushConstanti163i16s+1Push constant integer value
0x43PushConstanti82i8s+1Push constant integer value
0x44PushConstantf325f32+1Push constant float value
0x45PushConstant01+1Push constant integer value 0
0x46PushConstantString3i16u+1Push string from string table
0x47PushNothing1+1Push the nothing type
0x48PushConstantColor88885i32u+1Push constant color value
0x49PushConstantColor55513i16u+1Push constant color value
0x50JumpRelative2i8s-1Jump to popped address relative to file start
0x51JumpAbsolute2i8s-1Jump to popped address in memory
0x52Return1?*Return from current subroutine
0x53CompareAndBranchIfFalse3i16s-1Jump N number of bytes from after instruction if false or i0
0x54BranchAlways3i16sJump N number of bytes from after instruction
0x60EqualTo1-2 +1Compare last 2 values on stack
0x61LessThan1-2 +1Compare last 2 values on stack
0x62GreaterThan1-2 +1Compare last 2 values on stack
0x63LessOrEqual1-2 +1Compare last 2 values on stack
0x64GreaterOrEqual1-2 +1Compare last 2 values on stack
0x6AAnd1-2 +1Check last 2 values on stack are both true
0x6BOr1-2 +1Check last 2 values on stack are have true
0x6CNot1-2 +1Check last 2 values on stack are not true
0x6DBitwiseAnd1-2 +1Bitwise and last 2 values on stack
0x6EBitwiseOr1-2 +1Bitwise or last 2 values on stack
0x6FBitwiseXor1-2 +1Bitwise xor last 2 values on stack
0x70Add1-2 +1Add the last 2 values on stack
0x71Subtract1-2 +1Subtract the last 2 values on stack
0x72Multiply1-2 +1Multiply the last 2 values on stack
0x73Divide1-2 +1Divide the last 2 values on stack
0x74Power1-2 +1Raise to power the last 2 values on stack
0x75Modulus1-2 +1Modulus operator the last 2 values on stack
0x76BitwiseNot1-1 +1Bitwise not last value on stack
0x77ShiftLeft1-2 +1Bitwise shift left last 2 values on stack
0x78ShiftRight1-2 +1Bitwise shift right last 2 values on stack
0x7AIncrement1-1 +1Increment value of last value on stack by 1
0x7BDecrement1-1 +1Decrement value of last value on stack by 1
0x80GetGameVariable5i16u i16uGet variable by ns and name string index seems non-functional
0x81SetGameVariable5i16u i16uSet variable by ns and name string index seems non-functional
0x82CallGameFunction6i16u i16u i8s?*Call native by ns and name string index, N args
0x83CallGameFunctionFromString6i16u i8s?*Call native by ns string index and stack string, N args
0x84CallGameFunctionDirect6i32s i8s?*Call native by address, N args (should only exist in memory)
0x90CreateArray1+1Create array
0x91GetArrayValue1-2 +1Get array or string table element
0x92ElementsInArray1-1 +1Get array or string table length
0x93SetArrayValue1-3Set array element
0x94AppendToArray1-2Push array element
0x95RemoveFromArray1-2Remove array element at index
0x96InsertIntoArray1-3Add array element at index
0xA0SetRedValue1-2 +1Set color red value
0xA1SetGreenValue1-2 +1Set color green value
0xA2SetBlueValue1-2 +1Set color blue value
0xA3SetAlphaValue1-2 +1Set color alpha value
0xA4GetRedValue1-1 +1Get color red value
0xA5GetGreenValue1-1 +1Get color green value
0xA6GetBlueValue1-1 +1Get color blue value
0xA7GetAlphaValue1-1 +1Get color alpha value
0xB0ConvertToString1-1 +1Convert last stack element to string
0xB1ConvertToFloat1-1 +1Convert last stack element to float
0xB2ConvertToInteger1-1 +1Convert last stack element to integer
0xB8IsInteger1-1 +1Check if last stack element is integer
0xB9IsFloat1-1 +1Check if last stack element is float
0xBAIsString1-1 +1Check if last stack element is string
0xBBIsAnObject1-1 +1Check if last stack element is an object
0xBCIsGameObject1-1 +1Check if last stack element is a game object
0xBDIsArray1-1 +1Check if last stack element is array
0xBFGetObjectClassID1-1 +1Get object class ID
0xFFHalt1+1Halt execution

* Unclear how many values are pushed and/or popped under what conditions.

0.12.0

3 years ago

0.11.1

5 years ago

0.11.0

5 years ago

0.10.0

5 years ago

0.9.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.0

6 years ago

0.3.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago