FF7/Field/Script/Opcodes/30 IFKEY

From Final Fantasy Inside
< FF7‎ | Field‎ | Script‎ | Opcodes
Revision as of 12:34, 4 April 2018 by my_wiki>BukTop (9 revisions imported)
  • Opcode: 0x30
  • Short name: IFKEY
  • Long name: If Key Pressed

Contents

Memory layout

0x30 B A

Arguments

  • const UShort (Bit field) B: Button ID to check for.
  • const UByte A: Amount to jump if button not pressed.

Description

Checks the status of a button being pressed; if pressed, regardless of the previous condition of the button press state (see IFKEYON / IFKEYOFF), the "if" body executes (that is, the script pointer is moved to the opcode after the current IFKEY). If the checked button fails the condition check, then the script pointer moves ahead A bytes.

The highlighted keys in the button ID table below do not quite act as the rest when used with this particular opcode. For these keys, IFKEY acts in the same manner as IFKEYON; these keys cannot be checked repeatedly, and the if statement body will only execute once, regardless of whether the key is being held down.

Button IDs can be ORd with each other to produce a combination of keys to check in one statement. For example, IFKEY with a key ID of 0x00F0 will check if any of the directional buttons are being pressed.

Button IDs

ID Button
0x0001 Assist
0x0008 Start
0x0010 Up
0x0020 Right
0x0040 Down
0x0080 Left
0x0100 Camera
0x0200 Target
0x0400 Page Up
0x0800 Page Down
0x1000 Menu
0x2000 OK
0x4000 Cancel
0x8000 Switch