Evaluate Linear Ability Behaviors

From Final Fantasy Hacktics Wiki
Revision as of 19:42, 12 May 2024 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN :  - Evaluate_Linear_Ability_Behaviors
Set Flags and count Enabled Tiles in AI 0xbdc and AI 0xb94 (Seems to be Table of Tiles from where you can hit a unit and Table of Tiles you can hit)
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : Nothing
------------------------------------------------------------------------------------------
0019c3d4: 27bdff90 addiu r29,r29,-0x0070     |
0019c3d8: afb1004c sw r17,0x004c(r29)        |
0019c3dc: 00008821 addu r17,r0,r0            |Initialize Y counter
0019c3e0: afb5005c sw r21,0x005c(r29)        |
0019c3e4: 3c15801a lui r21,0x801a            |
0019c3e8: 26b5f3c4 addiu r21,r21,-0x0c3c     |0x8019f3c4
0019c3ec: 02a01821 addu r3,r21,r0            |Prepare dynamic pointer to AI Data (1 halfword each iteration)
0019c3f0: afbf006c sw r31,0x006c(r29)        |
0019c3f4: afbe0068 sw r30,0x0068(r29)        |
0019c3f8: afb70064 sw r23,0x0064(r29)        |
0019c3fc: afb60060 sw r22,0x0060(r29)        |
0019c400: afb40058 sw r20,0x0058(r29)        |
0019c404: afb30054 sw r19,0x0054(r29)        |
0019c408: afb20050 sw r18,0x0050(r29)        |
0019c40c: afb00048 sw r16,0x0048(r29)        |
                                            @LOOP - AI Table 0x0bdc
0019c410: a4600bdc sh r0,0x0bdc(r3)              |Initialize 0xbdc
0019c414: a4600c00 sh r0,0x0c00(r3)              |Initialize 0xc00 High Elevation
0019c418: 26310001 addiu r17,r17,0x0001          |Counter +1
0019c41c: 2a220012 slti r2,r17,0x0012            |
0019c420: 1440fffb bne r2,r0,0x0019c410      Λ Loop 0x12 times (whole table)
0019c424: 24630002 addiu r3,r3,0x0002            |Dynamic Pointer to AI data (+1 halfword each iteration)
0019c428: 8ea2000c lw r2,0x000c(r21)         |Load considered AI Ability Behavior Flags 1-4
0019c42c: 3c030080 lui r3,0x0080             |
0019c430: 00431024 and r2,r2,r3              |

Set AI 0x0b94 Table - Reachable Tiles (with proximity conditions based on 0xe2d, Ability Range condition, Ability Usability conditions)
0019c434: 1040000b beq r2,r0,0x0019c464      #If Ability has [Longbow Attack]  AI behavior 0x03 Flag 0x80
0019c438: 26a40b94 addiu r4,r21,0x0b94           |0x8019f3c4 + 0xb94
0019c43c: 92a20e2d lbu r2,0x0e2d(r21)            |AI 0xe2d
0019c440: 34060048 ori r6,r0,0x0048              |Size of Data to transfer in routine below
0019c444: 000228c0 sll r5,r2,0x03                |
0019c448: 00a22821 addu r5,r5,r2                 |
0019c44c: 000528c0 sll r5,r5,0x03                |0xe2d * 0x48
0019c450: 24a50a74 addiu r5,r5,0x0a74            |
0019c454: 0c066ac2 jal 0x0019ab08                |-->Transfer Halfword Values Copy data from AI 0xa74 (based on 0xe2d) to AI 0xb94
0019c458: 02a52821 addu r5,r21,r5                |Pointer to AI 0xa74  + 0xe2d offset
0019c45c: 080671c3 j 0x0019c70c                  >>Jump to  AI 0x0bdc section
0019c460: 0000a021 addu r20,r0,r0                |
                                             Else : Not [Longbow Attack]
0019c464: 0000a021 addu r20,r0,r0                |Initialize Unit counter
0019c468: 02b41021 addu r2,r21,r20               |Dynamic pointer to AI data (1 byte per iteration/unit)
                                                @LOOP - All Units
