Usable Ability Setting

From Final Fantasy Hacktics Wiki
(Redirected from 0019a5f8 - 0019aa4c)
Jump to navigation Jump to search
BATTLE.BIN : Usable Ability Setting
-----------------------------------------------------------------------------------
Parameters - r4 : Unit ID
             r5 : Skillset ID
             r6 : Ability counter (offset in Unit's AI list of move - 0x8019f3c4 - 0x0ef0)
			  
Returns - r2 : Updated ability counter (r6)

Check if abilities are known, and/or usable (MP, Faith, Sword, Materia blade)
**Hacked by ARH**
-----------------------------------------------------------------------------------
0019a5f8: 27bdffb8 addiu r29,r29,-0x0048    |
0019a5fc: afb60038 sw r22,0x0038(r29)       |
0019a600: 0080b021 addu r22,r4,r0           |r22 = Unit's ID
0019a604: afb40030 sw r20,0x0030(r29)       |
0019a608: 00a0a021 addu r20,r5,r0           |r20 = Unit's Skillset
0019a60c: afb3002c sw r19,0x002c(r29)       |
0019a610: 00c09821 addu r19,r6,r0           |r19 = Counter
0019a614: afbf0044 sw r31,0x0044(r29)       |
0019a618: afbe0040 sw r30,0x0040(r29)       |
0019a61c: afb7003c sw r23,0x003c(r29)       |
0019a620: afb50034 sw r21,0x0034(r29)       |
0019a624: afb20028 sw r18,0x0028(r29)       |
0019a628: afb10024 sw r17,0x0024(r29)       |
0019a62c: 16800010 bne r20,r0,0x0019a670    #Branch to Main section If Skillset <> 0x00
0019a630: afb00020 sw r16,0x0020(r29)           |
0019a634: 08066a87 j 0x0019aa1c                 >>Jump to END If skillset = 0x00
0019a638: 02601021 addu r2,r19,r0               |returns counter

    ---- Weapon inventory known ability section (backward branch…) ---- 
0019a63c: 00121100 sll r2,r18,0x04          |Battle ID * 0x10 Unit's ID * 0x400
0019a640: 00521021 addu r2,r2,r18           |ID * 0x11 Shuriken Counter = 0
0019a644: 000210c0 sll r2,r2,0x03           |ID * 0x88 (unit offset) Battle ID * 0x10
0019a648: 24420ef0 addiu r2,r2,0x0ef0       |ID * 0x88 + 0xef0 (Unit offset + Move List offset) ID * 0x11
0019a64c: 3c08801a lui r8,0x801a                                |ID * 0x88 (unit offset)
0019a650: 2508f3c4 addiu r8,r8,-0xc3c       |0x8019f3c4  ID * 0x88 + 0xef0 (Unit offset + Move List offset)
0019a654: 01021021 addu r2,r8,r2            |Unit Move list pointer
0019a658: 00131880 sll r3,r19,0x02          |Counter * 4 (Ability offset in move list data)
0019a65c: 00438821 addu r17,r2,r3           |Ability pointer in unit's AI move list
0019a660: 26730001 addiu r19,r19,0x0001     |Ability counter + 1
0019a664: 00161280 sll r2,r22,0x0a          |Unit's ID * 0x400
0019a668: 08066a85 j 0x0019aa14             >>Jump to END Will store unit ID*4 in Byte 0x01
0019a66c: a2340002 sb r20,0x0002(r17)       |Store Unit's Skillset

    ---- Main routine ---- 
0019a670: 02802021 addu r4,r20,r0           |r4 = Unit's Skillset
0019a674: 34050001 ori r5,r0,0x0001         |Check = 1 (Ability)
0019a678: 0c01698e jal 0x0005a638           |-->Store Skillset's Abilities returns r2 = 0x80066204 (temp. Ability list)
0019a67c: afa00010 sw r0,0x0010(r29)        |Reset Jump ability flag (see jump section)
0019a680: 00402021 addu r4,r2,r0            |r4 = Temp Ability List? Pointer
0019a684: 3c08801a lui r8,0x801a            |
0019a688: 2508f3c4 addiu r8,r8,0xf3c4       |Start of AI data (0x8019f3c4)
0019a68c: 02c81021 addu r2,r22,r8           |AI data + unit ID
0019a690: 34030002 ori r3,r0,0x0002         |r3 = 0x02 (Weapon inventory action menu)
0019a694: 3c018006 lui r1,0x8006            |
0019a698: 00340821 addu r1,r1,r20           |80060000 + skillset ID
0019a69c: 903e5cb4 lbu r30,0x5cb4(r1)       |Load Skillset's Action Menu
0019a6a0: 9052198c lbu r18,0x198c(r2)       |Load Unit's Battle ID (0xff is not in battle)

    ---- Weapon Inventory ---- 
0019a6a4: 17c3003f bne r30,r3,0x0019a7a4    #If Action menu is Weapon inventory
0019a6a8: 34020003 ori r2,r0,0x0003         |r2 = 0x03 (Maths action menu)
0019a6ac: 02c02021 addu r4,r22,r0               |r4 = Unit's ID
0019a6b0: 02802821 addu r5,r20,r0               |r5 = Unit's Skillset
0019a6b4: 0c066a94 jal 0x0019aa50               |-->Load Known Ability Flag returns r2 = 0x01 if ability is known
0019a6b8: 00003021 addu r6,r0,r0                |Ability number = 0x00 (shuriken - first in skillset)
0019a6bc: 10400014 beq r2,r0,0x0019a710         #If Shuriken is known
0019a6c0: 00162280 sll r4,r22,0x0a                  |Unit's ID * 0x400
0019a6c4: 00008021 addu r16,r0,r0                   |Shuriken Counter = 0
0019a6c8: 00121100 sll r2,r18,0x04                  |Battle ID * 0x10
0019a6cc: 00521021 addu r2,r2,r18                   |ID * 0x11
0019a6d0: 000210c0 sll r2,r2,0x03                   |ID * 0x88 (unit offset)
0019a6d4: 24420ef0 addiu r2,r2,0x0ef0               |ID * 0x88 + 0xef0 (Unit offset + Move List offset)
0019a6d8: 3c08801a lui r8,0x801a                    |
0019a6dc: 2508f3c4 addiu r8,r8,-0x0c3c              |0x8019f3c4 
0019a6e0: 00481021 addu r2,r2,r8                    |Unit Move list pointer
0019a6e4: 00131880 sll r3,r19,0x02                  |Counter * 4 (Ability offset in move list data)
0019a6e8: 00621821 addu r3,r3,r2                    |Ability pointer in unit's AI move list
                                                    @LOOP - Will store 3 moves in move list (one per shuriken type)
0019a6ec: 00901021 addu r2,r4,r16                       |Shuriken counter + Unit ID * 0x400
0019a6f0: 2442007a addiu r2,r2,0x007a                   |Unit ID * 0x400 + Shuriken ID (0x7a + shuriken counter)
0019a6f4: a0740002 sb r20,0x0002(r3)                    |Store Unit's Skillset in move list data
0019a6f8: a4620000 sh r2,0x0000(r3)                     |Store Shuriken ID in Byte 0x00 and Unit ID * 4 in byte 0x01
0019a6fc: 24630004 addiu r3,r3,0x0004                   |Next Ability Offset in move list
0019a700: 26100001 addiu r16,r16,0x0001                 |Shuriken counter + 1
0019a704: 2a020003 slti r2,r16,0x0003                   |Check if shuriken counter < 3
0019a708: 1440fff8 bne r2,r0,0x0019a6ec             Λ loop 3 times (shuriken, magic shuriken, yagyu darkness)
0019a70c: 26730001 addiu r19,r19,0x0001                 |Ability counter + 1
0019a710: 02c02021 addu r4,r22,r0               |r4 = Unit's ID
0019a714: 02802821 addu r5,r20,r0               |r5 = Unit's Skillset
0019a718: 0c066a94 jal 0x0019aa50               |-->Load Known Ability Flag returns r2 = 0x01 if ability is known
0019a71c: 34060001 ori r6,r0,0x0001             |Ability number = 0x1 (Ball - 2nd in skillset)
0019a720: 10400014 beq r2,r0,0x0019a774         #Branch if Ability isn't known
0019a724: 00008021 addu r16,r0,r0                   |Ball Counter = 0
0019a728: 00162280 sll r4,r22,0x0a                  |Unit ID * 0x400
0019a72c: 00121100 sll r2,r18,0x04                  |Battle ID * 0x10
0019a730: 00521021 addu r2,r2,r18                   |ID * 0x11
0019a734: 000210c0 sll r2,r2,0x03                   |ID * 0x88
0019a738: 24420ef0 addiu r2,r2,0x0ef0               |ID * 0x88 + 0xef0 (Unit offset + Move List offset)
0019a73c: 3c08801a lui r8,0x801a                    |
0019a740: 2508f3c4 addiu r8,r8,0xf3c4               |0x8019f3c4 
0019a744: 01021021 addu r2,r8,r2                    |Unit Move list pointer
0019a748: 00131880 sll r3,r19,0x02                  |Counter * 4 (Ability offset in move list data)
0019a74c: 00621821 addu r3,r3,r2                    |Ability pointer in unit's AI move list
                                                    @LOOP - Will store 3 moves in list (one per ball type)
0019a750: 00901021 addu r2,r4,r16                       |Ball counter + Unit ID * 0x400
0019a754: 2442007d addiu r2,r2,0x007d                   |Unit ID * 0x400 + Ball ID (0x7d + shuriken counter)
0019a758: a0740002 sb r20,0x0002(r3)                    |Store Unit's Skillset in move list data
0019a75c: a4620000 sh r2,0x0000(r3)                     |Store Ball ID in Byte 0x00 and Unit ID * 4 in byte 0x01
0019a760: 24630004 addiu r3,r3,0x0004                   |Next Ability Offset in move list
0019a764: 26100001 addiu r16,r16,0x0001                 |Ball counter + 1
0019a768: 2a020003 slti r2,r16,0x0003                   |Check if Ball counter < 3
0019a76c: 1440fff8 bne r2,r0,0x0019a750             Λ loop 3 times (Fire Ball, Water Ball, Lightning Ball))
0019a770: 26730001 addiu r19,r19,0x0001                 |Ability counter + 1
0019a774: 34100002 ori r16,r0,0x0002            |Throw Ability Counter = 0x02 (After shuriken and Ball in skillset)
0019a778: 02c02021 addu r4,r22,r0               |r4 = Unit's ID
                                                @LOOP - Check/Store all the others abilities in throw skillset
