Author Topic: About IFKEY opcodes.  (Read 2761 times)

Akari

  • *
  • Posts: 766
    • View Profile
About IFKEY opcodes.
« on: 2007-01-19 11:33:16 »
2SynergyBlades: Could you check this info and tell me if this is true or not. I want to implement this opcodes now.

Code: [Select]
OP KEY JUMP

OP - 0x30/0x31/0x32
KEY - WORD
JUMP - BYTEKEY is a key to check for (surprise!), JUMP is a number of bytes to skip if the condition isn't true (IP+3+JUMP).

IFKEY is used to check if the button is being pressed.
IFKEYON is used to check if the button has been pressed (was OFF, became ON)
IFKEYOFF is used to check if the button has been released (was ON, became OFF)

What I don't understand is:
KEY & 0x0200
It's a condition which determines which key status to use (2 statuses for each mode - being pressed/was pressed/was released - they are always the same :/). 0x0200 is probably not a valid key... Help?

And I don't quite understand how IFKEYON and IFKEYOFF triggered. The button first press or release may happen in different time than  IFKEYON opcode check. What will happened if I press and release button few times (this can happened if WAIT-like opcodes used). Does it remembered all button events.. or how?
« Last Edit: 2007-01-19 12:09:44 by Akari »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: About IFKEY opcodes.
« Reply #1 on: 2007-01-19 13:58:12 »
IIRC, it updates the structure, which holds those statuses, before each fieldscript-pass (WAIT just waits n passes of the module - that obviously doesn't block other field threads from checking the state of the buttons). Pressing a button is not an event - the status of each button is just checked frequently.

IFKEYON will return true if previously unpressed button (unpressed in previous fs-pass) becomes pressed one in the current fieldscript pass.

Synergy Blades

  • Guest
Re: About IFKEY opcodes.
« Reply #2 on: 2007-01-19 14:29:57 »
Sorry, had to reinstall FF7, get LGPTools, etc.  :-D It's pretty much as dziugo says. IFKEY checks if the key is being pressed, no matter what. The other two are used as sort of "repeat checks".

IFKEYON checks if the button has been pressed, where it wasn't pressed before. The first time the button is pressed and this is checked, the condition is true, so the if body executes. The next time it encounters IFKEYON with the same button ID (with the user still pressing this button), IFKEYON's condition will fail, because this button state was previously "pressed", not "unpressed". This is in contrast to IFKEY where it doesn't care whether it was previously pressed or not, and always executes if the key is pressed. This condition failure will not reset (i.e evaluate to true) until the user lets go of the button, then represses it.

IFKEYOFF does the opposite, and its condition won't evaluate to true until the user has let go of the button; that is, is no longer being pressed where it was being checked before.

Key IDs:

Assist:   IFKEY(00,01,XX)
**n/a:   IFKEY(00,02,XX)**
**n/a:   IFKEY(00,04,XX)**
Start:   IFKEY(00,08,XX)
Up:   IFKEY(00,10,XX)
Right:   IFKEY(00,20,XX)
Down:   IFKEY(00,40,XX)
Left:   IFKEY(00,80,XX)
Camera:   IFKEY(01,00,XX)
Target:   IFKEY(02,00,XX)
PgUp:   IFKEY(04,00,XX)
PgDown:   IFKEY(08,00,XX)
Menu:   IFKEY(10,00,XX)
OK:   IFKEY(20,00,XX)
Cancel:   IFKEY(40,00,XX)
Switch:   IFKEY(80,00,XX)


[Edit] There's a couple of caveats to IFKEY usage. The following keys: ASSIST, CAMERA, TARGET, when used with IFKEY, act as though IFKEYON is being used. That is, they are not repeatedly checked, and the if statement body only executes once. Of course, when the key is let go, and repressed, it works again, but again only once.

Also, you can OR the bits of the key IDs together. So IFKEY(00,F0,00) will check if any of the directional buttons are being used.
« Last Edit: 2007-01-19 14:57:22 by Synergy Blades »

Akari

  • *
  • Posts: 766
    • View Profile
Re: About IFKEY opcodes.
« Reply #3 on: 2007-01-19 19:13:12 »
Well i think I got it =)
But:

Code: [Select]
Assist:   IFKEY(00,01,XX)
**n/a:   IFKEY(00,02,XX)**
**n/a:   IFKEY(00,04,XX)**
Start:   IFKEY(00,08,XX)
Up:   IFKEY(00,10,XX)
Right:   IFKEY(00,20,XX)
Down:   IFKEY(00,40,XX)
Left:   IFKEY(00,80,XX)
Camera:   IFKEY(01,00,XX)
Target:   IFKEY(02,00,XX)
PgUp:   IFKEY(04,00,XX)
PgDown:   IFKEY(08,00,XX)
Menu:   IFKEY(10,00,XX)
OK:   IFKEY(20,00,XX)
Cancel:   IFKEY(40,00,XX)
Switch:   IFKEY(80,00,XX)

What is "Assist", "n/a", "Camera", "Target", "PgUp", "PgDown", "Switch" buttons?

Synergy Blades

  • Guest
Re: About IFKEY opcodes.
« Reply #4 on: 2007-01-19 19:41:00 »
Bearing in mind I'm using the PC version, so I don't know exactly how they translate to PlayStation buttons. I don't think I ever played FF7 on the PS. However, here's a description for them:

n/a means there's no button for that ID, so not a valid bit to use. Ignore these.
Assist - show/hide the helper pointer/triangles.
Camera - switches camera in battle, I think?
Target - battle again, puts the little "target" markers on the enemies
Page Up/Down - allows you to switch between party members in eg. the materia screen
Switch - not sure where it's used other than in certain events in fields. This goes along with Menu, OK, and Cancel, so I assume it's whichever PS button isn't Menu/OK/Cancel  :-D