0019c46c: 90420c8d lbu r2,0x0c8d(r2)                 |This unit potential Target flag
0019c470: 00000000 nop                               |
0019c474: 1040001d beq r2,r0,0x0019c4ec              #If This unit is not a potential target branch to  Next Unit
0019c478: 02802021 addu r4,r20,r0                    |Send Unit ID
0019c47c: 0c067ca9 jal 0x0019f2a4                    |-->Transfer Unit Coordinates to AI Store this Unit coordinates on AI 0x0c74
0019c480: 26a50c74 addiu r5,r21,0x0c74               |Send Pointer
0019c484: 92a30026 lbu r3,0x0026(r21)                |This Ability Targeting Type (Target or Tile)  8019f3c4 + 0x26
0019c488: 34020006 ori r2,r0,0x0006                  |
0019c48c: 14620002 bne r3,r2,0x0019c498              #If AI 0x26 = 0x06 (Target specific ?)
0019c490: 34040002 ori r4,r0,0x0002                  |Not Target Specific checks both Range and AoE
0019c494: 00002021 addu r4,r0,r0                         |Target specifc Ability Checks just Range
0019c498: 0c06723b jal 0x0019c8ec                    |-->Check_if_Linear_Ability_hits_anything_(0019c8ec)  Enable Tile hit by Ability in AI Table 0xb4c (Tile from where you can hit someone with considered Ability ?)
0019c49c: 00002821 addu r5,r0,r0                     |Preset Range = 0x00 (unused with r4 values)

0019c4a0: 92a20e3b lbu r2,0x0e3b(r21)                |Load Max Y
0019c4a4: 00000000 nop                               |
0019c4a8: 18400010 blez r2,0x0019c4ec                #If Max Y is invalid  Avoid loop
0019c4ac: 00008821 addu r17,r0,r0                    |initialize Y counter
0019c4b0: 02a03021 addu r6,r21,r0                    |8019f3c4
                                                    @Loop - Copy from AI 0xb4c to 0xbdc (preserve previous values)
0019c4b4: 26310001 addiu r17,r17,0x0001                  |Y counter + 1
0019c4b8: 94c20bdc lhu r2,0x0bdc(r6)                     |This iteration AI 0xbdc Low elevation Y row
0019c4bc: 94c40b4c lhu r4,0x0b4c(r6)                     |This iteration AI 0xb4c Low elevation Y row
0019c4c0: 94c30c00 lhu r3,0x0c00(r6)                     |This iteration AI 0xbdc High elevation Y row
0019c4c4: 94c50b70 lhu r5,0x0b70(r6)                     |This iteration AI 0xb4c High elevation Y row
0019c4c8: 00441025 or r2,r2,r4                           |
0019c4cc: 00651825 or r3,r3,r5                           |
0019c4d0: a4c20bdc sh r2,0x0bdc(r6)                      |Enable AI 0xb4c flags in AI 0xbdc Table
0019c4d4: a4c30c00 sh r3,0x0c00(r6)                      |Enable AI 0xb4c flags in AI 0xbdc Table High elevation
0019c4d8: 92a20e3b lbu r2,0x0e3b(r21)                    |Load Max Y
0019c4dc: 00000000 nop                                   |
0019c4e0: 0222102a slt r2,r17,r2                         |
0019c4e4: 1440fff3 bne r2,r0,0x0019c4b4              Λ Loop while Y < Max Y
0019c4e8: 24c60002 addiu r6,r6,0x0002                    |Halfword offset for Ai Table
0019c4ec: 26940001 addiu r20,r20,0x0001              |Unit counter + 1
0019c4f0: 2a820015 slti r2,r20,0x0015                |
0019c4f4: 1440ffdd bne r2,r0,0x0019c46c          Λ Loop for all units
0019c4f8: 02b41021 addu r2,r21,r20                   |Dynamic pointer to AI data (1 byte per iteration/unit)
0019c4fc: 92a20e3b lbu r2,0x0e3b(r21)            |Load Max Y
0019c500: 00000000 nop                           |
0019c504: 18400021 blez r2,0x0019c58c            #If Max Y is invalid :  Avoid Loop
0019c508: 00008821 addu r17,r0,r0                |
0019c50c: 02a02821 addu r5,r21,r0                |
                                                @LOOP - Set AI 0x0b94 flags
