Author Topic: [FF7 Field Scripting] About PLUS! & PLUS2! events  (Read 3040 times)

lasyan3

  • *
  • Posts: 76
    • View Profile
Hi,

Now that I released my tool Hack7, I decided to take some time to play with it. Right now, I'm making some tests to figure out how those events are working, and I don't really get it, so I hope somebody will be able to help me.

In the Wiki, for the event PLUS2! (0x77) it is said that the parameter is signed and the result of the addition is capped at 32767.
In fact, when I try this (code from Hack7, $TW600 is a word variable) :
Code: [Select]
$TW600 = 10;
$TW600 = AddCap16( 32767 );
or this :
Code: [Select]
$TW600 = 32767;
$TW600 = AddCap16( 10 );
The result is indeed capped at 32767.

However, when I try this :
Code: [Select]
$TW600 = 42767;
$TW600 = AddCap16( 10 );
or this :
Code: [Select]
$TW600 = 10;
$TW600 = AddCap16( 42767 );

The result I get is not 32767 as expected, but 42777 instead !!! So, it seems that once the initial value is bigger than 32767, the addition doesn't cap anymore the result ! And it would also mean that the parameter is not signed !
If someone has any idea, please...

Aali

  • *
  • Posts: 1196
    • View Profile
Re: [FF7 Field Scripting] About PLUS! & PLUS2! events
« Reply #1 on: 2011-06-12 16:57:25 »
The result is capped at 32767, your interpretation of the data is incorrect.

If you treat the numbers as unsigned you can't really expect a signed comparison to work.

lasyan3

  • *
  • Posts: 76
    • View Profile
Re: [FF7 Field Scripting] About PLUS! & PLUS2! events
« Reply #2 on: 2011-06-12 20:02:43 »
Ok I got it.

When I was trying to do :
Code: [Select]
$TW600 = 10;
$TW600 = AddCap16( 42767 );
In fact it was :
Code: [Select]
$TW600 = 10;
$TW600 = AddCap16( -22769 );
Which give -22759, which equal to 42777 when unsigned... Thanks Aali.