Difference between revisions of "Check Allies/Enemies that can be Targeted"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (link to 0x0017bdd0)
 
Line 1: Line 1:
 
+
Parameters : r4 = Attacker ID
  Check Allies/Enemies that can be Targeted
+
              r5 = 0x80 if Ability ignores enemy unit
  0017bc78: 27bdffc0 addiu r29,r29,0xffc0
+
              r6 = 0x40 if Ability ignores allies
  0017bc7c: afb5002c sw r21,0x002c(r29)
+
              r7 = 0x01 if Ability AoE is 255
  0017bc80: 00a0a821 addu r21,r5,r0 r21 = Can Hit Enemies Flag
+
  0017bc84: afb60030 sw r22,0x0030(r29)
+
Nullify AoE of targetable panel if unit is in a team to ignores
  0017bc88: 00c0b021 addu r22,r6,r0 r22 = Can Hit Allies Flag
+
  Set targetable panel 0x01 flag "ON" (= 0x01) if unit is not in the team to ignore (does not take AoE into account)
  0017bc8c: afb70034 sw r23,0x0034(r29)
+
If Targetable panel AoE is > 0x00 set targetable panel 0x01 flag ON
  0017bc90: 00e0b821 addu r23,r7,r0 r23 = 255 AoE check
+
----------------------------------------------------------------------------------
  0017bc94: 308400ff andi r4,r4,0x00ff r4 = Attacker/Self? ID
+
  0017bc78: 27bdffc0 addiu r29,r29,-0x0040    |
  0017bc98: 000410c0 sll r2,r4,0x03 ID * 8
+
  0017bc7c: afb5002c sw r21,0x002c(r29)       |
  0017bc9c: 00441023 subu r2,r2,r4 ID * 7
+
  0017bc80: 00a0a821 addu r21,r5,r0           |{{f/std|<nowiki>r21 = Ignore enemy Flag</nowiki>}}
  0017bca0: 00021180 sll r2,r2,0x06 ID * 448
+
  0017bc84: afb60030 sw r22,0x0030(r29)       |
  0017bca4: afb30024 sw r19,0x0024(r29)
+
  0017bc88: 00c0b021 addu r22,r6,r0           |{{f/std|<nowiki>r22 = Ignore ally Flag</nowiki>}}
  0017bca8: 00809821 addu r19,r4,r0 r19 = Attacker/Self ID
+
  0017bc8c: afb70034 sw r23,0x0034(r29)       |
  0017bcac: afb00018 sw r16,0x0018(r29)
+
  0017bc90: 00e0b821 addu r23,r7,r0           |{{f/std|<nowiki>r23 = 0x01 if Ability AoE is 255</nowiki>}}
  0017bcb0: 00008021 addu r16,r0,r0 Unit Counter = 0
+
  0017bc94: 308400ff andi r4,r4,0x00ff       |{{f/std|<nowiki>r4 = clean Attacker ID</nowiki>}}
  0017bcb4: afb20020 sw r18,0x0020(r29)
+
  0017bc98: 000410c0 sll r2,r4,0x03           |{{f/std|<nowiki>r2 = Attacker ID * 8</nowiki>}}
  0017bcb8: 34120001 ori r18,r0,0x0001 r18 = 1
+
  0017bc9c: 00441023 subu r2,r2,r4           |{{f/std|<nowiki>r2 = Attacker ID * 7</nowiki>}}
  0017bcbc: afb1001c sw r17,0x001c(r29)
+
  0017bca0: 00021180 sll r2,r2,0x06           |{{f/std|<nowiki>r2 = Attacker ID * 448 (size of unit data)</nowiki>}}
  0017bcc0: 00008821 addu r17,r0,r0 Pointer Mod = 0
+
  0017bca4: afb30024 sw r19,0x0024(r29)       |
  0017bcc4: afbf0038 sw r31,0x0038(r29)
+
  0017bca8: 00809821 addu r19,r4,r0           |{{f/std|<nowiki>r19 = Attacker ID</nowiki>}}
  0017bcc8: afb40028 sw r20,0x0028(r29)
+
  0017bcac: afb00018 sw r16,0x0018(r29)       |
  0017bccc: 3c018019 lui r1,0x8019