0019c510: 92a30e2d lbu r3,0x0e2d(r21)                |AI 0x0e2d
0019c514: 00112040 sll r4,r17,0x01                   |
0019c518: 000310c0 sll r2,r3,0x03                    |
0019c51c: 00431021 addu r2,r2,r3                     |
0019c520: 000210c0 sll r2,r2,0x03                    |0xe2d offset (0x48)
0019c524: 02a21021 addu r2,r21,r2                    |
0019c528: 00821021 addu r2,r4,r2                     |Dynamic 8019f3c4 + 0xe2d offset (1 halfword per iteration)
0019c52c: 94420a74 lhu r2,0x0a74(r2)                 |Load this Y iteration flags in Reachable tiles table(based on 0xe2d) low elevation
0019c530: 94a30bdc lhu r3,0x0bdc(r5)                 |Load this Y flags  low elevation
0019c534: 00000000 nop                               |
0019c538: 00431024 and r2,r2,r3                      |
0019c53c: a4a20b94 sh r2,0x0b94(r5)                  |Store in AI 0xb94 only the flags enabled in both AI 0xa74 and 0xbdc Move condition and allow to hit a unit
0019c540: 92a30e2d lbu r3,0x0e2d(r21)                |
0019c544: 00000000 nop                               |
0019c548: 000310c0 sll r2,r3,0x03                    |
0019c54c: 00431021 addu r2,r2,r3                     |
0019c550: 000210c0 sll r2,r2,0x03                    |0xe2d offset (0x48)
0019c554: 02a21021 addu r2,r21,r2                    |
0019c558: 00822021 addu r4,r4,r2                     |Dynamic 8019f3c4 + 0xe2d offset (1 halfword per iteration)
0019c55c: 94820a98 lhu r2,0x0a98(r4)                 |Load this Y iteration flags in Reachable tiles table(based on 0xe2d) high elevation
0019c560: 94a30c00 lhu r3,0x0c00(r5)                 |Load this Y flags  high elevation
0019c564: 26310001 addiu r17,r17,0x0001              |
0019c568: a4a00bdc sh r0,0x0bdc(r5)                  |Reset AI 0xbdc
0019c56c: a4a00c00 sh r0,0x0c00(r5)                  |Reset AI 0xbdc high elevation
0019c570: 00431024 and r2,r2,r3                      |
0019c574: a4a20bb8 sh r2,0x0bb8(r5)                  |Store in AI 0xb94 only the flags enabled in both AI 0xa74 and 0xbdc high elevation
0019c578: 92a20e3b lbu r2,0x0e3b(r21)                |Load Max Y
0019c57c: 00000000 nop                               |
0019c580: 0222102a slt r2,r17,r2                     |
0019c584: 1440ffe2 bne r2,r0,0x0019c510          Λ Loop while Y < Max Y
0019c588: 24a50002 addiu r5,r5,0x0002                |
0019c58c: 00008821 addu r17,r0,r0                |Initialize Elevation counter
0019c590: 341e8000 ori r30,r0,0x8000             |Prepare bitmask
0019c594: 02a0b821 addu r23,r21,r0               |Dynamic pointer to 0x8019f3c4 (+0x24 for high elevation)
                                                @LOOP - both elevation
0019c598: 92a20e3b lbu r2,0x0e3b(r21)                |Load Max Y
0019c59c: 00000000 nop                               |
0019c5a0: 1840003b blez r2,0x0019c690                #If Max Y is invalid : branch to  Next elevation
0019c5a4: 00009021 addu r18,r0,r0                    |Initialize Y counter
0019c5a8: 26f60b94 addiu r22,r23,0x0b94              |Dynamic pointer to AI 0x0b94 (+0x2 per Y rows)
                                                    @LOOP - All Y rows
