Difference between revisions of "Some targetability setting"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Uploading Routine - Didn't document yet)
 
m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Targetability Settings
+
BATTLE.BIN : Some targetability setting
 
+
-------------------------------------------------------------------------------------------------------
  00194570: 3c02801a lui r2,0x801a
+
Parameters : Nothing
  00194574: 8c4201f8 lw r2,0x01f8(r2)
+
  00194578: 27bdffd0 addiu r29,r29,0xffd0
+
Returns : Nothing
  0019457c: afbf002c sw r31,0x002c(r29)
+
  00194580: afb60028 sw r22,0x0028(r29)
+
Check some Team Conditions and Acting Unit Death Setence (see notes)
  00194584: afb50024 sw r21,0x0024(r29)
+
- Enable or disable flag 0x40000000 at 0x801a0078
  00194588: afb40020 sw r20,0x0020(r29)
+
- Deals with AI Decision [Allied Target] flag (at 8019f3c4 + 0x182c + 0x07 + Unit Offset)
  0019458c: afb3001c sw r19,0x001c(r29)
+
- Deals With AI Data at 801a0d7f  (aka 8019f3c4 + 0x19bb)
  00194590: afb20018 sw r18,0x0018(r29)
+
---------------------------------------------------------------------------------------------------------
  00194594: afb10014 sw r17,0x0014(r29)
+
  00194570: 3c02801a lui r2,0x801a           |
  00194598: afb00010 sw r16,0x0010(r29)