0019a77c: 02802821 addu r5,r20,r0                   |r5 = Unit's Skillset
0019a780: 0c066a94 jal 0x0019aa50                   |-->Load Known Ability Flag returns r2 = 0x01 if ability is known
0019a784: 02003021 addu r6,r16,r0                   |Ability counter (position in skillset)
0019a788: 1440ffac bne r2,r0,0x0019a63c             #If Ability is known : branch backward in weapon inventory section and EXIT
0019a78c: 26100001 addiu r16,r16,0x0001             |Throw Ability Counter ++
0019a790: 2a02000c slti r2,r16,0x000c               |Check if Ability counter reaches 0xc (Nb of abilities in throw skillset)
0019a794: 1440fff9 bne r2,r0,0x0019a77c         Λ Loop for the remaining 11 throw abilities
0019a798: 02c02021 addu r4,r22,r0               |r4 = Unit's ID
0019a79c: 08066a87 j 0x0019aa1c                 >>Jump to END returns r2 as ability counter
0019a7a0: 02601021 addu r2,r19,r0               |r2 = Counter

    ---- Mathematics ---- 
0019a7a4: 17c2000f bne r30,r2,0x0019a7e4    #If Action menu is Mathematics
0019a7a8: 3402000a ori r2,r0,0x000a         |r2 = 0x0a (charge)
0019a7ac: 00121100 sll r2,r18,0x04              |Battle ID * 0x10
0019a7b0: 00521021 addu r2,r2,r18               |ID * 0x11
0019a7b4: 000210c0 sll r2,r2,0x03               |ID * 0x88
0019a7b8: 24420ef0 addiu r2,r2,0x0ef0           |Unit offset + 0x0ef0
0019a7bc: 3c08801a lui r8,0x801a                |
0019a7c0: 2508f3c4 addiu r8,r8,-0x0c3c          |0x8019f3c4
0019a7c4: 00481021 addu r2,r2,r8                |Unit Move's list
0019a7c8: 00131880 sll r3,r19,0x02              |Counter * 4
0019a7cc: 00438821 addu r17,r2,r3               |Unit Move pointer (based on counter)
0019a7d0: 26620001 addiu r2,r19,0x0001          |r2 = Counter + 1
0019a7d4: 00161a80 sll r3,r22,0x0a              |Ability ID * 1024 (ID * 4 Stored in upper byte of halfword)
0019a7d8: a2340002 sb r20,0x0002(r17)           |Store Skillset in Unit Move data 0x02
0019a7dc: 08066a87 j 0x0019aa1c                 >>Jump to  END returns r2 as ability counter (one ability)
0019a7e0: a6230000 sh r3,0x0000(r17)            |Store Unit's ID * 4 in byte 0x01

    ---- Charge ---- 