0019c5ac: 96d40000 lhu r20,0x0000(r22)                   |Load this Y row AI 0x0b94 flags
0019c5b0: 00000000 nop                                   |
0019c5b4: 12800031 beq r20,r0,0x0019c67c                 #If This Row has no flags : branch to  Next Y row
0019c5b8: 00000000 nop                                   |
0019c5bc: 92a30e3a lbu r3,0x0e3a(r21)                    |Load Max X
0019c5c0: 00000000 nop                                   |
0019c5c4: 1060002d beq r3,r0,0x0019c67c                  #if Max X is invalid : branch to  Next Y row
0019c5c8: 00008021 addu r16,r0,r0                        |
0019c5cc: 02c09821 addu r19,r22,r0                       |Dynamic pointer to AI 0x0b94 (+0x2 per Y rows)
0019c5d0: 02141004 sllv r2,r20,r16                       |Tile's Bit of interest is shifted at 0x8000
                                                        @LOOP - All tiles in this Y row
0019c5d4: 30428000 andi r2,r2,0x8000                         |
0019c5d8: 10400023 beq r2,r0,0x0019c668                      #If This Tile Flag is disabled : branch to  Next Tile (keep flag ON)
0019c5dc: 00000000 nop                                       |
0019c5e0: 92a219b9 lbu r2,0x19b9(r21)                        |Load Water Movement Flag
0019c5e4: 00000000 nop                                       |
0019c5e8: 1040000e beq r2,r0,0x0019c624                      #If Acting Unit suffer water penalty
0019c5ec: 02430018 mult r18,r3                                   |
0019c5f0: 00111a00 sll r3,r17,0x08                               |
0019c5f4: 00001012 mflo r2                                       |
0019c5f8: 00501021 addu r2,r2,r16                                |
0019c5fc: 00431021 addu r2,r2,r3                                 |Tile's ID (X + Y*Max X + 0x100 if high elevation)
0019c600: 000210c0 sll r2,r2,0x03                                |8 bytes per tile ID
0019c604: 3c018019 lui r1,0x8019                                 |
0019c608: 00220821 addu r1,r1,r2                                 |
0019c60c: 9022f8cf lbu r2,-0x0731(r1)                            |This Tile height + depth 8018f8cc + 0x03 + Tile's offset
0019c610: 00000000 nop                                           |
0019c614: 00021142 srl r2,r2,0x05                                |Keep only depth
0019c618: 28420002 slti r2,r2,0x0002                             |
0019c61c: 1040000e beq r2,r0,0x0019c658                          #if Depth is 2 or more : branch and Disable this tile
0019c620: 00000000 nop                                           |
                                                             Else : Water is not a problem (by Ability or depth)
0019c624: 92a20000 lbu r2,0x0000(r21)                            |Considered Ability Skillset ID
0019c628: 3c018006 lui r1,0x8006                                 |
0019c62c: 00220821 addu r1,r1,r2                                 |
0019c630: 90235cb4 lbu r3,0x5cb4(r1)                             |Considered skillset action menu 80065cb4 + Skillset offset
0019c634: 34020004 ori r2,r0,0x0004                              |
0019c638: 1462000b bne r3,r2,0x0019c668                          #If Action Menu is not [Elements] : branch to  Next Tile (keep flag ON)
0019c63c: 26a40c74 addiu r4,r21,0x0c74                           |Pointer to AI 0xc74
0019c640: a2b00c74 sb r16,0x0c74(r21)                            |Store X at AI 0xc74
0019c644: a2b20c76 sb r18,0x0c76(r21)                            |Store Y at AI 0xc76
0019c648: 0c066dd5 jal 0x0019b754                                |-->See_if_elemental_ability_can_be_used Check Terrain Type Vs Ability ID (from AI 0x02)
0019c64c: a2b10c75 sb r17,0x0c75(r21)                            |Store elevation at AI 0xc75
0019c650: 14400005 bne r2,r0,0x0019c668                          #If considered Ability matches terrain type Next Tile (keep flag ON)
0019c654: 00000000 nop                                               |
                                                             Else : Depth > 2 or Unusable geomancy ability