+
  0017bcb0: 00008021 addu r16,r0,r0           |{{f/std|<nowiki>r16 = 0x00 (loop counter)</nowiki>}}
  0017bcd0: 00220821 addu r1,r1,r2
+
  0017bcb4: afb20020 sw r18,0x0020(r29)       |
  0017bcd4: 903408d1 lbu r20,0x08d1(r1) Load Unit's ENTD Flags
+
  0017bcb8: 34120001 ori r18,r0,0x0001       |{{f/std|<nowiki>r18 = 0x01</nowiki>}}
  0017bcd8: 02002021 addu r4,r16,r0 r4 = Unit Counter
+
  0017bcbc: afb1001c sw r17,0x001c(r29)       |
  0017bcdc: 0c05ef74 jal 0x 0017bdd0 {{F/jal|Check_if_Unit_can_be_Targeted|Check_if_Unit_can_be_Targeted}}
+
  0017bcc0: 00008821 addu r17,r0,r0           |{{f/std|<nowiki>r17 = 0x00 (unit pointer in unit data, +0x1c0 each loop iteration)</nowiki>}}
  0017bce0: 27a50010 addiu r5,r29,0x0010 r5 = Stack Pointer
+
  0017bcc4: afbf0038 sw r31,0x0038(r29)       |
  0017bce4: 1440001c bne r2,r0,0x 0017bd58 Branch if Unit Can't be targeted
+
  0017bcc8: afb40028 sw r20,0x0028(r29)       |
  0017bce8: 00000000 nop
+
  0017bccc: 3c018019 lui r1,0x8019           |
  0017bcec: 3c018019 lui r1,0x8019
+
  0017bcd0: 00220821 addu r1,r1,r2           |{{f/adr|<nowiki>r1 = 0x80190000 + Attacker ID*448</nowiki>}}
  0017bcf0: 00310821 addu r1,r1,r17