0019a7e4: 17c2000c bne r30,r2,0x0019a818    #If Action menu is charge
0019a7e8: 001610c0 sll r2,r22,0x03          |Unit's ID * 8
0019a7ec: 001210c0 sll r2,r18,0x03              |Unit's Battle ID * 8
0019a7f0: 3c08801a lui r8,0x801a                |
0019a7f4: 2508f3c4 addiu r8,r8,-0x0c3c          |Start of AI data (0x8019f3c4)
0019a7f8: 00481021 addu r2,r2,r8                |Unit data pointer + Unit offset
0019a7fc: 9050177c lbu r16,0x177c(r2)           |Load Unit's Weapon ID (0x8019f3c4 + 0x1778  + 0x04 + Unit offset)
0019a800: 00000000 nop                          |
0019a804: 2602ffb9 addiu r2,r16,-0x0047         |Weapon ID - 0x47 (Romanda Gun)
0019a808: 2c420006 sltiu r2,r2,0x0006           |Check if weapon ID if between 0x47 and 0x4d (is a gun)
0019a80c: 14400083 bne r2,r0,0x0019aa1c         #Branch to END If Equiped weapon is a gun returns r2 as ability counter
0019a810: 02601021 addu r2,r19,r0               |r2 = Counter
0019a814: 001610c0 sll r2,r22,0x03              |Unit's ID * 8

    ---- Default / Charge (if no guns equiped) / Others (not Maths, not Throw)---- 