0019c658: 96630000 lhu r3,0x0000(r19)                            |This Y rows flags
0019c65c: 021e1007 srav r2,r30,r16                               |This tile bitmask
0019c660: 00621826 xor r3,r3,r2                                  |
0019c664: a6630000 sh r3,0x0000(r19)                             |Disable this tile in AI 0xb94
0019c668: 92a30e3a lbu r3,0x0e3a(r21)                        |Max X
0019c66c: 26100001 addiu r16,r16,0x0001                      |X counter +1
0019c670: 0203102a slt r2,r16,r3                             |
0019c674: 1440ffd7 bne r2,r0,0x0019c5d4                  Λ Loop while X < Max X
0019c678: 02141004 sllv r2,r20,r16                           |
0019c67c: 92a20e3b lbu r2,0x0e3b(r21)                    |Max Y
0019c680: 26520001 addiu r18,r18,0x0001                  |Y counter + 1
0019c684: 0242102a slt r2,r18,r2                         |
0019c688: 1440ffc8 bne r2,r0,0x0019c5ac              Λ loop while Y < Max Y
0019c68c: 26d60002 addiu r22,r22,0x0002                  |Y offset (+ 1 halfword each iteration)
0019c690: 26310001 addiu r17,r17,0x0001              |Elevation + 1
0019c694: 2a220002 slti r2,r17,0x0002                |
0019c698: 1440ffbf bne r2,r0,0x0019c598          Λ loop 2 times
0019c69c: 26f70024 addiu r23,r23,0x0024              |Elevation Offset (+0x24 for high elevation)
0019c6a0: 8ea2000c lw r2,0x000c(r21)             |Load AI Behavior Flags 1 to 4
0019c6a4: 3c030800 lui r3,0x0800                 |
0019c6a8: 00431024 and r2,r2,r3                  | Flag 0x08 of AI 0x0f is a copy of Ability 0xef0 0x03 so this should be a monster skill check
0019c6ac: 10400016 beq r2,r0,0x0019c708          #If This Ability requires monster skill
0019c6b0: 00000000 nop                               |
0019c6b4: 0c0672e5 jal 0x0019cb94                    |-->Some_height/Map_coordinate_calculation_for_all_units Enable Tile Adjacent to an Ally with monster skill in AI 0xb4c
0019c6b8: 00008821 addu r17,r0,r0                    |
0019c6bc: 92a20e3b lbu r2,0x0e3b(r21)                |Max Y
0019c6c0: 00000000 nop                               |
0019c6c4: 18400010 blez r2,0x0019c708                #if Max Y is Invalid :  Avoid loop
0019c6cc: 02a03021 addu r6,r21,r0                    |Dynamic pointer to 0x8019f3c4 (+1 halfword each oteration)
                                                    @LOOP
0019c6d0: 26310001 addiu r17,r17,0x0001                  |Y counter + 1
0019c6d4: 94c20b94 lhu r2,0x0b94(r6)                     |This Y row Flags from AI 0x0b94
0019c6d8: 94c40b4c lhu r4,0x0b4c(r6)                     |This Y row Flags from AI 0x0b4c
0019c6dc: 94c30bb8 lhu r3,0x0bb8(r6)                     |This Y row Flags from AI 0x0b94 high elevation
0019c6e0: 94c50b70 lhu r5,0x0b70(r6)                     |This Y row Flags from AI 0x0b4c high elevation
0019c6e4: 00441024 and r2,r2,r4                          |
0019c6e8: 00651824 and r3,r3,r5                          |
0019c6ec: a4c20b94 sh r2,0x0b94(r6)                      |Keep only the flags enabled in both Table in AI 0xb94 high elevation
0019c6f0: a4c30bb8 sh r3,0x0bb8(r6)                      |Keep only the flags enabled in both Table in AI 0xb94 high elevation
0019c6f4: 92a20e3b lbu r2,0x0e3b(r21)                    |
0019c6f8: 00000000 nop                                   |Max Y
0019c6fc: 0222102a slt r2,r17,r2                         |
0019c700: 1440fff3 bne r2,r0,0x0019c6d0              Λ Loop while Y < Max Y
0019c704: 24c60002 addiu r6,r6,0x0002                    |
0019c708: 0000a021 addu r20,r0,r0            |Initialize Unit Counter
0019c70c: 02b41021 addu r2,r21,r20           |Prepare dynamic pointer to 0x8019f3c4 (1 byte per iteration)