+
  0017bcd4: 903408d1 lbu r20,0x08d1(r1)       |{{f/load|<nowiki>r20 = Attacker ENTD's flag</nowiki>}} {{f/std|<nowiki> ( 0x801908cc + 0x05 = 0x801908d1 )</nowiki>}}
  0017bcf4: 90220a86 lbu r2,0x0a86(r1) Load Unit's Modified ENTD Flags
+
  0017bcd8: 02002021 addu r4,r16,r0           {{f/bloop|<nowiki>LOOP through all units</nowiki>}} {{f/std|<nowiki>r4 = Loop counter (unit counter)</nowiki>}}
  0017bcf8: 00000000 nop
+
  0017bcdc: 0c05ef74 jal 0x0017bdd0                |{{f/jal|Check_if_Unit_can_be_Targeted|<nowiki>Check_if_Unit_can_be_Targeted</nowiki>}} Return 0x00 if can be targeted + unit tile ID on r5
  0017bcfc: 02821026 xor r2,r20,r2
+
  0017bce0: 27a50010 addiu r5,r29,0x0010           |{{f/std|<nowiki>r5 = Stack Pointer</nowiki>}}
  0017bd00: 16700002 bne r19,r16,0x 0017bd0c Branch if Attacker/Self ID != Unit Counter
+
  0017bce4: 1440001c bne r2,r0,0x0017bd58          {{f/Cond|<nowiki>If unit can be targeted</nowiki>}}
  0017bd04: 00402021 addu r4,r2,r0 Teams Different? = Differing ENTD Flags
+
  0017bce8: 00000000 nop                               |{{f/std|<nowiki> </nowiki>}}
  0017bd08: 00002021 addu r4,r0,r0 Teams Different? = False
+
  0017bcec: 3c018019 lui r1,0x8019                     |{{f/std|<nowiki>r1 = 0x80190000</nowiki>}}
  0017bd0c: 8fa30010 lw r3,0x0010(r29) Load Tile ID
+
  0017bcf0: 00310821 addu r1,r1,r17                   |{{f/std|<nowiki>r1 = 0x80190000 + unit data offset (0x1c0 each iteration)</nowiki>}}
  0017bd10: 00000000 nop
+
  0017bcf4: 90220a86 lbu r2,0x0a86(r1)                 |{{f/load|<nowiki>r2 = This iteration unit modified ENTD flag</nowiki>}}
  0017bd14: 00031080 sll r2,r3,0x02 ID * 4
+
  0017bcf8: 00000000 nop                               |
  0017bd18: 00431021 addu r2,r2,r3 ID * 5
+
  0017bcfc: 02821026 xor r2,r20,r2                     |{{f/std|<nowiki>r2 = every differences between attacker and this iteration unit ENTD flags - (Team ID in it) (0x00 if same ENTD's flag)</nowiki>}}
  0017bd1c: 3c038019 lui r3,0x8019
+
  0017bd00: 16700002 bne r19,r16,0x0017bd0c            {{f/Cond|<nowiki>If This iteration unit is Attacker</nowiki>}}
  0017bd20: 24632dd8 addiu r3,r3,0x2dd8
+
  0017bd04: 00402021 addu r4,r2,r0                     |{{f/std|<nowiki>r4 = Differing ENTD Flags</nowiki>}}
  0017bd24: 00431821 addu r3,r2,r3
+
  0017bd08: 00002021 addu r4,r0,r0                         |{{f/std|<nowiki>r4 = 0x00 (nullify ENTD difference)</nowiki>}}
  0017bd28: 90620000 lbu r2,0x0000(r3) Load Tile's AoE
+
  0017bd0c: 8fa30010 lw r3,0x0010(r29)                 |{{f/adr|<nowiki>r3 = This iteration Unit's Tile ID</nowiki>}}
  0017bd2c: 00000000 nop
+
  0017bd10: 00000000 nop                               |
  0017bd30: 10400009 beq r2,r0,0x 0017bd58 Branch if AoE = 0
+
  0017bd14: 00031080 sll r2,r3,0x02                   |{{f/std|<nowiki>r2 = This iteration Unit's Tile ID * 4</nowiki>}}
  0017bd34: 30820030 andi r2,r4,0x0030
+
  0017bd18: 00431021 addu r2,r2,r3                     |{{f/std|<nowiki>r2 = This iteration Unit's Tile ID * 5</nowiki>}}
  0017bd38: 14400002 bne r2,r0,0x 0017bd44 Branch if Teams are different
+
  0017bd1c: 3c038019 lui r3,0x8019                     |
  0017bd3c: 32c200ff andi r2,r22,0x00ff r2 = Can Hit Allies Flag
+
  0017bd20: 24632dd8 addiu r3,r3,0x2dd8               |{{f/std|<nowiki>r3 = Targetable grid data pointer</nowiki>}}
  0017bd40: 32a200ff andi r2,r21,0x00ff r2 = Can Hit Enemies Flag
+
  0017bd24: 00431821 addu r3,r2,r3                     |{{f/std|<nowiki>r3 = This iteration Unit's Targetable panel data pointer</nowiki>}}
  0017bd44: 10400003 beq r2,r0,0x 0017bd54 Branch if Ability can't target this unit
+
  0017bd28: 90620000 lbu r2,0x0000(r3)                 |{{f/load|<nowiki>r2 = This iteration Unit's Targetable panel AoE</nowiki>}}
  0017bd48: 00000000 nop
+
  0017bd2c: 00000000 nop                               |
  0017bd4c: 0805ef56 j 0x 0017bd58
+
  0017bd30: 10400009 beq r2,r0,0x0017bd58              {{f/Cond|<nowiki>If This iteration Unit's Targetable panel AoE > 0x00</nowiki>}}
  0017bd50: a0720001 sb r18,0x0001(r3) Store Tile Targeted? = True
+
  0017bd34: 30820030 andi r2,r4,0x0030                     |{{f/std|<nowiki>r2  <> 0x00 if Attacker and this iteration Unit are not in the same Team (Differing ENTD flag filtered on Team difference)</nowiki>}}
  0017bd54: a0600000 sb r0,0x0000(r3) Store Tile Targeted? = False
+
  0017bd38: 14400002 bne r2,r0,0x0017bd44                  {{f/Cond|<nowiki>If No team difference</nowiki>}} /Else branch keeping r2 = Avoid ally flag
  0017bd58: 26100001 addiu r16,r16,0x0001 Unit Counter ++
+
  0017bd3c: 32c200ff andi r2,r22,0x00ff                   |{{f/std|<nowiki>r2 = Ignore ally flag</nowiki>}}
  0017bd5c: 2a020015 slti r2,r16,0x0015
+
  0017bd40: 32a200ff andi r2,r21,0x00ff                       |{{f/std|<nowiki>r2 = Ignore enemy flag</nowiki>}}
  0017bd60: 1440ffdd bne r2,r0,0x 0017bcd8 Branch if Unit Counter < 0x15
+
  0017bd44: 10400003 beq r2,r0,0x0017bd54                  {{f/Cond|<nowiki>If This iteration unit is not in the team to ignore</nowiki>}} /Else , ignore Team (do not restore the targeted flag and nullify AoE)
  0017bd64: 263101c0 addiu r17,r17,0x01c0 Pointer Mod += 0x1c0
+
  0017bd48: 00000000 nop                                       |
  0017bd68: 32e200ff andi r2,r23,0x00ff
+
  0017bd4c: 0805ef56 j 0x0017bd58                              {{f/jump|<nowiki>jump to next iteration (after set the panel targeted flag ON)</nowiki>}}
  0017bd6c: 1440000c bne r2,r0,0x 0017bda0 Branch if AoE = 255
+
  0017bd50: a0720001 sb r18,0x0001(r3)                         |{{f/store|<nowiki>Turn targetable panel targeted flag ON (= 0x01)</nowiki>}}  * panel 0x01 byte
  0017bd70: 00008021 addu r16,r0,r0 Tile Counter = 0
+
  0017bd54: a0600000 sb r0,0x0000(r3)                     {{f/Cond|<nowiki>Else (Team to avoid)</nowiki>}} {{f/store|<nowiki>Nullify Targetable panel AoE </nowiki>}}
  0017bd74: 34040001 ori r4,r0,0x0001 Tile Targeted? = True
+
  0017bd58: 26100001 addiu r16,r16,0x0001         |{{f/std|<nowiki>r16 = loop counter + 1</nowiki>}}
  0017bd78: 3c038019 lui r3,0x8019
+
  0017bd5c: 2a020015 slti r2,r16,0x0015           |{{f/std|<nowiki>r2 = 0x01 if counter < 0x15</nowiki>}}
  0017bd7c: 24632dd8 addiu r3,r3,0x2dd8
+
  0017bd60: 1440ffdd bne r2,r0,0x0017bcd8    {{f/eloop|<nowiki>loop while unit counter < 0x15</nowiki>}}
  0017bd80: 90620000 lbu r2,0x0000(r3) Load Tile's AoE
+
  0017bd64: 263101c0 addiu r17,r17,0x01c0         |{{f/std|<nowiki>r1 = unit data Pointer Mod += 0x1c0</nowiki>}}
  0017bd84: 00000000 nop
+
  0017bd68: 32e200ff andi r2,r23,0x00ff       |{{f/std|<nowiki>r2 = 0x01 if Ability AoE is 255</nowiki>}}
  0017bd88: 10400002 beq r2,r0,0x 0017bd94 Branch if AoE = 0
+
  0017bd6c: 1440000c bne r2,r0,0x0017bda0    {{f/Cond|<nowiki>If Ability AoE is not 255</nowiki>}} /Else branch to {{f/loc|<nowiki>END</nowiki>}}
  0017bd8c: 26100001 addiu r16,r16,0x0001 Tile Counter ++
+
  0017bd70: 00008021 addu r16,r0,r0               |{{f/std|<nowiki>r16 = 0x00 (loop counter)</nowiki>}}
  0017bd90: a0640001 sb r4,0x0001(r3) Store Tile Targeted? = True
+
  0017bd74: 34040001 ori r4,r0,0x0001             |{{f/std|<nowiki>r4 = 0x01</nowiki>}}
  0017bd94: 2a020200 slti r2,r16,0x0200
+
  0017bd78: 3c038019 lui r3,0x8019                 |
  0017bd98: 1440fff9 bne r2,r0,0x 0017bd80 Branch if Tile Counter < 0x200
+
  0017bd7c: 24632dd8 addiu r3,r3,0x2dd8           |{{f/adr|<nowiki>r3 = 0x80192dd8 ( targetable panel grid)</nowiki>}}
  0017bd9c: 24630005 addiu r3,r3,0x0005 Pointer += 5
+
  0017bd80: 90620000 lbu r2,0x0000(r3)             {{f/bloop|<nowiki>LOOP through all targetable panel</nowiki>}} {{f/load|<nowiki>r2 = Targetable panel AoE</nowiki>}}
  0017bda0: 8fbf0038 lw r31,0x0038(r29)
+
  0017bd84: 00000000 nop                               |
  0017bda4: 8fb70034 lw r23,0x0034(r29)
+
  0017bd88: 10400002 beq r2,r0,0x0017bd94              {{f/Cond|<nowiki>If This iteration panel AoE > 0x00</nowiki>}}
  0017bda8: 8fb60030 lw r22,0x0030(r29)
+
  0017bd8c: 26100001 addiu r16,r16,0x0001             |{{f/std|<nowiki>r16 = counter + 1</nowiki>}}
  0017bdac: 8fb5002c lw r21,0x002c(r29)
+
  0017bd90: a0640001 sb r4,0x0001(r3)                     |{{f/store|<nowiki>Set Targetable panel targeted flag ON (= 0x01)</nowiki>}}
  0017bdb0: 8fb40028 lw r20,0x0028(r29)
+
  0017bd94: 2a020200 slti r2,r16,0x0200               |{{f/std|<nowiki>r2 = 0x01 if counter < 0x200</nowiki>}}
  0017bdb4: 8fb30024 lw r19,0x0024(r29)
+
  0017bd98: 1440fff9 bne r2,r0,0x0017bd80          {{f/eloop|<nowiki>loop while counter < 0x200</nowiki>}}
  0017bdb8: 8fb20020 lw r18,0x0020(r29)
+
  0017bd9c: 24630005 addiu r3,r3,0x0005               |{{f/std|<nowiki>Pointer += 5</nowiki>}}
  0017bdbc: 8fb1001c lw r17,0x001c(r29)
+
  0017bda0: 8fbf0038 lw r31,0x0038(r29)              
  0017bdc0: 8fb00018 lw r16,0x0018(r29)
+
  0017bda4: 8fb70034 lw r23,0x0034(r29)              
  0017bdc4: 27bd0040 addiu r29,r29,0x0040
+
  0017bda8: 8fb60030 lw r22,0x0030(r29)              
  0017bdc8: 03e00008 jr r31
+
  0017bdac: 8fb5002c lw r21,0x002c(r29)              
  0017bdcc: 00000000 nop
+
  0017bdb0: 8fb40028 lw r20,0x0028(r29)              
 +
  0017bdb4: 8fb30024 lw r19,0x0024(r29)              
 +
  0017bdb8: 8fb20020 lw r18,0x0020(r29)              
 +
  0017bdbc: 8fb1001c lw r17,0x001c(r29)              
 +
  0017bdc0: 8fb00018 lw r16,0x0018(r29)              
 +
  0017bdc4: 27bd0040 addiu r29,r29,0x0040            
 +
  0017bdc8: 03e00008 jr r31                          
 +
  0017bdcc: 00000000 nop                              
 +
=== Return location ===
 +
'''Battle.bin'''
 +
  0017bb6c: [[Targeting_routine]]

Latest revision as of 20:22, 10 February 2022

Parameters : r4 = Attacker ID
             r5 = 0x80 if Ability ignores enemy unit
             r6 = 0x40 if Ability ignores allies
             r7 = 0x01 if Ability AoE is 255

Nullify AoE of targetable panel if unit is in a team to ignores
Set targetable panel 0x01 flag "ON" (= 0x01) if unit is not in the team to ignore (does not take AoE into account)
If Targetable panel AoE is > 0x00 set targetable panel 0x01 flag ON
----------------------------------------------------------------------------------
0017bc78: 27bdffc0 addiu r29,r29,-0x0040    |
0017bc7c: afb5002c sw r21,0x002c(r29)       |
0017bc80: 00a0a821 addu r21,r5,r0           |r21 = Ignore enemy Flag
0017bc84: afb60030 sw r22,0x0030(r29)       |
0017bc88: 00c0b021 addu r22,r6,r0           |r22 = Ignore ally Flag
0017bc8c: afb70034 sw r23,0x0034(r29)       |
0017bc90: 00e0b821 addu r23,r7,r0           |r23 = 0x01 if Ability AoE is 255
0017bc94: 308400ff andi r4,r4,0x00ff        |r4 = clean Attacker ID
0017bc98: 000410c0 sll r2,r4,0x03           |r2 = Attacker ID * 8
0017bc9c: 00441023 subu r2,r2,r4            |r2 = Attacker ID * 7
0017bca0: 00021180 sll r2,r2,0x06           |r2 = Attacker ID * 448  (size of unit data)
0017bca4: afb30024 sw r19,0x0024(r29)       |
0017bca8: 00809821 addu r19,r4,r0           |r19 = Attacker ID
0017bcac: afb00018 sw r16,0x0018(r29)       |
0017bcb0: 00008021 addu r16,r0,r0           |r16 = 0x00 (loop counter)
0017bcb4: afb20020 sw r18,0x0020(r29)       |
0017bcb8: 34120001 ori r18,r0,0x0001        |r18 = 0x01
0017bcbc: afb1001c sw r17,0x001c(r29)       |
0017bcc0: 00008821 addu r17,r0,r0           |r17 = 0x00 (unit pointer in unit data, +0x1c0 each loop iteration)
0017bcc4: afbf0038 sw r31,0x0038(r29)       |
0017bcc8: afb40028 sw r20,0x0028(r29)       |
0017bccc: 3c018019 lui r1,0x8019            |
0017bcd0: 00220821 addu r1,r1,r2            |r1 = 0x80190000 + Attacker ID*448
0017bcd4: 903408d1 lbu r20,0x08d1(r1)       |r20 = Attacker ENTD's flag  ( 0x801908cc + 0x05 = 0x801908d1 )
0017bcd8: 02002021 addu r4,r16,r0           @LOOP through all units r4 = Loop counter (unit counter)
0017bcdc: 0c05ef74 jal 0x0017bdd0                |-->Check_if_Unit_can_be_Targeted Return 0x00 if can be targeted + unit tile ID on r5
0017bce0: 27a50010 addiu r5,r29,0x0010           |r5 = Stack Pointer
0017bce4: 1440001c bne r2,r0,0x0017bd58          #If unit can be targeted
0017bce8: 00000000 nop                               | 
0017bcec: 3c018019 lui r1,0x8019                     |r1 = 0x80190000
0017bcf0: 00310821 addu r1,r1,r17                    |r1 = 0x80190000 + unit data offset (0x1c0 each iteration)
0017bcf4: 90220a86 lbu r2,0x0a86(r1)                 |r2 = This iteration unit modified ENTD flag
0017bcf8: 00000000 nop                               |
0017bcfc: 02821026 xor r2,r20,r2                     |r2 = every differences between attacker and this iteration unit ENTD flags - (Team ID in it) (0x00 if same ENTD's flag)
0017bd00: 16700002 bne r19,r16,0x0017bd0c            #If This iteration unit is Attacker
0017bd04: 00402021 addu r4,r2,r0                     |r4 = Differing ENTD Flags
0017bd08: 00002021 addu r4,r0,r0                         |r4 = 0x00 (nullify ENTD difference)
0017bd0c: 8fa30010 lw r3,0x0010(r29)                 |r3 = This iteration Unit's Tile ID
0017bd10: 00000000 nop                               |
0017bd14: 00031080 sll r2,r3,0x02                    |r2 = This iteration Unit's Tile ID * 4
0017bd18: 00431021 addu r2,r2,r3                     |r2 = This iteration Unit's Tile ID * 5
0017bd1c: 3c038019 lui r3,0x8019                     |
0017bd20: 24632dd8 addiu r3,r3,0x2dd8                |r3 = Targetable grid data pointer
0017bd24: 00431821 addu r3,r2,r3                     |r3 = This iteration Unit's Targetable panel data pointer
0017bd28: 90620000 lbu r2,0x0000(r3)                 |r2 = This iteration Unit's Targetable panel AoE
0017bd2c: 00000000 nop                               |
0017bd30: 10400009 beq r2,r0,0x0017bd58              #If This iteration Unit's Targetable panel AoE > 0x00
0017bd34: 30820030 andi r2,r4,0x0030                     |r2  <> 0x00 if Attacker and this iteration Unit are not in the same Team (Differing ENTD flag filtered on Team difference)
0017bd38: 14400002 bne r2,r0,0x0017bd44                  #If No team difference /Else branch keeping r2 = Avoid ally flag
0017bd3c: 32c200ff andi r2,r22,0x00ff                    |r2 = Ignore ally flag
0017bd40: 32a200ff andi r2,r21,0x00ff                        |r2 = Ignore enemy flag
0017bd44: 10400003 beq r2,r0,0x0017bd54                  #If This iteration unit is not in the team to ignore /Else , ignore Team (do not restore the targeted flag and nullify AoE)
0017bd48: 00000000 nop                                       |
0017bd4c: 0805ef56 j 0x0017bd58                              >>jump to next iteration (after set the panel targeted flag ON)
0017bd50: a0720001 sb r18,0x0001(r3)                         |Turn targetable panel targeted flag ON (= 0x01)  * panel 0x01 byte
0017bd54: a0600000 sb r0,0x0000(r3)                      #Else (Team to avoid) Nullify Targetable panel AoE 
0017bd58: 26100001 addiu r16,r16,0x0001          |r16 = loop counter + 1
0017bd5c: 2a020015 slti r2,r16,0x0015            |r2 = 0x01 if counter < 0x15
0017bd60: 1440ffdd bne r2,r0,0x0017bcd8     Λ loop while unit counter < 0x15
0017bd64: 263101c0 addiu r17,r17,0x01c0          |r1 = unit data Pointer Mod += 0x1c0
0017bd68: 32e200ff andi r2,r23,0x00ff       |r2 = 0x01 if Ability AoE is 255
0017bd6c: 1440000c bne r2,r0,0x0017bda0     #If Ability AoE is not 255 /Else branch to END
0017bd70: 00008021 addu r16,r0,r0                |r16 = 0x00 (loop counter)
0017bd74: 34040001 ori r4,r0,0x0001              |r4 = 0x01
0017bd78: 3c038019 lui r3,0x8019                 |
0017bd7c: 24632dd8 addiu r3,r3,0x2dd8            |r3 = 0x80192dd8 ( targetable panel grid)
0017bd80: 90620000 lbu r2,0x0000(r3)             @LOOP through all targetable panel r2 = Targetable panel AoE
0017bd84: 00000000 nop                               |
0017bd88: 10400002 beq r2,r0,0x0017bd94              #If This iteration panel AoE > 0x00
0017bd8c: 26100001 addiu r16,r16,0x0001              |r16 = counter + 1
0017bd90: a0640001 sb r4,0x0001(r3)                      |Set Targetable panel targeted flag ON (= 0x01)
0017bd94: 2a020200 slti r2,r16,0x0200                |r2 = 0x01 if counter < 0x200
0017bd98: 1440fff9 bne r2,r0,0x0017bd80          Λ loop while counter < 0x200
0017bd9c: 24630005 addiu r3,r3,0x0005                |Pointer += 5
0017bda0: 8fbf0038 lw r31,0x0038(r29)                
0017bda4: 8fb70034 lw r23,0x0034(r29)                
0017bda8: 8fb60030 lw r22,0x0030(r29)                
0017bdac: 8fb5002c lw r21,0x002c(r29)                
0017bdb0: 8fb40028 lw r20,0x0028(r29)                
0017bdb4: 8fb30024 lw r19,0x0024(r29)                
0017bdb8: 8fb20020 lw r18,0x0020(r29)                
0017bdbc: 8fb1001c lw r17,0x001c(r29)                
0017bdc0: 8fb00018 lw r16,0x0018(r29)                
0017bdc4: 27bd0040 addiu r29,r29,0x0040              
0017bdc8: 03e00008 jr r31                            
0017bdcc: 00000000 nop                               

Return location

Battle.bin
 0017bb6c: Targeting_routine