Skip to content

Instantly share code, notes, and snippets.

@yosh778
Last active October 13, 2017 09:44
Show Gist options
  • Save yosh778/141f78102cbcb15673b2375002e52a76 to your computer and use it in GitHub Desktop.
Save yosh778/141f78102cbcb15673b2375002e52a76 to your computer and use it in GitHub Desktop.

Ys VIII RPN arithmetics

Ys VIII scripts use RPN arithmetics to perform conditions and some arithmetic calculations.

There are many different types of operations managed by the game, 63 in total apprently, with codes going from 0x1 up to 0x45, stored as 16 bits integers.

Find bellow some of these operators codes.

The main function found by weaknespase is located at the address .text+0x0029E876 from the unpatched japanese vita eboot. It contains a simple switch on these opcodes.

Testing them is also quite simple : for instance you can modify the 1stload/talk.bin script and change the GetExp item scripts to perform calculation tests. Their result will be added as experience points when you use the item.

Example

RPN code : 1a 00 13 00 00 00 1f 00 1a 00 05 00 00 00 0e 00 1d 00

This decodes into : *0x13 5 ==

Which means : (*0x13 == 5)

Operators

OpcodeOperation
0x0002! (Logical NOT)
0x0008>>
0x0009>=
0x000A>
0x000B<<
0x000C<=
0x000D<
0x000E==
0x0010&&
0x0011&
0x0012||
0x0013|
0x0014~ (Bitwise NOT) [untested]
0x001Apush int
0x001Bpush float
0x001Dend of stream
0x001Fload var
0x0042negate float ? [untested]
0x0045sqrt float ? [untested]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment