Difference between revisions of "FF7/Field/Script/Opcodes/14 IFUB"

From Final Fantasy Inside
< FF7‎ | Field‎ | Script‎ | Opcodes
Jump to navigation Jump to search
my_wiki>Synergy Blades
(No difference)

Revision as of 00:46, 18 August 2006

  • Opcode: 0x14
  • Short name: IFUB
  • Long name: If (Unsigned Byte)

Memory layout

0x14 B A V C E

Arguments

  • const UByte B: Memory bank to access.
  • const UByte A: Address of the value to retrieve.
  • const UByte V: Unsigned value to compare the retrieved value to.
  • const UByte C: Type of comparison to perform.
  • const UByte E: Amount to jump if the comparison does not hold.

Description

Performs a comparison between a retrieved value from memory (Bank and Address), and the unsigned byte Value given in the argument list. The type of comparison used is shown in the table below. If the comparison fails, the script pointer jumps forward by the amount specified in the final argument; the starting offset for this jump is just before the jump value argument itself. This is used to implement if/else functionality in scripts, as demonstrated below.

If the content of the 'if' block following the IFUB line is longer than 0xFF, the 'else' argument will also need to be longer than 0xFF, and hence you should use IFUBL instead. If the value or address is larger than 0xFF, you should use the IFUW/IFUWL variants. If the value you are comparing is negative, you should use the IFSW/IFSWL variants.

Comparison Types

ID Comparison Performed
0 A == B
1 A != B
2 A > B
3 A < B
4 A >= B
5 A <= B
6 A & B
7 A ^ B
8 B
9 A & (1<<B)
A !((A & (1<<B)))


If/Else Example

In this example, if the value found is greater than 0x30, the script halts for a shorter period of time; otherwise, the script halts for a long period of time.

IFUB (10,20,30,02,06)
WAIT (00,01)
JMPF (04)
WAIT (00,04)
RET ()

<cpp>

if(<10>[20] > 30)
{
 WAIT(100);
}
else
{
 WAIT(400);
}
return;

</cpp>