Set AI 0xbdc Table - Targetable Tiles to Hit a Unit
                                            @LOOP - All Units
0019c710: 90420c8d lbu r2,0x0c8d(r2)             |Load This Unit Targetable flag in AI 0x0c8d
0019c714: 00000000 nop                           |
0019c718: 1040001d beq r2,r0,0x0019c790          #If Unit is not a potential Target : branch to Next unit
0019c71c: 02802021 addu r4,r20,r0                |Send Unit ID
0019c720: 0c067ca9 jal 0x0019f2a4                |-->Transfer Unit Coordinates to AI Store Unit coordinates on r5
0019c724: 26a50c74 addiu r5,r21,0x0c74           |Send AI 0x0c74 pointer
0019c728: 92a30026 lbu r3,0x0026(r21)            |Considered Ability Targeting type
0019c72c: 34020006 ori r2,r0,0x0006              |
0019c730: 14620002 bne r3,r2,0x0019c73c          #If Targeting type is 0x06 (Target specific)
0019c734: 34040001 ori r4,r0,0x0001              |Spread AoE if Tile specific Targeting
0019c738: 34040003 ori r4,r0,0x0003                  |Spread Nothing (use r5 = 0x00) if Target specific
0019c73c: 0c06723b jal 0x0019c8ec                |-->Check_if_Linear_Ability_hits_anything_(0019c8ec) Set AI 0xb4c flags
0019c740: 00002821 addu r5,r0,r0                 |Send 0x00
0019c744: 92a20e3b lbu r2,0x0e3b(r21)            |Load Max Y
0019c748: 00000000 nop                           |
0019c74c: 18400010 blez r2,0x0019c790            #If Max Y is invalid : branch to  Next Unit
0019c750: 00008821 addu r17,r0,r0                |Initialize Y counter
0019c754: 02a03021 addu r6,r21,r0                |Prepare dynamic pointer to 0x8019f3c4 (1halfword per iteration)
                                                @LOOP - Y rows in AI Tables
0019c758: 26310001 addiu r17,r17,0x0001              |Unit Counter + 1
0019c75c: 94c20bdc lhu r2,0x0bdc(r6)                 |This Y row Flags from AI 0x0bdc
0019c760: 94c40b4c lhu r4,0x0b4c(r6)                 |This Y row Flags from AI 0x0b4c
0019c764: 94c30c00 lhu r3,0x0c00(r6)                 |This Y row Flags from AI 0x0bdc high elevation
0019c768: 94c50b70 lhu r5,0x0b70(r6)                 |This Y row Flags from AI 0x0b4c high elevation
0019c76c: 00441025 or r2,r2,r4                       |
0019c770: 00651825 or r3,r3,r5                       |
0019c774: a4c20bdc sh r2,0x0bdc(r6)                  |Enable AI 0xb4c flags in AI Table 0xbdc
0019c778: a4c30c00 sh r3,0x0c00(r6)                  |Enable AI 0xb4c flags in AI Table 0xbdc high elevation
0019c77c: 92a20e3b lbu r2,0x0e3b(r21)                |Load Max Y
0019c780: 00000000 nop                               |
0019c784: 0222102a slt r2,r17,r2                     |
0019c788: 1440fff3 bne r2,r0,0x0019c758          #Loop while Y < Max Y
0019c78c: 24c60002 addiu r6,r6,0x0002                |Offset for AI Pointer (1 halword)
0019c790: 26940001 addiu r20,r20,0x0001          |Unit counter +1
0019c794: 2a820015 slti r2,r20,0x0015            |
0019c798: 1440ffdd bne r2,r0,0x0019c710      #Loop for all units
0019c79c: 02b41021 addu r2,r21,r20               |Offset for AI pointer
0019c7a0: 8ea2000c lw r2,0x000c(r21)         |Load AI Ability Behavior Flags 1-4
0019c7a4: 00000000 nop                       |
0019c7a8: 30421000 andi r2,r2,0x1000         |
0019c7ac: 10400025 beq r2,r0,0x0019c844      #if considered Ability has [Check CT/Target]
0019c7b0: 00000000 nop                           |
0019c7b4: 0000a021 addu r20,r0,r0                |Initialize Unit counter
0019c7b8: 34080005 ori r8,r0,0x0005              |Targeting type to check
0019c7bc: 34078000 ori r7,r0,0x8000              |Prepare bitmask
0019c7c0: 3c068019 lui r6,0x8019                 |
0019c7c4: 24c608cc addiu r6,r6,0x08cc            |Prepare dynamic pointer to Unit Battle data
                                                @LOOP