0019a818: 00561023 subu r2,r2,r22           |ID * 7
0019a81c: 00021180 sll r2,r2,0x06           |ID * 1c0 (unit offset in battle data)
0019a820: 3c038019 lui r3,0x8019            |
0019a824: 246308cc addiu r3,r3,0x08cc       |
0019a828: 0043a821 addu r21,r2,r3           |r21 = Unit's Data Pointer
0019a82c: 00008021 addu r16,r0,r0           |Ability Counter = 0
0019a830: 00121100 sll r2,r18,0x04          |Battle ID * 16
0019a834: 00521021 addu r2,r2,r18           |ID * 17
0019a838: 000210c0 sll r2,r2,0x03           |ID *0x88 (Unit offset in AI usable move list)
0019a83c: 24420ef0 addiu r2,r2,0x0ef0       |ID * 0x88 + 0xef0 (Unit offset + Move List offset)
0019a840: 3c08801a lui r8,0x801a            |
0019a844: 2508f3c4 addiu r8,r8,-0x0c3c      |0x8019f3c4 
0019a848: 01023821 addu r7,r8,r2            |Unit usable Move list pointer
0019a84c: 0080b821 addu r23,r4,r0           |r23 = Temp List of Abilities Pointer (All ability in skillset)
                                            @LOOP 16 times (All action abilities in the skillset)
