Calculate Ability Pointers and Type

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Parameters : r4 = Ability ID
             r5 = Previous routine Stack pointer 1
             r6 = Previous routine Stack pointer 2

Returns : r2 = 0x00 if Used ability possess a data 2 table (ID < 0x170)
          r2 = 0x01 If Ability is an Item Ability
          r2 = 0x02 If Ability is a Throw Ability
          r2 = 0x03 If Ability is a Jump Ability 
          r2 = 0x04 If Ability is a Charge Ability 
          r2 = 0x05 If Ability is a Math Ability
          r2 = 0x06 If Ability is a Reaction Ability 
          r2 = 0x07 If Ability is a Support Ability
          r2 = 0x08 If Ability is a Move Ability

Store : On r5 0x00 Ability Data 1 Pointer
        On r6 0x00 Specific Data pointer (data 2, Item, Throw etc...)
-----------------------------------------------------------------------------------------
0005a72c: 308401ff andi r4,r4,0x01ff        |r4 = Used Ability ID
0005a730: 000418c0 sll r3,r4,0x03           |r3 = Used Ability ID * 8
0005a734: 3c028006 lui r2,0x8006            |
0005a738: 2442ebf0 addiu r2,r2,-0x1410      |r2 = 0x8005ebf0 (start of abilities data 1)
0005a73c: 00621021 addu r2,r3,r2            |r2 = Used Ability data 1 pointer
0005a740: aca20000 sw r2,0x0000(r5)         |Store Ability's Data 1 Pointer  (on previous routine stack)
0005a744: 28820170 slti r2,r4,0x0170        |r2 = 0x01 if Ability ID < 170 
0005a748: 10400008 beq r2,r0,0x0005a76c     #If Used ability < Potion (= has a data 2 table)
0005a74c: 00641023 subu r2,r3,r4                 |r2 = Used Ability ID *7
0005a750: 00021040 sll r2,r2,0x01                |r2 = Used Ability ID *14
0005a754: 3c038006 lui r3,0x8006                 |
0005a758: 2463fbf0 addiu r3,r3,-0x0410           |r3 = 0x8005fbf0 (Start of gata 2 table)
0005a75c: 00431021 addu r2,r2,r3                 |r2 = Used ability data 2 pointer
0005a760: acc20000 sw r2,0x0000(r6)              |Store Ability's Data 2 Pointer (previous routine stack)
0005a764: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x00
0005a768: 00001021 addu r2,r0,r0                 |r2 = 0x00
0005a76c: 2882017e slti r2,r4,0x017e        |r2 = 0x01 if Ability ID < 17e (0x170 to 0x17d = Item abilities)
0005a770: 10400007 beq r2,r0,0x0005a790     #If Used Ability is an item Ability
0005a774: 00000000 nop                           | 
0005a778: 3c028006 lui r2,0x8006                 | 
0005a77c: 24420ea0 addiu r2,r2,0x0ea0            |r2 = 0x80060ea0
0005a780: 00821021 addu r2,r4,r2                 |r2 = Used ability Item pointer 0x80060ea0 + 0x170 = 0x80061010 (start of Item table)
0005a784: acc20000 sw r2,0x0000(r6)              |Store Ability Item's Pointer (previous routine stack)
0005a788: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x01
0005a78c: 34020001 ori r2,r0,0x0001              |r2 = 0x01
0005a790: 2882018a slti r2,r4,0x018a        |r2 = 0x01 if Ability ID < 0x18a (0x17e to 0x189 = Throw abilities)
0005a794: 10400007 beq r2,r0,0x0005a7b4     #If Ability is a Throw ability
0005a798: 00000000 nop                           | 
0005a79c: 3c028006 lui r2,0x8006                 | 
0005a7a0: 24420ea2 addiu r2,r2,0x0ea2            |r2 = 0x80060ea2
0005a7a4: 00821021 addu r2,r4,r2                 |r2 = Used ability thrown item pointer  0x8006ea2 + 0x18a = 0x80061020
0005a7a8: acc20000 sw r2,0x0000(r6)              |Store Thrown item pointer (previous routine stack)
0005a7ac: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x02
0005a7b0: 34020002 ori r2,r0,0x0002              |r2 = 0x02
0005a7b4: 28820196 slti r2,r4,0x0196        |r2 = 0x01 if Ability ID < 0x196 (0x18a to 0x195 = Jump Abilities ID)
0005a7b8: 10400007 beq r2,r0,0x0005a7d8     #If Used Ability is a jump ability
0005a7bc: 00041040 sll r2,r4,0x01                |r2 = Ability ID * 2
0005a7c0: 3c038006 lui r3,0x8006                 |
0005a7c4: 24630d18 addiu r3,r3,0x0d18            |r3 = 0x80060d18
0005a7c8: 00431021 addu r2,r2,r3                 |r2 = Used Ability Range/Vertical data pointer 0x80060d18 + 2*0x18a = 0x8006102c
0005a7cc: acc20000 sw r2,0x0000(r6)              |Store Jump's Ability Range/Vertical pointer
0005a7d0: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x03
0005a7d4: 34020003 ori r2,r0,0x0003              |r2 = 0x03
0005a7d8: 2882019e slti r2,r4,0x019e        |r2 = 0x01 if Ability ID < 0x19e (Charge Abilities)
0005a7dc: 10400007 beq r2,r0,0x0005a7fc     #If Used Ability is a charge ability
0005a7e0: 00041040 sll r2,r4,0x01                |r2 = Ability ID * 2
0005a7e4: 3c038006 lui r3,0x8006                 |
0005a7e8: 24630d18 addiu r3,r3,0x0d18            |r3 = 0x80060d18
0005a7ec: 00431021 addu r2,r2,r3                 |r2 = Used Ability Power/CT data pointer 0x80060d18 + 2*0x96 = 0x80061044
0005a7f0: acc20000 sw r2,0x0000(r6)              |Store Charge's Ability Pointer
0005a7f4: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x04
0005a7f8: 34020004 ori r2,r0,0x0004              |r2 = 0x04
0005a7fc: 288201a6 slti r2,r4,0x01a6        |r2 = 0x01 if Ability ID < 0x1a6 (Math Abilities)
0005a800: 10400007 beq r2,r0,0x0005a820     #If Used Ability is a Math Ability
0005a804: 00000000 nop                           | 
0005a808: 3c028006 lui r2,0x8006                 |
0005a80c: 24420eb6 addiu r2,r2,0x0eb6            |r2 = 0x80060eb6
0005a810: 00821021 addu r2,r4,r2                 |r2 = Used Ability Math ID data pointer  0x80060eb6 + 0x19a = 0x80061054
0005a814: acc20000 sw r2,0x0000(r6)              |Store Math's Ability Pointer
0005a818: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x05
0005a81c: 34020005 ori r2,r0,0x0005              |r2 = 0x05
0005a820: 288201c6 slti r2,r4,0x01c6        |r2 = 0x01 If Ability ID < 0x1c6
0005a824: 10400007 beq r2,r0,0x0005a844     #If Used Ability is a Reaction Ability
0005a828: 00000000 nop                           | 
0005a82c: 3c028006 lui r2,0x8006                 |
0005a830: 24420eb6 addiu r2,r2,0x0eb6            |r2 = 0x80060eb6
0005a834: 00821021 addu r2,r4,r2                 |r2 = Used Ability Reaction ID data pointer
0005a838: acc20000 sw r2,0x0000(r6)              |Store Reaction's Ability ID Pointer
0005a83c: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x06
0005a840: 34020006 ori r2,r0,0x0006              |r2 = 0x06
0005a844: 288201e6 slti r2,r4,0x01e6        |r2 = 0x01 if Ability ID < 0x1e6
0005a848: 14400007 bne r2,r0,0x0005a868     #If Ability ID is a Move Ability (>= 0x1e6)
0005a84c: 00000000 nop                           | 
0005a850: 3c028006 lui r2,0x8006                 |
0005a854: 24420eb6 addiu r2,r2,0x0eb6            |r2 = 0x80060eb6
0005a858: 00821021 addu r2,r4,r2                 |r2 = Used Ability Move ID data pointer
0005a85c: acc20000 sw r2,0x0000(r6)              |Store Movement's Ability Pointer
0005a860: 08016a1f j 0x0005a87c                  >>Jump to END - r2 = 0x07
0005a864: 34020008 ori r2,r0,0x0008              |r2 = 0x07
                                            #Else Ability ID is a Support Ability (between 0x1c6 and 0x1e5
0005a868: 3c028006 lui r2,0x8006            |
0005a86c: 24420eb6 addiu r2,r2,0x0eb6       |r2 = 0x80060eb6
0005a870: 00821021 addu r2,r4,r2            |r2 = Used Ability Support ID data pointer
0005a874: acc20000 sw r2,0x0000(r6)         |Store Support Ability Pointer
0005a878: 34020007 ori r2,r0,0x0007         |r2 = 0x07             
0005a87c: 03e00008 jr r31                        
0005a880: 00000000 nop

Return locations

Battle.bin
00136254: 001361e8_-_00136320
00141794: Spell Quote determination