0019c7c8: 02b41021 addu r2,r21,r20                   |AI dynamic pointer (1 byte per unit)
0019c7cc: 90420c8d lbu r2,0x0c8d(r2)                 |This Unit Potential target flag
0019c7d0: 00000000 nop                               |
0019c7d4: 10400017 beq r2,r0,0x0019c834              #Is this unit is not a potential target : branch to  Next Unit
0019c7d8: 00c02821 addu r5,r6,r0                     |This Unit Battle pointer
0019c7dc: 90c20058 lbu r2,0x0058(r6)                 |Load Current Status 1
0019c7e0: 92a30026 lbu r3,0x0026(r21)                |Considered Ability targeting type
0019c7e4: 00000000 nop                               |
0019c7e8: 10680003 beq r3,r8,0x0019c7f8              #If Targeting type is not 0x05
0019c7ec: 30420004 andi r2,r2,0x0004                     |
0019c7f0: 10400010 beq r2,r0,0x0019c834                  #If This Unit is not Jumping : branch to  Next Unit (keep unit flag)
0019c7f4: 00000000 nop                                       |
                                                     Else : If Targeting type is 0x05 or 0x06 but unit is not Jumping
0019c7f8: 94a30048 lhu r3,0x0048(r5)                     |Unit Y + Elevation
0019c7fc: 90a40048 lbu r4,0x0048(r5)                     |Unit Y
0019c800: 00031bc2 srl r3,r3,0x0f                        |Unit Elevation
0019c804: 000310c0 sll r2,r3,0x03                        |
0019c808: 00431021 addu r2,r2,r3                         |
0019c80c: 00021080 sll r2,r2,0x02                        |Elevation * 0x24
0019c810: 00551021 addu r2,r2,r21                        |
0019c814: 24420bdc addiu r2,r2,0x0bdc                    |
0019c818: 00042040 sll r4,r4,0x01                        |Y * 2
0019c81c: 00822021 addu r4,r4,r2                         |Pointer to Unit AI 0x0bdc Y row
0019c820: 90a20047 lbu r2,0x0047(r5)                     |Load Unit X
0019c824: 94830000 lhu r3,0x0000(r4)                     |Unit Y row flags in AI 0x0bdcTable
0019c828: 00471007 srav r2,r7,r2                         |Unit Tile Bitmask
0019c82c: 00621826 xor r3,r3,r2                          |
0019c830: a4830000 sh r3,0x0000(r4)                      |Disable Unit Tile's Flag in AI 0x0bdc Why ? 
0019c834: 26940001 addiu r20,r20,0x0001              |Unit counter + 1
0019c838: 2a820015 slti r2,r20,0x0015                |
0019c83c: 1440ffe2 bne r2,r0,0x0019c7c8          #Loop for all units
0019c840: 24c601c0 addiu r6,r6,0x01c0                |Battle data offset
0019c844: 00008821 addu r17,r0,r0            |Initialize Elevation counter
0019c848: 02a03021 addu r6,r21,r0            |Prepare Dynamic pointer to AI data
                                            @LOOP
