Difference between revisions of "FF7/Field/Script/Opcodes/30 IFKEY"

From Final Fantasy Inside
< FF7‎ | Field‎ | Script‎ | Opcodes
Jump to navigation Jump to search
my_wiki>Halkun
(Button IDs)
(Amend button IDs)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
* Opcode: '''0x30'''
 
* Opcode: '''0x30'''
 
* Short name: '''IFKEY'''
 
* Short name: '''IFKEY'''
* Long name: If Key is pressed.
+
* Long name: If Key Pressed
  
 
==== Memory layout ====
 
==== Memory layout ====
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
! width="40" | 0x30
 
! width="40" | 0x30
! width="40" | ''B''
+
! width="80" | ''B''
! width="40" | ''C''
 
 
! width="40" | ''A''
 
! width="40" | ''A''
 
|}
 
|}
Line 13: Line 12:
 
==== Arguments ====
 
==== Arguments ====
  
* '''const UByte''' ''B'': Which button to check for.
+
* '''const UShort (Bit field)''' ''B'': Button ID to check for.
* '''const UByte''' ''C'': Condition of button.
+
* '''const UByte''' ''A'': Amount to jump if button not pressed.
* '''const UByte''' ''A'': Amount to jump if comparison is false.
 
  
 
==== Description ====
 
==== Description ====
  
Checks the status of a button being pressed. If the checked button fails the condition check, then the code jumps ahead ''A'' amount of bytes.
+
Checks the status of a button being pressed; if pressed, regardless of the previous condition of the button press state (see [[FF7/Field/Script/Opcodes/31 IFKEYON|IFKEYON]] / [[FF7/Field/Script/Opcodes/32 IFKEYOFF|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.
  
==== Conditions ====
+
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 ====
  
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
! style="background:rgb(204,204,204)" width="40" | ID
+
! style="background:rgb(204,204,204)" | ID
! style="background:rgb(204,204,204)" width="100" | Button
+
! style="background:rgb(204,204,204)" | Button
 +
|-#
 +
| 0b1 / 1
 +
| L2 / Camera
 +
|-
 +
| 0b10 / 2
 +
| R2 / Target
 +
|-
 +
| 0b100 / 4
 +
| L1 / PageUp
 +
|-
 +
| 0b1000 / 8
 +
| L2 / PageDown
 +
|-
 +
| 0b10000 / 16
 +
| Triangle / Menu
 +
|-
 +
| 0b100000 / 32
 +
| Circle / OK
 +
|-
 +
| 0b1000000 / 64
 +
| Cross / Cancel
 +
|-
 +
| 0b10000000 / 128
 +
| Square / Switch
 +
|-
 +
| 0b100000000 / 256
 +
| Select / Assist
 
|-
 
|-
| align="center" | 0
+
| style="background:rgb(255,255,204)" | 0b1000000000 / 512
| Pressed
+
| style="background:rgb(255,255,204)" | Unknown 1
 
|-
 
|-
| align="center" | 1
+
| style="background:rgb(255,255,204)" | 0b10000000000 / 1024
| Not Pressed
+
| style="background:rgb(255,255,204)" | Unknown 2
 
|-
 
|-
|}
+
| 0b100000000000 / 2048
 
+
| Start / Pause
==== Button IDs ====
 
 
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
! style="background:rgb(204,204,204)" width="40" | ID
 
! style="background:rgb(204,204,204)" width="120" | Button
 
 
|-
 
|-
| align="center" | 5
+
| 0b1000000000000 / 4096
| Triangle [Menu]
+
| Up
 
|-
 
|-
| align="center" | 6
+
| 0b10000000000000 / 8192
| Cross [Cancel]
+
| Right
 
|-
 
|-
| align="center" | 7
+
| 0b100000000000000 / 16384
| Circle [OK]
+
| Down
 
|-
 
|-
| align="center" | 8
+
| 0b1000000000000000 / 32768
| Square [EXT]
+
| Left
 
|-
 
|-
 
|}
 
|}

Latest revision as of 12:21, 11 September 2020

  • Opcode: 0x30
  • Short name: IFKEY
  • Long name: If Key Pressed

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
0b1 / 1 L2 / Camera
0b10 / 2 R2 / Target
0b100 / 4 L1 / PageUp
0b1000 / 8 L2 / PageDown
0b10000 / 16 Triangle / Menu
0b100000 / 32 Circle / OK
0b1000000 / 64 Cross / Cancel
0b10000000 / 128 Square / Switch
0b100000000 / 256 Select / Assist
0b1000000000 / 512 Unknown 1
0b10000000000 / 1024 Unknown 2
0b100000000000 / 2048 Start / Pause
0b1000000000000 / 4096 Up
0b10000000000000 / 8192 Right
0b100000000000000 / 16384 Down
0b1000000000000000 / 32768 Left