Get Inverted Button Input

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: GET INVERTED BUTTON INPUT
#       Parameters:
#           r4 = 1? (Doesn't seem to be used for anything)
#       Returns:
#           r2 = (Inverted button input)
#           Inverted Button state definition: Halfword (2-byte) value; for each bit, 0 means button is not pressed, 1 means it is pressed
#               0x8000  Left
#               0x4000  Down
#               0x2000  Right
#               0x1000  Up
#               0x0800  Start
#               0x0400  R3
#               0x0200  L3
#               0x0100  Select
#               0x0080  Square
#               0x0040  X
#               0x0020  Circle
#               0x0010  Triangle
#               0x0008  R1
#               0x0004  L1
#               0x0002  R2
#               0x0001  L2

8001db58: 27bdffe8 addiu r29,r29,-0x0018
8001db5c: afbf0010 sw r31,0x0010(r29)
8001db60: 0c0087fd jal 0x80021ff4               #   PAD_dr ();                      // PSX kernel function PAD_dr() (Gets controller button state)
8001db64: 00000000 nop
8001db68: 3c028003 lui r2,0x8003
8001db6c: 8c422a78 lw r2,0x2a78(r2)             #   *0x80032a78                         // Output location for PAD_dr()
8001db70: 00000000 nop
8001db74: 00021027 nor r2,r0,r2                 #   return binary_not(*0x80032a78)      // Return inverted button input
8001db78: 8fbf0010 lw r31,0x0010(r29)
8001db7c: 27bd0018 addiu r29,r29,0x0018
8001db80: 03e00008 jr r31
8001db84: 00000000 nop