0019c84c: 92a20e3b lbu r2,0x0e3b(r21)            |Load Max Y
0019c850: 00000000 nop                           |
0019c854: 1840000e blez r2,0x0019c890            #If Max Y is invalid : branch to  Next elevation
0019c858: 00009021 addu r18,r0,r0                |Initialize Y counter
0019c85c: 24c40bdc addiu r4,r6,0x0bdc            |Dynamic pointer to AI 0x0bdc
0019c860: 24c50c24 addiu r5,r6,0x0c24            |Dynamic pointer to AI 0x0c24
                                                @LOOP
0019c864: 94a20000 lhu r2,0x0000(r5)                 |This Y row AI 0xc24 flags
0019c868: 24a50002 addiu r5,r5,0x0002                |Offset for AI 0xc24 pointer
0019c86c: 94830000 lhu r3,0x0000(r4)                 |This Y row AI 0xbdc flags
0019c870: 26520001 addiu r18,r18,0x0001              |Y counter +1
0019c874: 00621824 and r3,r3,r2                      |
0019c878: a4830000 sh r3,0x0000(r4)                  |Keep only flags in both Table in AI 0xbdc 0xc24 is Valid Tiles flags (Not unselectable nor cross section)
0019c87c: 92a20e3b lbu r2,0x0e3b(r21)                |Max Y
0019c880: 00000000 nop                               |
0019c884: 0242102a slt r2,r18,r2                     |
0019c888: 1440fff6 bne r2,r0,0x0019c864          Λ Loop while Y < Max Y
0019c88c: 24840002 addiu r4,r4,0x0002                |Offset for AI 0xbdc pointer
0019c890: 26310001 addiu r17,r17,0x0001              |
0019c894: 2a220002 slti r2,r17,0x0002                |
0019c898: 1440ffec bne r2,r0,0x0019c84c      Λ Loop
0019c89c: 24c60024 addiu r6,r6,0x0024            |Elevation offset

0019c8a0: 0c065f1a jal 0x00197c68                |-->Final Targeting Check Count Tiles enabled in AI 0x0bdc
0019c8a4: 26a40bdc addiu r4,r21,0x0bdc           |Send Pointer to AI 0x0bdc
0019c8a8: 26a40b94 addiu r4,r21,0x0b94           |Send Pointer to AI 0x0b94
0019c8ac: 0c065f1a jal 0x00197c68                |-->Final Targeting Check Count Tiles enabled in AI 0x0b94
0019c8b0: a2a20cbb sb r2,0x0cbb(r21)             |Store Nb of Tiles enabled in AI 0x0bdc
0019c8b4: a2a20cbc sb r2,0x0cbc(r21)             |Store Nb of Tiles enabled in AI 0x0b94
0019c8b8: 8fbf006c lw r31,0x006c(r29)
0019c8bc: 8fbe0068 lw r30,0x0068(r29)
0019c8c0: 8fb70064 lw r23,0x0064(r29)
0019c8c4: 8fb60060 lw r22,0x0060(r29)
0019c8c8: 8fb5005c lw r21,0x005c(r29)
0019c8cc: 8fb40058 lw r20,0x0058(r29)
0019c8d0: 8fb30054 lw r19,0x0054(r29)
0019c8d4: 8fb20050 lw r18,0x0050(r29)
0019c8d8: 8fb1004c lw r17,0x004c(r29)
0019c8dc: 8fb00048 lw r16,0x0048(r29)
0019c8e0: 27bd0070 addiu r29,r29,0x0070
0019c8e4: 03e00008 jr r31
0019c8e8: 00000000 nop

Return locations

BATTLE.BIN
 001977b8: Store_ability/skillset_data,_set_AI_settings_for_ability?
 001977e0: Store_ability/skillset_data,_set_AI_settings_for_ability?
 0019bfc0: Find_Highest_Target_Priority_in_Ability_Range_(0019bf2c)