0019a850: 96f20000 lhu r18,0x0000(r23)          |Load this iteration Ability ID
0019a854: 00000000 nop                          |
0019a858: 12400060 beq r18,r0,0x0019a9dc        #If Ability ID is not 0x00
0019a85c: 00131880 sll r3,r19,0x02                  |Ability Counter * 4 (Ability offset in move list)
0019a860: 001220c0 sll r4,r18,0x03                  |Ability ID * 8
0019a864: 3c018006 lui r1,0x8006                    |
0019a868: 00240821 addu r1,r1,r4                    |
0019a86c: 9022ebf7 lbu r2,-0x1409(r1)               |Load AI behaviour flags 4 (SCUS data)
0019a870: 00000000 nop                              |
0019a874: 30420080 andi r2,r2,0x0080                |Check if ability is usable by AI
0019a878: 10400058 beq r2,r0,0x0019a9dc             #If AI can use this ability
0019a87c: 00e38821 addu r17,r7,r3                       |r17 = Current Usable Ability Pointer
0019a880: 2a420170 slti r2,r18,0x0170                   |check if ability has an data 2 table (less than potion)
0019a884: 1040002c beq r2,r0,0x0019a938                 #If Ability has a data2 table
0019a888: 00921023 subu r2,r4,r18                           |Ability ID * 7
0019a88c: 00022040 sll r4,r2,0x01                           |Ability ID * 14 (offset in data2)
0019a890: 92a20090 lbu r2,0x0090(r21)                       |Load Unit's Support set 2
0019a894: 3c018006 lui r1,0x8006                            |
0019a898: 00240821 addu r1,r1,r4                            |
0019a89c: 9023fbfd lbu r3,-0x0403(r1)                       |Load Ability's MP Cost 0x8005fbf0 - 0x0d + Ability offset
0019a8a0: 30420080 andi r2,r2,0x0080                        |Check for Half of MP
0019a8a4: 10400002 beq r2,r0,0x0019a8b0                     #If Unit uses Half of MP
0019a8a8: 00000000 nop                                          |
0019a8ac: 00031842 srl r3,r3,0x01                               |Halve MP
0019a8b0: 96a2002e lhu r2,0x002e(r21)                       |Load Unit's Max MP
0019a8b4: 00000000 nop                                      |
0019a8b8: 0043102a slt r2,r2,r3                             |Check if Max MP < MP cost
0019a8bc: 14400047 bne r2,r0,0x0019a9dc                     #If unit could use the Ability (Max MP > MP cost) /Else branch to next iteration (Ability not usable)
0019a8c0: 00000000 nop                                          |
0019a8c4: 3c02801a lui r2,0x801a                                |
0019a8c8: 8c42f3d0 lw r2,-0x0c30(r2)                            |Load AI Behavior Data  When this was updated - should be SCUS?
0019a8cc: 00000000 nop                                          |
0019a8d0: 30420400 andi r2,r2,0x0400                            |Check for check Faith
0019a8d4: 10400006 beq r2,r0,0x0019a8f0                         #If AI used ability has check Faith ON
0019a8d8: 00000000 nop                                              |
0019a8dc: 92a20052 lbu r2,0x0052(r21)                               |Load Unit's Innate Statuses set 5 Innate because this routine is not executed at every turn (Start - unequip - equip change etc..)
0019a8e0: 00000000 nop                                              |
0019a8e4: 30420040 andi r2,r2,0x0040                                |Check for innocent
0019a8e8: 1440003c bne r2,r0,0x0019a9dc                             #If Unit has innocent (innate) Branch to next iteration Ability is not usable
0019a8ec: 00000000 nop                                                  |
0019a8f0: 3c018006 lui r1,0x8006                                |
0019a8f4: 00240821 addu r1,r1,r4                                |
0019a8f8: 9023fbf6 lbu r3,-0x040a(r1)                           |Load Ability Flags 4  ( 0x8005fbf0 - 0x06 + Ability offset)
0019a8fc: 00000000 nop                                          |
0019a900: 30620008 andi r2,r3,0x0008                            |Check fr requires sword
0019a904: 10400004 beq r2,r0,0x0019a918                         #If Ability requires a sword
0019a908: 00000000 nop                                              |
0019a90c: 92a20184 lbu r2,0x0184(r21)                               |Load Unit's Equipped Flags
0019a910: 08066a4c j 0x0019a930                                     >>Avoid matera blade section
0019a914: 30420008 andi r2,r2,0x0008                                |Check for Sword (not null if sword is equipped)
                                                                #Else check materia blade
