Re: Snake
Would anyone care to explain?
I won't go through with how he downloaded it, that's pretty basic.
score = (w - (e = e - 5) - 2) * 2 - 8;
MindJoltAPI.service.submitScore(score);
//96 04 00 08 2f 08 27
_push "score" "w"
//1c
_getVariable
//96 04 00 08 29 08 29
_push "e" "e"
//1c
_getVariable
//96 05 00 07 05 00 00 00
_push 5
//0b
_subtract
//87 01 00 00
_storeRegister 0
//1d
_setVariable
//96 02 00 04 00
_push register0
//0b
_subtract
//96 05 00 07 02 00 00 00
_push 2
//0b
_subtract
//96 05 00 07 02 00 00 00
_push 2
//0c
_multiply
//96 05 00 07 08 00 00 00
_push 8
//0b
_subtract
//1d
_setVariable
//96 02 00 08 2f
_push "score"
//1c
_getVariable
//96 07 00 07 01 00 00 00 08 01
_push 1 "MindJoltAPI"
//1c
_getVariable
//96 02 00 08 12
_push "service"
//4e
_getMember
//96 02 00 08 30
_push "submitScore"
We want to set the score to a much higher value. Therefore, we are going to change the last part of the score calculations ([...] - (broken image removed).
How about, we change the - to a +, and the 8 to a really big number? That'll work.
After painful (sarcasm of course) searchings, we can deduce that the following lines:
//96 05 00 07 08 00 00 00 Are the ones related to the 8 and the minus.
_push 8
//0b
_subtract
no_ninjas wanted to change it to 992; so let's do that. He found out that 992 in Hex is 3e0. Now, look at 07 08 00 00 00 . 07 means that we are pushing an integer, and the 08 00 00 00 is the integer we are pushing in reverse order (meaning, last byte is first, making it 00 00 00 08).
So, 992 will be 00 00 03 e0. When we reverse it, it becomes e0 03 00 00.
Let's see what we have so far. We found out that we'll switch
96 05 00 07 08 00 00 00 with
96 05 00 07 e0 03 00 00
Now, according to plan, we will change the subtract to add. Looking around, we find out that the AS2 opcode to addition is 0a. That was easy.
Finally, we have our AoB:
96 05 00 07 08 00 00 00 0b =>
96 05 00 07 e0 03 00 00 0a
Hope this clears it up.
Just for general knowledge, in case this comes in handy one time:
The largest integer (plain old int; not long, unsigned, static etc) is 2147483647. In Hex, that is 7F FF FF FF.