Editing VSMX
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
= Description = | = Description = | ||
Virtual Script Machine Instructions (VSMX) | Virtual Script Machine Instructions (VSMX) file (filename extension .jsx, a .js compiled) | ||
*http://endlessparadigm.com/forum/showthread.php?tid=21485 | History: | ||
*http://endlessparadigm.com/forum/showthread.php?tid=21485 | |||
[[Rcomage]] | [[Rcomage]] can compile/decompile .jsx (VSMX) <=> .JS (need to change the VSMX version at offset 0x04 to 01 (PSP?) instead of 02 (PS3?) | ||
<pre> | |||
but it's very buggy and usually doesn't work right | |||
</pre> | |||
*VSMX files are used on: | *VSMX files are used on: | ||
**PSP | **PSP (inside RCO's from video/music UMDs, and two lftv firmware RCO's in flash0/vsh/resource/...) | ||
**PS3 | **PS3 ([[Rich_Appearance_Format_(RAF)|inside RAF's]]: on [[Coldboot.raf]], [[Themes (.p3t)|PS3 themes]] animated) and some PS3 Games? | ||
**PSVita & PS4 (unknown | **PSVita & PS4 (unknown) | ||
= VSMX Structure = | = VSMX Structure = | ||
== Header == | == Header == | ||
Line 54: | Line 56: | ||
== OPCODE Table == | == OPCODE Table == | ||
*Instructions length: 4+4 bytes? (or 3+1+4) | |||
*See [http://pastebin.com/vRCDzXt1 Pastebin] (without the header) of the coldboot. | |||
{| class="wikitable sortable" | |||
{| class="wikitable" | |||
|- | |- | ||
! | ! OpCode<BR />(short) !! Mnemonics<BR />(official) !! Mnemonics<BR />(rcomage) !! group !! Notes | ||
|- | |- | ||
| 0x00 | | 0x00 || NOP || UNKNOWN_0 || - || - | ||
|- | |- | ||
| 0x01 | | 0x01 || ASSGN || ASSIGN || Assignment Operators || - | ||
|- | |- | ||
| 0x02 || ADD || ADD || Arithmetic Operators || - | |||
|- | |- | ||
| | | 0x03 || SUB || SUBTRACT || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x04 || MUL || MULTIPLY || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x05 || DIV || DIVIDE || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x06 || MOD || MODULUS || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x07 || TO_NUMBER || POSITIVE || - || - | ||
|- | |- | ||
| | | 0x08 || CSIGN || NEGATE || - || - | ||
|- | |- | ||
| | | 0x09 || NOT || NOT || - || - | ||
|- | |- | ||
| | | 0x0A || INC || PRE_INCREMENT || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x0B || DEC || PRE_DECREMENT || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x0C || POST_INC || INCREMENT || Arithmetic Operators || - | ||
|- | |- | ||
| | | 0x0D || POST_DEC || DECREMENT || Arithmetic Operators || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| 0x0E || CMPEQ || TEST_EQUAL || Compare Operators || - | |||
|- | |- | ||
| | | 0x0F || CMPNEQ || TEST_NOT_EQUAL || Compare Operators || - | ||
|- | |- | ||
| | | 0x10 || CMPSEQ || TEST_IDENTITY || Compare Operators || - | ||
|- | |- | ||
| | | 0x11 || CMPSNEQ || TEST_NON_IDENTITY || Compare Operators || - | ||
|- | |- | ||
| | | 0x12 || CMPLT || TEST_LESS_THAN || Compare Operators || - | ||
|- | |- | ||
| | | 0x13 || CMPLE || TEST_LESS_EQUAL_THAN || Compare Operators || - | ||
|- | |- | ||
| | | 0x14 || CMPGE || TEST_MORE_EQUAL_THAN || Compare Operators || - | ||
|- | |- | ||
| | | 0x15 || CMPGT || TEST_MORE_THAN || Compare Operators || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| 0x16 || INSTANCEOF || UNKNOWN_16 || - || - | |||
|- | |- | ||
| | | 0x17 || IN || UNKNOWN_17 || - || - | ||
|- | |- | ||
| | | 0x18 || TYPEOF || TYPEOF || - || - | ||
|- | |- | ||
| | | 0x19 || BIT_AND || BINARY_AND || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1A || BIT_XOR || BINARY_XOR || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1B || BIT_OR || BINARY_OR || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1C || BIT_NOT || BINARY_NOT || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1D || LSHIFT || LSHIFT || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1E || S_RSHIFT || RSHIFT || Bitwise Operators || - | ||
|- | |- | ||
| | | 0x1F || U_RSHIFT || UNSIGNED_RSHIFT || Bitwise Operators || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| 0x20 || COPY || STACK_PUSH || - || - | |||
|- | |- | ||
| | | 0x21 || SWAP || UNKNOWN_21 || - || - | ||
|- | |- | ||
| | | 0x22 || REMOVE || END_STATEMENT || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| 0x23 || PUSH_UNDEFINED || CONST_NULL || Data Types || - | |||
|- | |- | ||
| | | 0x24 || PUSH_NULL || CONST_EMPTY_ARRAY || Data Types || - | ||
|- | |- | ||
| | | 0x25 || PUSH_BOOL || CONST_BOOL || Data Types || - | ||
|- | |- | ||
| | | 0x26 || PUSH_INT || CONST_INT || Data Types || - | ||
|- | |- | ||
| | | 0x27 || PUSH_FLOAT || CONST_FLOAT || Data Types || - | ||
|- | |- | ||
| | | 0x28 || PUSH_STRING || CONST_STRING || Data Types || - | ||
|- | |- | ||
| | | 0x29 || PUSH_OBJECT || CONST_OBJECT || - || - | ||
|- | |- | ||
| 0x2A || PUSH_FUNC || FUNCTION || - || byte 4 uses a "flag" | |||
|- | |- | ||
| | | 0x2B || PUSH_ARRAY || CONST_ARRAY || - || - | ||
|- | |- | ||
| | | 0x2C || PUSH_THIS || THIS_OBJECT || - || - | ||
|- | |- | ||
| | | 0x2D || PUSH_LOCAL || UNNAMED_VARIABLE || - || - | ||
|- | |- | ||
| | | 0x2E || PUSH_GLOBAL || NAME || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| | | 0x2F || GETATTR || PROPERTY || - || - | ||
|- | |- | ||
| 0x30 || GETATTR_KEEPOBJ || METHOD || - || - | |||
|- | |- | ||
| | | 0x31 || SETATTR || SET || - || - | ||
|- | |- | ||
| | | 0x32 || DELATTR || UNSET || - || - | ||
|- | |- | ||
| | | 0x33 || APPEND_ATTR || OBJECT_ADD_ATTRIBUTE || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| | | 0x34 || GETITEM || ARRAY_INDEX || - || - | ||
|- | |- | ||
| 0x35 || GETITEM_KEEPOBJ || UNKNOWN_35 || - || - | |||
|- | |- | ||
| | | 0x36 || SETITEM || ARRAY_INDEX_ASSIGN || - || - | ||
|- | |- | ||
| | | 0x37 || DELITEM || UNKNOWN_37 || - || - | ||
|- | |- | ||
| | | 0x38 || APPEND_ITEM || ARRAY_PUSH || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| | | 0x39 || JUMP || JUMP || - || - | ||
|- | |- | ||
| 0x3A || JUMPT || JUMP_IF_TRUE || - || - | |||
|- | |- | ||
| | | 0x3B || JUMPF || JUMP_IF_FALSE || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| | | 0x3C || CALL_FUNC || CALL_FUNCTION || - || - | ||
|- | |- | ||
| 0x3D || CALL_METHOD || CALL_METHOD || - || - | |||
|- | |- | ||
| | | 0x3E || CALL_CONSTRUCTOR || CALL_INBUILT / CALL_NEW <!-- different versions of rcomage --> || - || - | ||
|- | |- | ||
| | | colspan="5" {{cellcolors|grey}} | ||
|- | |- | ||
| | | 0x3F || RET || RETURN || - || - | ||
|- | |- | ||
| 0x40 || THROW || UNKNOWN_40 || - || - | |||
|- | |- | ||
| | | 0x41 || TRYBLK_IN || UNKNOWN_41 || - || - | ||
|- | |- | ||
| | | 0x42 || TRYBLK_OUT || UNKNOWN_42 || - || - | ||
|- | |- | ||
| 0x43 || CATCH_FINALLYBLK_IN || UNKNOWN_43 || - || - | |||
|- | |- | ||
| | | 0x44 || CATCH_FINALLYBLK_OUT || UNKNOWN_44 || - || - | ||
|- | |- | ||
| | | 0x45 || HALT || END_SCRIPT || - || - | ||
|- | |- | ||
| | | 0x46 || DEBUG_FILE || DEBUG_FILE || - || - | ||
|- | |- | ||
| | | 0x47 || DEBUG_LINE || DEBUG_LINE || - || - | ||
|- | |- | ||
| 0x48 || GETITEM_KEEPOBJNAME || UNKNOWN_48 || - || - | |||
|- | |- | ||
| | | 0x49 || PUSH_VECTOR || UNKNOWN_49 / MAKE_FLOAT_ARRAY <!-- different versions of rcomage --> || Data Types || - | ||
|- | |- | ||
| 0x4A || GET_VECTOR_ELEMENT || UNKNOWN_4a || - || - | |||
|- | |- | ||
| | | 0x4B || GET_VECTOR_ELEMENT_KEEPVECTOR || UNKNOWN_4b || - || - | ||
|- | |- | ||
| | | 0x4C || ASSGN_VECTOR_ELEMENT || UNKNOWN_4c || - || - | ||
|- | |- | ||
| 0x4D || SETATTR_VECTOR_ELEMENT || UNKNOWN_4d || - || byte 4 uses a vector identifyer -> | |||
|- | |- | ||
| 0x4E || SETITEM_VECTOR_ELEMENT || UNKNOWN_4e || - || <!--byte 4 uses a vector identifyer--> | |||
| 0x4E | |||
|- | |- | ||
|} | |} | ||
=== Arithmetic Operators === | === Arithmetic Operators === | ||
Line 307: | Line 292: | ||
|- | |- | ||
| 0x19 || BIT_AND || & || AND | | 0x19 || BIT_AND || & || AND | ||
|- | |- | ||
| 0x1B || BIT_OR || <nowiki>|</nowiki> || OR | | 0x1B || BIT_OR || <nowiki>|</nowiki> || OR | ||
|- | |- | ||
| 0x1C || BIT_NOT || ~ || NOT | | 0x1C || BIT_NOT || ~ || NOT | ||
|- | |||
| 0x1A || BIT_XOR || ^ || XOR | |||
|- | |- | ||
| 0x1D || LSHIFT || << || Left Shift | | 0x1D || LSHIFT || << || Left Shift | ||
Line 335: | Line 320: | ||
|- | |- | ||
| 0x0E || CMPEQ || == || Equality | | 0x0E || CMPEQ || == || Equality | ||
|- | |||
| 0x10 || CMPSEQ || === || Strict Equal value and equal type | |||
|- | |- | ||
| 0x0F || CMPNEQ || != || Inequality | | 0x0F || CMPNEQ || != || Inequality | ||
|- | |- | ||
| | | 0x11 || CMPSNEQ || !== || Strict not equal value or not equal type | ||
|- | |||
| 0x15 || CMPGT || > || Greater Than | |||
|- | |- | ||
| | | 0x14 || CMPGE || >= || Greater Than or Equal To | ||
|- | |- | ||
| 0x12 || CMPLT || < || Less Than | | 0x12 || CMPLT || < || Less Than | ||
|- | |- | ||
| 0x13 || CMPLE || <= || Less Than or Equal To | | 0x13 || CMPLE || <= || Less Than or Equal To | ||
|- | |- | ||
|} | |} | ||
Line 384: | Line 369: | ||
This is an example of the decodification and decompilation made with the VSMX script contained inside [[coldboot.raf]]. The decompilation has been made by hand because the vsmx decompiler by ZiNgA BuRgA doesnt supports vectors and crashes, the purpose is to serve as an explain of how the opcodes works, the features that was added to VSMX v2 format for PS3, and as an overall explain of how to decompile other VSMX files | This is an example of the decodification and decompilation made with the VSMX script contained inside [[coldboot.raf]]. The decompilation has been made by hand because the vsmx decompiler by ZiNgA BuRgA doesnt supports vectors and crashes, the purpose is to serve as an explain of how the opcodes works, the features that was added to VSMX v2 format for PS3, and as an overall explain of how to decompile other VSMX files | ||
The file can be saved as .js and compiled directlly (there is no need to remove the comments), for a better | The file can be saved as .js and compiled directlly (there is no need to remove the comments), for a better view of the decompiled code without the comments in [[PlayStation JavaScript]] format see [[coldboot.raf]] page | ||
*Form left to right: | *Form left to right: | ||
Line 394: | Line 379: | ||
**'''DECOMPILED PSJS CODE''' - The source code in [[PlayStation JavaScript]] format ready to compile, it will generate a coldboot.jsx exactly like the one extracted from coldboot.raf by the [[CXML Containers|CXML decompiler tool]] | **'''DECOMPILED PSJS CODE''' - The source code in [[PlayStation JavaScript]] format ready to compile, it will generate a coldboot.jsx exactly like the one extracted from coldboot.raf by the [[CXML Containers|CXML decompiler tool]] | ||
{{Boxcode| | {{Boxcode|content=<syntaxhighlight lang="javascript"> | ||
//--------------------------------------------------------------------------------------------------------------------- | //--------------------------------------------------------------------------------------------------------------------- | ||
// VSMX v2 Decompilation Sample (coldboot.raf PS3). Decompiled step by step from VSMX opcodes to PSJS code by sandungas | // VSMX v2 Decompilation Sample (coldboot.raf PS3). Decompiled step by step from VSMX opcodes to PSJS code by sandungas | ||
Line 618: | Line 603: | ||
/* 210 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | /* 210 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | ||
/* 211 - 31000000 03000000 - SETATTR scale *///footer.scale = sd_scale | /* 211 - 31000000 03000000 - SETATTR scale *///footer.scale = sd_scale | ||
/* 212 - 22000000 00000000 - REMOVE */ | /* 212 - 22000000 00000000 - REMOVE */ footer.scale = sd_scale; | ||
/* 213 - 39000000 F9000000 - JUMP 249 */ } else { | /* 213 - 39000000 F9000000 - JUMP 249 */} else { | ||
/* 214 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | /* 214 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | ||
/* 215 - 27000000 00000040 - PUSH_FLOAT 2.0 *///2.0 | /* 215 - 27000000 00000040 - PUSH_FLOAT 2.0 *///2.0 | ||
/* 216 - 01000000 00000000 - ASSGN *///sd_offset_x = 2.0 | /* 216 - 01000000 00000000 - ASSGN *///sd_offset_x = 2.0 | ||
/* 217 - 22000000 00000000 - REMOVE */ | /* 217 - 22000000 00000000 - REMOVE */ sd_offset_x = 2.0; | ||
/* 218 - 2E000000 14000000 - PUSH_GLOBAL logo *///logo | /* 218 - 2E000000 14000000 - PUSH_GLOBAL logo *///logo | ||
/* 219 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | /* 219 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | ||
/* 220 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///logo.position->0 = sd_offset_x | /* 220 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///logo.position->0 = sd_offset_x | ||
/* 221 - 22000000 00000000 - REMOVE */ | /* 221 - 22000000 00000000 - REMOVE */ logo.position->0 = sd_offset_x; | ||
/* 222 - 2E000000 15000000 - PUSH_GLOBAL blur *///blur | /* 222 - 2E000000 15000000 - PUSH_GLOBAL blur *///blur | ||
/* 223 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | /* 223 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | ||
/* 224 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///blur.position->0 = sd_offset_x | /* 224 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///blur.position->0 = sd_offset_x | ||
/* 225 - 22000000 00000000 - REMOVE */ | /* 225 - 22000000 00000000 - REMOVE */ blur.position->0 = sd_offset_x; | ||
/* 226 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | /* 226 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | ||
/* 227 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | /* 227 - 2E000000 1B000000 - PUSH_GLOBAL sd_offset_x *///sd_offset_x | ||
/* 228 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///footer.position->0 = sd_offset_x | /* 228 - 4D000000 02000000 - SETATTR_VECTOR_ELEMENT 0 position *///footer.position->0 = sd_offset_x | ||
/* 229 - 22000000 00000000 - REMOVE */ | /* 229 - 22000000 00000000 - REMOVE */ footer.position->0 = sd_offset_x; | ||
/* 230 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | /* 230 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | ||
/* 231 - 27000000 0000803F - PUSH_FLOAT 1.0 *///1.0 | /* 231 - 27000000 0000803F - PUSH_FLOAT 1.0 *///1.0 | ||
Line 642: | Line 627: | ||
/* 234 - 49000000 03000000 - PUSH_VECTOR 3 *///<1.0, 0.5, 0.5> | /* 234 - 49000000 03000000 - PUSH_VECTOR 3 *///<1.0, 0.5, 0.5> | ||
/* 235 - 01000000 00000000 - ASSGN *///sd_scale = <1.0, 0.5, 0.5> | /* 235 - 01000000 00000000 - ASSGN *///sd_scale = <1.0, 0.5, 0.5> | ||
/* 236 - 22000000 00000000 - REMOVE */ | /* 236 - 22000000 00000000 - REMOVE */ sd_scale = <1.0, 0.5, 0.5>; | ||
/* 237 - 2E000000 14000000 - PUSH_GLOBAL logo *///logo | /* 237 - 2E000000 14000000 - PUSH_GLOBAL logo *///logo | ||
/* 238 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | /* 238 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | ||
/* 239 - 31000000 03000000 - SETATTR scale *///scale | /* 239 - 31000000 03000000 - SETATTR scale *///scale | ||
/* 240 - 22000000 00000000 - REMOVE */ | /* 240 - 22000000 00000000 - REMOVE */ logo.scale = sd_scale; | ||
/* 241 - 2E000000 15000000 - PUSH_GLOBAL blur *///blur | /* 241 - 2E000000 15000000 - PUSH_GLOBAL blur *///blur | ||
/* 242 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | /* 242 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | ||
/* 243 - 31000000 03000000 - SETATTR scale *///scale | /* 243 - 31000000 03000000 - SETATTR scale *///scale | ||
/* 244 - 22000000 00000000 - REMOVE */ | /* 244 - 22000000 00000000 - REMOVE */ blur.scale = sd_scale; | ||
/* 245 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | /* 245 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | ||
/* 246 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | /* 246 - 2E000000 1C000000 - PUSH_GLOBAL sd_scale *///sd_scale | ||
/* 247 - 31000000 03000000 - SETATTR scale *///scale | /* 247 - 31000000 03000000 - SETATTR scale *///scale | ||
/* 248 - 22000000 00000000 - REMOVE */ | /* 248 - 22000000 00000000 - REMOVE */ footer.scale = sd_scale;}} | ||
/* 249 - 2E000000 17000000 - PUSH_GLOBAL logo_hide *///logo_hide | /* 249 - 2E000000 17000000 - PUSH_GLOBAL logo_hide *///logo_hide | ||
/* 250 - 26000000 00000000 - PUSH_INT 0 *///0 | /* 250 - 26000000 00000000 - PUSH_INT 0 *///0 | ||
Line 853: | Line 838: | ||
/* 445 - 49000000 04000000 - PUSH_VECTOR 4 *///<0.8, 0.0, 0.8, 1.0> | /* 445 - 49000000 04000000 - PUSH_VECTOR 4 *///<0.8, 0.0, 0.8, 1.0> | ||
/* 446 - 01000000 00000000 - ASSGN *///Unamed_Variable = <0.8, 0.0, 0.8, 1.0> | /* 446 - 01000000 00000000 - ASSGN *///Unamed_Variable = <0.8, 0.0, 0.8, 1.0> | ||
/* 447 - 22000000 00000000 - REMOVE */ var Unamed_Variable = <0.8, 0.0, 0.8, 1.0>; | /* 447 - 22000000 00000000 - REMOVE */var Unamed_Variable = <0.8, 0.0, 0.8, 1.0>; | ||
/* 448 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | /* 448 - 2E000000 16000000 - PUSH_GLOBAL footer *///footer | ||
/* 449 - 30000000 05000000 - GETATTR_KEEPOBJ setColor *///footer.setColor | /* 449 - 30000000 05000000 - GETATTR_KEEPOBJ setColor *///footer.setColor |