0019a918: 30620004 andi r2,r3,0x0004                                |Check for requires matera blade
0019a91c: 10400007 beq r2,r0,0x0019a93c                             #If Ability requires a materia blade
0019a920: 02c02021 addu r4,r22,r0                                   |r4 = Unit's ID
0019a924: 92a20184 lbu r2,0x0184(r21)                                   |Load Unit's Equipped Flags
0019a928: 00000000 nop                                                  |
0019a92c: 30420004 andi r2,r2,0x0004                                    |Check for materia blade
0019a930: 1040002a beq r2,r0,0x0019a9dc                             #If Equipment flag is not fullfilled branch to   Next iteration (ability is not usable)
0019a934: 00000000 nop                                                  |
0019a938: 02c02021 addu r4,r22,r0                       |r4 = Unit's ID
0019a93c: 02802821 addu r5,r20,r0                       |r5 = Skillset
0019a940: 02003021 addu r6,r16,r0                       |r6 = Ability Counter
0019a944: 0c066a94 jal 0x0019aa50                       |-->Load Known Ability Flag returns r2 = 0x01 if ability is known
0019a948: afa70018 sw r7,0x0018(r29)                    |Preserve r7
0019a94c: 8fa70018 lw r7,0x0018(r29)                    |Restore r7 (AI unit usable move list pointer)
0019a950: 10400022 beq r2,r0,0x0019a9dc                 #If Ability is known /Else branch to next iteration
0019a954: 2a8200b0 slti r2,r20,0x00b0                       |Check if skillset is a monster skillset
0019a958: 1440000c bne r2,r0,0x0019a98c                     #If Monster skillset
0019a95c: 34020009 ori r2,r0,0x0009                         |r2 = 9
0019a960: 34020003 ori r2,r0,0x0003                             |r2 = 3
0019a964: 16020004 bne r16,r2,0x0019a978                        #If Ability counter = 0x03 (Last monster ability)
0019a968: 00000000 nop                                              |
0019a96c: 96220002 lhu r2,0x0002(r17)                               |Load Ability's skillset and extra behavior data
0019a970: 08066a61 j 0x0019a984                                     |
0019a974: 34420800 ori r2,r2,0x0800                                 |Enable Monster skill needed flag
                                                                #Else : not last monster ability
0019a978: 96220002 lhu r2,0x0002(r17)                               |Load Ability's skillset and extra behavior data
0019a97c: 00000000 nop                                              |
0019a980: 3042f7ff andi r2,r2,0xf7ff                                |Disable Monster Skill Needed flag?
0019a984: a6220002 sh r2,0x0002(r17)                            |Store new Skillset/flags (AI list of usable moves)
0019a988: 34020009 ori r2,r0,0x0009                             |r2 = 9
0019a98c: a2340002 sb r20,0x0002(r17)                       |Store Skillset
0019a990: 17c2000d bne r30,r2,0x0019a9c8                    #If Skillset's action menu is Jump /Else branch to store unit ID
0019a994: a6320000 sh r18,0x0000(r17)                       |Store Ability ID
0019a998: 2a42018f slti r2,r18,0x018f                           |Check if Ability ID is less then 0x18f (vertical jump 2)
0019a99c: 1040000f beq r2,r0,0x0019a9dc                         #If Ability is a "Level Jump" ability /Else branch to next iteration (For now only range matters)
0019a9a0: 34020001 ori r2,r0,0x0001                                 |r2 = 0x01
0019a9a4: 8fa80010 lw r8,0x0010(r29)                                |Load Stored Jump Flag
0019a9a8: 00000000 nop                                              |
0019a9ac: 15020005 bne r8,r2,0x0019a9c4                             #If Jump flag is ON
0019a9b0: 34080001 ori r8,r0,0x0001                                 |Enable Jump flag
0019a9b4: 2673ffff addiu r19,r19,-0x0001                                |Ability counter - 1
0019a9b8: 00131080 sll r2,r19,0x02                                      |Ability offset in AI list of usable moves
0019a9bc: 00e28821 addu r17,r7,r2                                       |r17 = Previous Usable Ability Pointer Was a jump ability (Jump flag is 0x01)
0019a9c0: a6320000 sh r18,0x0000(r17)                                   |Update Ability ID with a better Jump ability
0019a9c4: afa80010 sw r8,0x0010(r29)                                |Store new Jump Stored Flag
0019a9c8: 26730001 addiu r19,r19,0x0001                     #E      |Ability counter + 1
0019a9cc: 96220000 lhu r2,0x0000(r17)                               |Load Ability ID
0019a9d0: 00161a80 sll r3,r22,0x0a                                  |Unit ID * 0x400
0019a9d4: 00431021 addu r2,r2,r3                                    |Ability ID + Unit ID * 0x400
0019a9d8: a6220000 sh r2,0x0000(r17)                                |Store Ability/Unit ID Data
0019a9dc: 26100001 addiu r16,r16,0x0001         |Ability Counter + 1
0019a9e0: 2a020010 slti r2,r16,0x0010           |Check counter Vs 0x10 (Max abilities in a skillset)
0019a9e4: 1440ff9a bne r2,r0,0x0019a850     Λ Loop while Ability Counter < 16
0019a9e8: 26f70002 addiu r23,r23,0x0002         |Ability ID Pointer += 2 (in Temporary list at 0x80066204)
0019a9ec: 34020009 ori r2,r0,0x0009         |r2 = 9
0019a9f0: 17c20009 bne r30,r2,0x0019aa18    #If Action menu is Jump
0019a9f4: 00000000 nop                          |
0019a9f8: 8fa80010 lw r8,0x0010(r29)            |Load Jump Stored Flag
0019a9fc: 00000000 nop                          |
0019aa00: 15000006 bne r8,r0,0x0019aa1c         #If there is no Jump flag stored /Else branch to END and returns r2 = Ability counter
0019aa04: 02601021 addu r2,r19,r0               |r2 = Counter
0019aa08: 34020012 ori r2,r0,0x0012                 |r2 = 0x12
0019aa0c: a2220002 sb r2,0x0002(r17)                |Store Skillset = Jump (Hard coded)
0019aa10: 00161280 sll r2,r22,0x0a                  |Unit ID * 0x400
0019aa14: a6220000 sh r2,0x0000(r17)                |Store Unit's ID *4 in byte 0x01  (known throw ability jump here too)
0019aa18: 02601021 addu r2,r19,r0                   |r2 = Counter (number of usable abilities? is this an AI thing?)
0019aa1c: 8fbf0044 lw r31,0x0044(r29)       END
0019aa20: 8fbe0040 lw r30,0x0040(r29)
0019aa24: 8fb7003c lw r23,0x003c(r29)
0019aa28: 8fb60038 lw r22,0x0038(r29)
0019aa2c: 8fb50034 lw r21,0x0034(r29)
0019aa30: 8fb40030 lw r20,0x0030(r29)
0019aa34: 8fb3002c lw r19,0x002c(r29)
0019aa38: 8fb20028 lw r18,0x0028(r29)
0019aa3c: 8fb10024 lw r17,0x0024(r29)
0019aa40: 8fb00020 lw r16,0x0020(r29)
0019aa44: 27bd0048 addiu r29,r29,0x0048
0019aa48: 03e00008 jr r31
0019aa4c: 00000000 nop