+
  00194574: 8c4201f8 lw r2,0x01f8(r2)         |{{f/adr|Acting Unit's AI Decision Pointer}}  *Acting Unit 8019f3c4 +0x182c
  0019459c: 3c01801a lui r1,0x801a
+
  00194578: 27bdffd0 addiu r29,r29,-0x0030    |
  001945a0: a0200d7f sb r0,0x0d7f(r1)
+
  0019457c: afbf002c sw r31,0x002c(r29)       |
  001945a4: 90420007 lbu r2,0x0007(r2)
+
  00194580: afb60028 sw r22,0x0028(r29)       |
  001945a8: 3c16801a lui r22,0x801a
+
  00194584: afb50024 sw r21,0x0024(r29)       |
  001945ac: 26d6f3c4 addiu r22,r22,0xf3c4
+
  00194588: afb40020 sw r20,0x0020(r29)       |
  001945b0: 30420008 andi r2,r2,0x0008
+
  0019458c: afb3001c sw r19,0x001c(r29)       |
  001945b4: 14400009 bne r2,r0,0x001945dc
+
  00194590: afb20018 sw r18,0x0018(r29)       |
  001945b8: 3c03bfff lui r3,0xbfff
+
  00194594: afb10014 sw r17,0x0014(r29)       |
  001945bc: 3c02801a lui r2,0x801a
+
  00194598: afb00010 sw r16,0x0010(r29)       |
  001945c0: 8c420bbc lw r2,0x0bbc(r2)
+
  0019459c: 3c01801a lui r1,0x801a           |
  001945c4: 00000000 nop
+
  001945a0: a0200d7f sb r0,0x0d7f(r1)         |{{f/store|Initialize [0x801a0d7f]}} {{f/std| 8019f3c4 + 0x19bb}}
  001945c8: 9042005c lbu r2,0x005c(r2)
+
  001945a4: 90420007 lbu r2,0x0007(r2)       |{{f/load|Load AI Targeting Flags 2}}
  001945cc: 00000000 nop
+
  001945a8: 3c16801a lui r22,0x801a           |
  001945d0: 30420001 andi r2,r2,0x0001
+
  001945ac: 26d6f3c4 addiu r22,r22,-0x0c3c    |{{f/adr|AI data pointer 0x8019f3c4}}
  001945d4: 10400009 beq r2,r0,0x001945fc
+
  001945b0: 30420008 andi r2,r2,0x0008       |{{f/std|Check [Allied Target] - AI panic mod}}
  001945d8: 00009821 addu r19,r0,r0
+
  001945b4: 14400009 bne r2,r0,0x001945dc     {{f/Cond|If Acting Unit Team is not in panic mod}}
  001945dc: 3c02801a lui r2,0x801a
+
  001945b8: 3c03bfff lui r3,0xbfff               |
  001945e0: 8c420078 lw r2,0x0078(r2)
+
  001945bc: 3c02801a lui r2,0x801a               |
  001945e4: 3463ffff ori r3,r3,0xffff
+
  001945c0: 8c420bbc lw r2,0x0bbc(r2)             |{{f/adr|Load Acting Unit Data pointer}}
  001945e8: 00431024 and r2,r2,r3
+
  001945c4: 00000000 nop                         |
  001945ec: 3c01801a lui r1,0x801a
+
  001945c8: 9042005c lbu r2,0x005c(r2)           |{{f/load|Load Acting unit Current Status 5}}
  001945f0: ac220078 sw r2,0x0078(r1)
+
  001945cc: 00000000 nop                         |
  001945f4: 080651bc j 0x001946f0
+
  001945d0: 30420001 andi r2,r2,0x0001           |{{f/std|Check [Death sentence]}}
  001945f8: 00000000 nop
+
  001945d4: 10400009 beq r2,r0,0x001945fc         {{f/Cond|Avoid Death Sentence/ Allied Target section}}
  001945fc: 0000a821 addu r21,r0,r0
+
  001945d8: 00009821 addu r19,r0,r0               |{{f/std|Initialize counter (Ally)}}
  00194600: 0000a021 addu r20,r0,r0
+
  00194604: 00008021 addu r16,r0,r0
+
{{f/sec|AI Acting unit in panic mod or with Death Sentence}}
  00194608: 00009021 addu r18,r0,r0
+
  001945dc: 3c02801a lui r2,0x801a                   |
  0019460c: 02c08821 addu r17,r22,r0
+
  001945e0: 8c420078 lw r2,0x0078(r2)                 |{{f/adr|Load target setting [0x801a0078]}} {{f/std| 8019f3c4 + 0xcb4}}
  00194610: 0c065b23 jal 0x00196c8c
+
  001945e4: 3463ffff ori r3,r3,0xffff                 |
  00194614: 02002021 addu r4,r16,r0
+
  001945e8: 00431024 and r2,r2,r3                     |{{f/std|Disable [flag 0x4000000] }}
  00194618: 1440000f bne r2,r0,0x00194658
+
  001945ec: 3c01801a lui r1,0x801a                   |
  0019461c: 00000000 nop
+
  001945f0: ac220078 sw r2,0x0078(r1)                 |{{f/store|Disable [flag 0x4000000] at 0x801a0078}}
  00194620: 92221834 lbu r2,0x1834(r17)
+
  001945f4: 080651bc j 0x001946f0                     {{f/jump|Exit Routine}}
  00194624: 00000000 nop
+
  001945f8: 00000000 nop                             |
  00194628: 10400003 beq r2,r0,0x00194638
+
  0019462c: 00000000 nop
+
                                            '''Else : No Panic mod AND no [Death Sentence]'''
  00194630: 08065196 j 0x00194658
+
  001945fc: 0000a821 addu r21,r0,r0           |{{f/std|[Enemy Flag] counter}}
  00194634: 26b50001 addiu r21,r21,0x0001
+
  00194600: 0000a021 addu r20,r0,r0           |
  00194638: 3c018019 lui r1,0x8019
+
  00194604: 00008021 addu r16,r0,r0           |{{f/std|Unit Counter (loop counter)}}
  0019463c: 00320821 addu r1,r1,r18
+
  00194608: 00009021 addu r18,r0,r0           |{{f/adr|Offset for Battle stats (+0x1c0 each iteration)}}
  00194640: 90220926 lbu r2,0x0926(r1)
+
  0019460c: 02c08821 addu r17,r22,r0         |{{f/adr|AI decision pointer (+0x10 each iteration)}}
  00194644: 00000000 nop
+
                                            {{f/bloop|LOOP - through all units}}
  00194648: 30420003 andi r2,r2,0x0003
+
  00194610: 0c065b23 jal 0x00196c8c               |{{f/jal|Check_target_type|Check_target_type}} {{f/std|<nowiki>Returns r2 = 0x01 if Unit is non targetable</nowiki>}}
  0019464c: 10400002 beq r2,r0,0x00194658
+
  00194614: 02002021 addu r4,r16,r0               |
  00194650: 26730001 addiu r19,r19,0x0001
+
  00194618: 1440000f bne r2,r0,0x00194658         {{f/Cond|If Unit is Targetable}} /Else branch to  {{f/loc| Next Unit}}
  00194654: 26940001 addiu r20,r20,0x0001
+
  0019461c: 00000000 nop                             |
  00194658: 265201c0 addiu r18,r18,0x01c0
+
  00194620: 92221834 lbu r2,0x1834(r17)               |{{f/load|Load this unit [Enemy Flag]}} {{f/std|8019f3c4 + 0x182c + 0x08 + Unit offset}}
  0019465c: 26100001 addiu r16,r16,0x0001
+
  00194624: 00000000 nop                             |
  00194660: 2a020015 slti r2,r16,0x0015
+
  00194628: 10400003 beq r2,r0,0x00194638             {{f/Cond|If [Enemy flag] is ON}}
  00194664: 1440ffea bne r2,r0,0x00194610
+
  0019462c: 00000000 nop                                 |
  00194668: 26310010 addiu r17,r17,0x0010
+
  00194630: 08065196 j 0x00194658                         {{f/jump|Jump to}} {{f/loc| Next Unit}}
  0019466c: 12740003 beq r19,r20,0x0019467c
+
  00194634: 26b50001 addiu r21,r21,0x0001                 |{{f/std|[Enemy Flag] counter + 1}}
  00194670: 2a620002 slti r2,r19,0x0002
+
                                                    '''Else : [Enemy flag] is OFF'''
  00194674: 10400016 beq r2,r0,0x001946d0
+
  00194638: 3c018019 lui r1,0x8019                       |
  00194678: 34020001 ori r2,r0,0x0001
+
  0019463c: 00320821 addu r1,r1,r18                       |
  0019467c: 92c20e39 lbu r2,0x0e39(r22)
+
  00194640: 90220926 lbu r2,0x0926(r1)                   |{{f/load|Load This unit Current Status 3}} {{f/std|801908cc + 0x5A + Unit battle data offset}}
  00194680: 00000000 nop
+
  00194644: 00000000 nop                                 |
  00194684: 1040000d beq r2,r0,0x001946bc
+
  00194648: 30420003 andi r2,r2,0x0003                   |{{f/std|check [Frog] and [Critical]}}
  00194688: 00008021 addu r16,r0,r0
+
  0019464c: 10400002 beq r2,r0,0x00194658                 {{f/Cond|If This unit has [Frog] or [Critical]}}
  0019468c: 02c01821 addu r3,r22,r0
+
  00194650: 26730001 addiu r19,r19,0x0001                 |{{f/std|Ally counter + 1}}
  00194690: 90621834 lbu r2,0x1834(r3)
+
  00194654: 26940001 addiu r20,r20,0x0001                     |{{f/std|Ally with Frog/Critical counter + 1}}
  00194694: 00000000 nop
+
  00194658: 265201c0 addiu r18,r18,0x01c0         |{{f/std|Unit battle stats offset (+0x1c0)}}
  00194698: 14400005 bne r2,r0,0x001946b0
+
  0019465c: 26100001 addiu r16,r16,0x0001         |{{f/std|Unit counter +1}}
  0019469c: 26100001 addiu r16,r16,0x0001
+
  00194660: 2a020015 slti r2,r16,0x0015           |{{f/std|Check limit}}
  001946a0: 90621833 lbu r2,0x1833(r3)
+
  00194664: 1440ffea bne r2,r0,0x00194610     {{f/eloop|Loop 0x15 times}}
  001946a4: 00000000 nop
+
  00194668: 26310010 addiu r17,r17,0x0010         |{{f/std|Unit AI decision offset (+0x10)}}
  001946a8: 34420008 ori r2,r2,0x0008
+
  0019466c: 12740003 beq r19,r20,0x0019467c   {{f/Cond|If there is some Allies not critical nor frog}}
  001946ac: a0621833 sb r2,0x1833(r3)
+
  00194670: 2a620002 slti r2,r19,0x0002           |
  001946b0: 2a020015 slti r2,r16,0x0015
+
  00194674: 10400016 beq r2,r0,0x001946d0         {{f/Cond|If Acting unit has only one ally}}
  001946b4: 1440fff6 bne r2,r0,0x00194690
+
  00194678: 34020001 ori r2,r0,0x0001                 |
  001946b8: 24630010 addiu r3,r3,0x0010
+
  0019467c: 92c20e39 lbu r2,0x0e39(r22)       {{f/Cond|E}}      |{{f/load|Load Acting Unit's Team}}
  001946bc: 3c03bfff lui r3,0xbfff
+
  00194680: 00000000 nop                             |
  001946c0: 8ec20cb4 lw r2,0x0cb4(r22)
+
  00194684: 1040000d beq r2,r0,0x001946bc             {{f/Cond|Branch if Uncontrolled Blue (player unit)}}
  001946c4: 3463ffff ori r3,r3,0xffff
+
  001946c8: 080651bb j 0x001946ec
+
{{f/sec|AI Team Panic Mod : One Ally left or All Teammates are frog or critical}}
  001946cc: 00431024 and r2,r2,r3
+
  00194688: 00008021 addu r16,r0,r0           |{{f/std|Initialize Unit counter}}
  001946d0: 16a20003 bne r21,r2,0x001946e0
+
  0019468c: 02c01821 addu r3,r22,r0           |{{f/adr|AI data pointer 0x8019f3c4}}
  001946d4: 3c034000 lui r3,0x4000
+
                                            {{f/bloop|LOOP - through all units (Enable [AI panic mod] flag on all ally units)}}
  001946d8: 34020001 ori r2,r0,0x0001
+
  00194690: 90621834 lbu r2,0x1834(r3)           |{{f/load|Load [Enemy Flag]}}
  001946dc: a2c219bb sb r2,0x19bb(r22)
+
  00194694: 00000000 nop                         |
  001946e0: 8ec20cb4 lw r2,0x0cb4(r22)
+
  00194698: 14400005 bne r2,r0,0x001946b0         {{f/Cond|If Unit has no [enemy flag]}}
  001946e4: 00000000 nop
+
  0019469c: 26100001 addiu r16,r16,0x0001         |{{f/std|Unit counter + 1}}
  001946e8: 00431025 or r2,r2,r3
+
  001946a0: 90621833 lbu r2,0x1833(r3)               |{{f/load|Load AI Targeting Flags 2}}
  001946ec: aec20cb4 sw r2,0x0cb4(r22)
+
  001946a4: 00000000 nop                             |
  001946f0: 8fbf002c lw r31,0x002c(r29)
+
  001946a8: 34420008 ori r2,r2,0x0008                 |{{f/std|Enable [0x08]}}
 +
  001946ac: a0621833 sb r2,0x1833(r3)                 |{{f/store|Enable [Allied Target] flag on all unit}}
 +
  001946b0: 2a020015 slti r2,r16,0x0015               |
 +
  001946b4: 1440fff6 bne r2,r0,0x00194690     {{f/Cond|Loop for all units}}
 +
  001946b8: 24630010 addiu r3,r3,0x0010           |{{f/std|AI decision offset}}
 +
 +
{{f/sec|All Team (AI or player)Panic Mod : One Ally left or All Teammates are frog or critical}}
 +
  001946bc: 3c03bfff lui r3,0xbfff               |
 +
  001946c0: 8ec20cb4 lw r2,0x0cb4(r22)           |{{f/adr|Load Target Setting (0x801a0078)}} {{f/std| 8019f3c4 + 0xcb4}}
 +
  001946c4: 3463ffff ori r3,r3,0xffff             |
 +
  001946c8: 080651bb j 0x001946ec                 {{f/jump|Save and Exit}}
 +
  001946cc: 00431024 and r2,r2,r3                 |{{f/store|Disable [0x40000000]  at 0x801a0078}}
 +
 +
{{f/sec|No Panic Mod - Check Nb of enemies}}
 +
  001946d0: 16a20003 bne r21,r2,0x001946e0   {{f/Cond|If There's only one Enemy Left}}
 +
  001946d4: 3c034000 lui r3,0x4000               |
 +
  001946d8: 34020001 ori r2,r0,0x0001             |
 +
  001946dc: a2c219bb sb r2,0x19bb(r22)           |{{f/store|Save to Unit targetable flag (Override Untargetable)}}
 +
  001946e0: 8ec20cb4 lw r2,0x0cb4(r22)       |{{f/adr|Same as 0x0078}}
 +
  001946e4: 00000000 nop                     |
 +
  001946e8: 00431025 or r2,r2,r3             |{{f/std|Enable 0x40000000}}
 +
  001946ec: aec20cb4 sw r2,0x0cb4(r22)       |{{f/store|Enable [flag 0x4000000] at 0x801a0078}}
 +
  001946f0: 8fbf002c lw r31,0x002c(r29)       END
 
  001946f4: 8fb60028 lw r22,0x0028(r29)
 
  001946f4: 8fb60028 lw r22,0x0028(r29)
 
  001946f8: 8fb50024 lw r21,0x0024(r29)
 
  001946f8: 8fb50024 lw r21,0x0024(r29)
Line 108: Line 130:
 
  00194714: 03e00008 jr r31
 
  00194714: 03e00008 jr r31
 
  00194718: 00000000 nop
 
  00194718: 00000000 nop
 +
=== Notes ===
 +
[Allied Target] flag (label in wiki) - From AI Decision : 8019f3c4 - 0x182c - 0x07
 +
Set to 0x01 if :
 +
    - Not Blue Team (AI only)
 +
    - Acting Unit Teammates are all critical or Frog
 +
    - Acting Unit has only one teammate left
 +
 +
Flag 0x40000000 at 0x801a0078
 +
  - Enabled if Acting Unit has only One Foe Left
 +
  - Disabled if : (Panic mod prevails on Last enemy mod ?)
 +
      - Acting Unit has Death Sentence
 +
      - Acting Unit has [Allied Target]flag One
 +
      - Acting Unit has only one Teammate left
 +
      - Acting Unit Teammates are all critical or Frog
 +
     
 +
801a0d7f : set to 0x01 if there is only one enemy left
 +
=== Return Locations ===
 +
'''BATTLE.BIN'''
 +
00194060: [[Main_AI_action_setup]]

Latest revision as of 19:58, 6 April 2024

BATTLE.BIN : Some targetability setting
-------------------------------------------------------------------------------------------------------
Parameters : Nothing

Returns : Nothing

Check some Team Conditions and Acting Unit Death Setence (see notes)
- Enable or disable flag 0x40000000 at 0x801a0078
- Deals with AI Decision [Allied Target] flag (at 8019f3c4 + 0x182c + 0x07 + Unit Offset)
- Deals With AI Data at 801a0d7f  (aka 8019f3c4 + 0x19bb)
---------------------------------------------------------------------------------------------------------
00194570: 3c02801a lui r2,0x801a            |
00194574: 8c4201f8 lw r2,0x01f8(r2)         |Acting Unit's AI Decision Pointer   *Acting Unit 8019f3c4 +0x182c
00194578: 27bdffd0 addiu r29,r29,-0x0030    |
0019457c: afbf002c sw r31,0x002c(r29)       |
00194580: afb60028 sw r22,0x0028(r29)       |
00194584: afb50024 sw r21,0x0024(r29)       |
00194588: afb40020 sw r20,0x0020(r29)       |
0019458c: afb3001c sw r19,0x001c(r29)       |
00194590: afb20018 sw r18,0x0018(r29)       |
00194594: afb10014 sw r17,0x0014(r29)       |
00194598: afb00010 sw r16,0x0010(r29)       |
0019459c: 3c01801a lui r1,0x801a            |
001945a0: a0200d7f sb r0,0x0d7f(r1)         |Initialize [0x801a0d7f]  8019f3c4 + 0x19bb
001945a4: 90420007 lbu r2,0x0007(r2)        |Load AI Targeting Flags 2
001945a8: 3c16801a lui r22,0x801a           |
001945ac: 26d6f3c4 addiu r22,r22,-0x0c3c    |AI data pointer 0x8019f3c4
001945b0: 30420008 andi r2,r2,0x0008        |Check [Allied Target] - AI panic mod
001945b4: 14400009 bne r2,r0,0x001945dc     #If Acting Unit Team is not in panic mod
001945b8: 3c03bfff lui r3,0xbfff                |
001945bc: 3c02801a lui r2,0x801a                |
001945c0: 8c420bbc lw r2,0x0bbc(r2)             |Load Acting Unit Data pointer
001945c4: 00000000 nop                          |
001945c8: 9042005c lbu r2,0x005c(r2)            |Load Acting unit Current Status 5
001945cc: 00000000 nop                          |
001945d0: 30420001 andi r2,r2,0x0001            |Check [Death sentence]
001945d4: 10400009 beq r2,r0,0x001945fc         #Avoid Death Sentence/ Allied Target section
001945d8: 00009821 addu r19,r0,r0               |Initialize counter (Ally)

AI Acting unit in panic mod or with Death Sentence
001945dc: 3c02801a lui r2,0x801a                    |
001945e0: 8c420078 lw r2,0x0078(r2)                 |Load target setting [0x801a0078]  8019f3c4 + 0xcb4
001945e4: 3463ffff ori r3,r3,0xffff                 |
001945e8: 00431024 and r2,r2,r3                     |Disable [flag 0x4000000] 
001945ec: 3c01801a lui r1,0x801a                    |
001945f0: ac220078 sw r2,0x0078(r1)                 |Disable [flag 0x4000000] at 0x801a0078
001945f4: 080651bc j 0x001946f0                     >>Exit Routine
001945f8: 00000000 nop                              |

                                            Else : No Panic mod AND no [Death Sentence]
001945fc: 0000a821 addu r21,r0,r0           |[Enemy Flag] counter
00194600: 0000a021 addu r20,r0,r0           |
00194604: 00008021 addu r16,r0,r0           |Unit Counter (loop counter)
00194608: 00009021 addu r18,r0,r0           |Offset for Battle stats (+0x1c0 each iteration)
0019460c: 02c08821 addu r17,r22,r0          |AI decision pointer (+0x10 each iteration)
                                            @LOOP - through all units
00194610: 0c065b23 jal 0x00196c8c               |-->Check_target_type Returns r2 = 0x01 if Unit is non targetable
00194614: 02002021 addu r4,r16,r0               |
00194618: 1440000f bne r2,r0,0x00194658         #If Unit is Targetable /Else branch to   Next Unit
0019461c: 00000000 nop                              |
00194620: 92221834 lbu r2,0x1834(r17)               |Load this unit [Enemy Flag] 8019f3c4 + 0x182c + 0x08 + Unit offset
00194624: 00000000 nop                              |
00194628: 10400003 beq r2,r0,0x00194638             #If [Enemy flag] is ON
0019462c: 00000000 nop                                  |
00194630: 08065196 j 0x00194658                         >>Jump to  Next Unit
00194634: 26b50001 addiu r21,r21,0x0001                 |[Enemy Flag] counter + 1
                                                    Else : [Enemy flag] is OFF
00194638: 3c018019 lui r1,0x8019                        |
0019463c: 00320821 addu r1,r1,r18                       |
00194640: 90220926 lbu r2,0x0926(r1)                    |Load This unit Current Status 3 801908cc + 0x5A + Unit battle data offset
00194644: 00000000 nop                                  |
00194648: 30420003 andi r2,r2,0x0003                    |check [Frog] and [Critical]
0019464c: 10400002 beq r2,r0,0x00194658                 #If This unit has [Frog] or [Critical]
00194650: 26730001 addiu r19,r19,0x0001                 |Ally counter + 1
00194654: 26940001 addiu r20,r20,0x0001                     |Ally with Frog/Critical counter + 1
00194658: 265201c0 addiu r18,r18,0x01c0         |Unit battle stats offset (+0x1c0)
0019465c: 26100001 addiu r16,r16,0x0001         |Unit counter +1
00194660: 2a020015 slti r2,r16,0x0015           |Check limit
00194664: 1440ffea bne r2,r0,0x00194610     Λ Loop 0x15 times
00194668: 26310010 addiu r17,r17,0x0010         |Unit AI decision offset (+0x10)
0019466c: 12740003 beq r19,r20,0x0019467c   #If there is some Allies not critical nor frog
00194670: 2a620002 slti r2,r19,0x0002           |
00194674: 10400016 beq r2,r0,0x001946d0         #If Acting unit has only one ally
00194678: 34020001 ori r2,r0,0x0001                 |
0019467c: 92c20e39 lbu r2,0x0e39(r22)       #E      |Load Acting Unit's Team
00194680: 00000000 nop                              |
00194684: 1040000d beq r2,r0,0x001946bc             #Branch if Uncontrolled Blue (player unit)

AI Team Panic Mod : One Ally left or All Teammates are frog or critical
00194688: 00008021 addu r16,r0,r0           |Initialize Unit counter
0019468c: 02c01821 addu r3,r22,r0           |AI data pointer 0x8019f3c4
                                            @LOOP - through all units (Enable [AI panic mod] flag on all ally units)
00194690: 90621834 lbu r2,0x1834(r3)            |Load [Enemy Flag]
00194694: 00000000 nop                          |
00194698: 14400005 bne r2,r0,0x001946b0         #If Unit has no [enemy flag]
0019469c: 26100001 addiu r16,r16,0x0001         |Unit counter + 1
001946a0: 90621833 lbu r2,0x1833(r3)                |Load AI Targeting Flags 2
001946a4: 00000000 nop                              |
001946a8: 34420008 ori r2,r2,0x0008                 |Enable [0x08]
001946ac: a0621833 sb r2,0x1833(r3)                 |Enable [Allied Target] flag on all unit
001946b0: 2a020015 slti r2,r16,0x0015               |
001946b4: 1440fff6 bne r2,r0,0x00194690     #Loop for all units
001946b8: 24630010 addiu r3,r3,0x0010           |AI decision offset

All Team (AI or player)Panic Mod : One Ally left or All Teammates are frog or critical
001946bc: 3c03bfff lui r3,0xbfff                |
001946c0: 8ec20cb4 lw r2,0x0cb4(r22)            |Load Target Setting (0x801a0078)  8019f3c4 + 0xcb4
001946c4: 3463ffff ori r3,r3,0xffff             |
001946c8: 080651bb j 0x001946ec                 >>Save and Exit
001946cc: 00431024 and r2,r2,r3                 |Disable [0x40000000]  at 0x801a0078

No Panic Mod - Check Nb of enemies
001946d0: 16a20003 bne r21,r2,0x001946e0    #If There's only one Enemy Left
001946d4: 3c034000 lui r3,0x4000                |
001946d8: 34020001 ori r2,r0,0x0001             |
001946dc: a2c219bb sb r2,0x19bb(r22)            |Save to Unit targetable flag (Override Untargetable)
001946e0: 8ec20cb4 lw r2,0x0cb4(r22)        |Same as 0x0078
001946e4: 00000000 nop                      |
001946e8: 00431025 or r2,r2,r3              |Enable 0x40000000
001946ec: aec20cb4 sw r2,0x0cb4(r22)        |Enable [flag 0x4000000] at 0x801a0078
001946f0: 8fbf002c lw r31,0x002c(r29)       END
001946f4: 8fb60028 lw r22,0x0028(r29)
001946f8: 8fb50024 lw r21,0x0024(r29)
001946fc: 8fb40020 lw r20,0x0020(r29)
00194700: 8fb3001c lw r19,0x001c(r29)
00194704: 8fb20018 lw r18,0x0018(r29)
00194708: 8fb10014 lw r17,0x0014(r29)
0019470c: 8fb00010 lw r16,0x0010(r29)
00194710: 27bd0030 addiu r29,r29,0x0030
00194714: 03e00008 jr r31
00194718: 00000000 nop

Notes

[Allied Target] flag (label in wiki) - From AI Decision : 8019f3c4 - 0x182c - 0x07
Set to 0x01 if : 
    - Not Blue Team (AI only)
    - Acting Unit Teammates are all critical or Frog
    - Acting Unit has only one teammate left

Flag 0x40000000 at 0x801a0078
  - Enabled if Acting Unit has only One Foe Left
  - Disabled if : (Panic mod prevails on Last enemy mod ?)
      - Acting Unit has Death Sentence
      - Acting Unit has [Allied Target]flag One
      - Acting Unit has only one Teammate left
      - Acting Unit Teammates are all critical or Frog
      
801a0d7f : set to 0x01 if there is only one enemy left

Return Locations

BATTLE.BIN
00194060: Main_AI_action_setup