Notes

AI Unit list of usable moves 8019f3c4 - 0x0ef0  
  - Weapon inventory : 3 Abilities for shuriken (1 per type of shuriken)
                       3 Abilities for Ball (1 per type of Ball)
                       1 unique ability for all other weapons (if one is known)
                   0x00 - Item ID if shuriken or Ball - Else 0x00
                   0x01 - Unit ID * 4
                   0x02 - Skillset ID

  - Mathematics : No "known ability" check. 1 Move only.
                  0x00 - Nothing
                  0x01 - Unit ID * 4
                  0x02 - Skillset ID

  - Charge : Ignored if Unit uses a gun (AI data 0x8019f3c4 - 0x1778)
             If not, processed as default

  - Jump : only one ability is stored, either the best "Level jump" one, or no ability ID (if only a vertical jump is known)
            0x00 - Ability ID (or 0x00 if only vertical jump abilities are known)
            0x01 - Unit ID *4
            0x02 - Skillset ID (or 0x12 hardcoded if no level jump ability are known)

  - Default/Others case
            0x00 - Ability ID 
            0x01 - Unit ID *4
            0x02 - Skillset ID 
        Note : Monsters skillsets : The "requires monster skill" flag is Enabled for the 
                                    last ability and disabled for the others. (So the Patcher checkbox seems useless)

Hardcoded mechanics
  - Weapon inventory : Shuriken ID (from 0x7a) and Ball ID (from 0x7d)
                       The loop stops at 0x0c (Any ability beyond this point will be ignored)
  - Charge : Guns are checked by ID (0x47 to 0x4d)
  - Jump skillset hardcoded as 0x12 if only "vertical jump" abilities are known
  - Requires Monster Skill flag : Forced ON for the last ability in skillset (Disabled if not)
 
BUG ?
  - The [Affected by Faith] ability flag is loaded from 0x8019f3c4 - 0x0d Byte. This flag is not updated during the loop, and
    i'm not sure what is stored here at this point. I feel it should be loaded from SCUS data table.

Return Locations

Battle.bin
0019a47c: Set_AI_Flags/Usable_Abilities
0019a4a0: Set_AI_Flags/Usable_Abilities