Difference between revisions of "Set or Remove Charging (00195f8c)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
  set current ability CT/status change
+
  '''BATTLE.BIN''' : - Set_or_Remove_Charging_(00195f8c)
 
+
  If Charging - Set Considered destination and simaulate movement while charging, or without charging (Aim, Dance and Song Hardcoded section)
  00195f8c: 3c04801a lui r4,0x801a
+
  ------------------------------------------------------------------------------------------
  00195f90: 8c840bbc lw r4,0x0bbc(r4) r4 = Attacker Unit Data?
+
Parameter : Nothing
  00195f94: 3c02801a lui r2,0x801a
+
Return : r2 = 0x00 (Default)
00195f98: 90420d7b lbu r2,0x0d7b(r2)
+
          r2 = -0x01 if Routine has aborted (AI 0xed6 is updated) - V_Sync alert ?
00195f9c: 27bdffe0 addiu r29,r29,0xffe0
+
          r2 = 0x01 Considered Action has better outcome than selected one (AI 0x17fc)
00195fa0: afb00010 sw r16,0x0010(r29)
+
  ------------------------------------------------------------------------------------------
00195fa4: 3c10801a lui r16,0x801a
+
  00195f8c: 3c04801a lui r4,0x801a            |
00195fa8: 2610f3c4 addiu r16,r16,0xf3c4
+
  00195f90: 8c840bbc lw r4,0x0bbc(r4)          |{{f/adr|Pointer to Acting Unit Battle data}}
00195fac: afbf0018 sw r31,0x0018(r29)
+
  00195f94: 3c02801a lui r2,0x801a            |
00195fb0: afb10014 sw r17,0x0014(r29)
+
  00195f98: 90420d7b lbu r2,0x0d7b(r2)         |{{f/load|AI 0x19b7}}
 
+
  00195f9c: 27bdffe0 addiu r29,r29,-0x0020    |
  00195fb4: 1040000a beq r2,r0,0x00195fe0
+
  00195fa0: afb00010 sw r16,0x0010(r29)        |
00195fb8: 2491016e addiu r17,r4,0x016e r17 = Target Unit Data
+
00195fa4: 3c10801a lui r16,0x801a            |
00195fbc: 3c03801a lui r3,0x801a
+
  00195fa8: 2610f3c4 addiu r16,r16,0xf3c4      |{{f/adr|0x8019f3c4}}
00195fc0: 9063029a lbu r3,0x029a(r3)
+
  00195fac: afbf0018 sw r31,0x0018(r29)       |
00195fc4: 00000000 nop
+
00195fb0: afb10014 sw r17,0x0014(r29)       |
00195fc8: 10600028 beq r3,r0,0x0019606c
+
   
00195fcc: 34020001 ori r2,r0,0x0001
+
  {{f/sec|<nowiki>=== Return to where the code left off ===</nowiki>}}
  00195fd0: 10620031 beq r3,r2,0x00196098
+
  00195fb4: 1040000a beq r2,r0,0x00195fe0      {{f/Cond|If AI 0x19b7 <> 0x00}}
  00195fd4: 00000000 nop
+
  00195fb8: 2491016e addiu r17,r4,0x016e      |{{f/adr|Acting Unit Current Action data}}
  00195fd8: 08065849 j 0x00196124
+
  00195fbc: 3c03801a lui r3,0x801a                 |
  00195fdc: 00000000 nop
+
  00195fc0: 9063029a lbu r3,0x029a(r3)            |{{f/load|AI 0xed6 (this routine memory variable)}}
 
+
  00195fc4: 00000000 nop                          |
00195fe0: 9083015d lbu r3,0x015d(r4) Load Current Ability CT
+
  00195fc8: 10600028 beq r3,r0,0x0019606c          {{f/Cond|If Memory variable is 0x00 :}} {{f/loc|Return to Song Dance movement evaluation}}
  00195fe4: 340200ff ori r2,r0,0x00ff
+
  00195fcc: 34020001 ori r2,r0,0x0001              |
  00195fe8: 10620066 beq r3,r2,0x00196184 Exit if Ability has no CT
+
  00195fd0: 10620031 beq r3,r2,0x00196098          {{f/Cond|If Memory variable is 0x01 :}} {{f/loc|Return to Default ability movement evaluation (while charging)}}
  00195fec: 00001021 addu r2,r0,r0
+
  00195fd4: 00000000 nop                           |
  00195ff0: 9082016f lbu r2,0x016f(r4) Load Skillset of Last Attack Used (of Target?)
+
  00195fd8: 08065849 j 0x00196124                  {{f/Cond|Else : Memory Variable is 0x02}} {{f/loc|Return to Default ability movement evaluation (without charging)}}
  00195ff4: 3c018006 lui r1,0x8006
+
  00195fdc: 00000000 nop                          |
  00195ff8: 00220821 addu r1,r1,r2
+
  00195ffc: 90235cb4 lbu r3,0x5cb4(r1) Get Action Menu
+
  {{f/sec|<nowiki>=== Start from beginning ===</nowiki>}}
00196000: 3402000a ori r2,r0,0x000a
+
                                              '''<nowiki>Else : AI 0x19b7 = 0x00</nowiki>'''
  00196004: 14620007 bne r3,r2,0x00196024 Branch if Charge
+
  00195fe0: 9083015d lbu r3,0x015d(r4)             |{{f/load|Acting Unit Current Ability CT}}
  00196008: 00000000 nop
+
  00195fe4: 340200ff ori r2,r0,0x00ff              |
0019600c: 3c02801a lui r2,0x801a
+
  00195fe8: 10620066 beq r3,r2,0x00196184          {{f/Cond|If Acting Unit is not charging :}} {{f/loc|Exit }} {{f/Returns|Returns 0x00}}
  00196010: 8c4201f4 lw r2,0x01f4(r2) Load XY Coordinates
+
  00195fec: 00001021 addu r2,r0,r0                |
  00196014: 3c01801a lui r1,0x801a
+
00195ff0: 9082016f lbu r2,0x016f(r4)             |{{f/load|Acting Unit Skillset of Last Attack Used}}
  00196018: ac22f3dc sw r2,-0x0c24(r1) Save to AI Acting Unit XY Coordinates
+
  00195ff4: 3c018006 lui r1,0x8006                |
  0019601c: 08065814 j 0x00196050
+
  00195ff8: 00220821 addu r1,r1,r2                 |{{f/adr|0x80060000 + Skillset offset (for action menu)}}
00196020: a2000014 sb r0,0x0014(r16) IsTargetFlagsSet = False
+
  00195ffc: 90235cb4 lbu r3,0x5cb4(r1)             |{{f/load|Get Acting Unit Last used Action Menu}}
 
+
  00196000: 3402000a ori r2,r0,0x000a              |
  00196024: 3c02801a lui r2,0x801a
+
00196028: 904201f1 lbu r2,0x01f1(r2)
+
                  {{f/sec|--- Set destination ---}}
  0019602c: 00000000 nop
+
  00196004: 14620007 bne r3,r2,0x00196024          {{f/Cond|If Action menu is [Aim]}} {{f/std|Charge skillset}}
  00196030: 00021080 sll r2,r2,0x02
+
  00196008: 00000000 nop                               |
  00196034: 00501021 addu r2,r2,r16
+
  0019600c: 3c02801a lui r2,0x801a                    |
  00196038: 8c420cc4 lw r2,0x0cc4(r2)
+
  00196010: 8c4201f4 lw r2,0x01f4(r2)                  |{{f/load|Acting Unit XY Coordinates}} {{f/std|0x8019f3c4 + 0x0e30}}
0019603c: 3c01801a lui r1,0x801a
+
  00196014: 3c01801a lui r1,0x801a                    |
  00196040: ac22f3dc sw r2,-0x0c24(r1) Save to AI Acting Unit XY Coordinates
+
  00196018: ac22f3dc sw r2,-0x0c24(r1)                |{{f/store|Save to AI Considered Action destination}} {{f/adr|0x8019f3c4 + 0x18}}
  00196044: 0c066ec8 jal 0x0019bb20
+
  0019601c: 08065814 j 0x00196050                      |{{f/loc|Avoid non-Charge section}}
  00196048: 00000000 nop
+
  00196020: a2000014 sb r0,0x0014(r16)                 |{{f/store|<nowiki>AI 0x14 = 0x00</nowiki>}} {{f/std|labeled as IsTargetFlagsSet. Afaik seems to more likely related to Caster position or necessity to move}}
0019604c: a2000014 sb r0,0x0014(r16) IsTargetFlagsSet = False
+
                                                  '''Else : Not Charge'''
  00196050: a200001d sb r0,0x001d(r16) Empty Last Skillset Used
+
  00196024: 3c02801a lui r2,0x801a                    |
 
+
  00196028: 904201f1 lbu r2,0x01f1(r2)                |{{f/load|AI 0xe2d}} {{f/std|Destination consideration (0x1 close to target, 0x2 Away from Target)}}
  <Song/Dance>
+
  0019602c: 00000000 nop                               |
  00196054: 96220002 lhu r2,0x0002(r17) Load Last Attack Used
+
  00196030: 00021080 sll r2,r2,0x02                    |{{f/std|AI 0xe2d offset (Word)}}
  00196058: 00000000 nop
+
  00196034: 00501021 addu r2,r2,r16                    |
0019605c: 2442ffaa addiu r2,r2,0xffaa Attack ID - 56 (Song and Dance)
+
  00196038: 8c420cc4 lw r2,0x0cc4(r2)                  |{{f/adr|Load Destination of interest coordinates}}
  00196060: 2c42000e sltiu r2,r2,0x000e
+
  0019603c: 3c01801a lui r1,0x801a                    |
  00196064: 1040000c beq r2,r0,0x00196098 Branch if Ability is not a Song/Dance
+
  00196040: ac22f3dc sw r2,-0x0c24(r1)                |{{f/store|Save to AI Considered Action destination}} {{f/adr|0x8019f3c4 + 0x18}}
  00196068: 00000000 nop
+
  00196044: 0c066ec8 jal 0x0019bb20                    |{{f/jal|AI_Check_if_Unit_is_a_Crystal/Treasure_(0019bb20)|AI_Check_if_Unit_is_a_Crystal/Treasure_(0019bb20)}} {{f/std|Set 0x801a0083 Value ("crystal on destination" flag)}}
  0019606c: 0c0674c2 jal 0x0019d308 Check against and Set Highest Priority
+
  00196048: 00000000 nop                              |
  00196070: 00000000 nop
+
  0019604c: a2000014 sb r0,0x0014(r16)                 |{{f/store|<nowiki>AI 0x14 = 0x00</nowiki>}} {{f/std|labeled as IsTargetFlagsSet. Afaik seems to more likely related to Caster position or necessity to move}}
  00196074: 2403ffff addiu r3,r0,0xffff
+
00196050: a200001d sb r0,0x001d(r16)             |{{f/store|<nowiki>Set Considered Skillset = 0x00</nowiki>}} {{f/std|AI 0x1d (akaAI  0x14 + 0x9) -  Move only}}
  00196078: 14430003 bne r2,r3,0x00196088 Branch because RNG said so
+
   
  0019607c: 2402ffff addiu r2,r0,0xffff
+
                  {{f/sec|--- Simulate Movement ---}}
  00196080: 08065861 j 0x00196184 Exit and return -1
+
00196054: 96220002 lhu r2,0x0002(r17)           |{{f/load|Acting Unit  Last  Used Ability}}
00196084: a2000ed6 sb r0,0x0ed6(r16)
+
00196058: 00000000 nop                          |
00196088: 0c065bf1 jal 0x00196fc4 Check if ability is AI usable, AI coordinates match and Check/Set Priority
+
  0019605c: 2442ffaa addiu r2,r2,-0x0056          |{{f/std|Attack ID - 0x56 (Angel Song ID)}}
0019608c: 00000000 nop
+
  00196060: 2c42000e sltiu r2,r2,0x000e            |{{f/std|0x1 if Any Song or Dance Ability}}
  00196090: 08065861 j 0x00196184 Exit and return 0
+
  00196064: 1040000c beq r2,r0,0x00196098          {{f/Cond|If Used Ability is a Song or Dance Ability}} {{f/std|Will hit the whole map }}
  00196094: 00001021 addu r2,r0,r0
+
  00196068: 00000000 nop                              |
 
+
0019606c: 0c0674c2 jal 0x0019d308                    |{{f/jal|Check_Set_Highest_Unit_Priority_(0019d308)|Check_Set_Highest_Unit_Priority_(0019d308)}} {{f/std|Set priority score for considered action (Store Action data in AI 0x34)}}
<Default Abilities>
+
  00196070: 00000000 nop                              |
00196098: 0c0674df jal 0x0019d37c Set Unit Target Priority + other stuff
+
00196074: 2403ffff addiu r3,r0,-0x0001              |
  0019609c: 00000000 nop
+
  00196078: 14430003 bne r2,r3,0x00196088              {{f/Cond|<nowiki>If returned r2 = -0x01</nowiki>}} {{f/std|V_Sync Alert ?}}
  001960a0: 2403ffff addiu r3,r0,0xffff
+
  0019607c: 2402ffff addiu r2,r0,-0x0001                  |
  001960a4: 14430003 bne r2,r3,0x001960b4 Branch if RNG said no
+
  00196080: 08065861 j 0x00196184                          {{f/jump|<nowiki>Set AI 0xed6 = 0x00</nowiki>}} {{f/loc|Exit}} {{f/Returns|Returns -0x01}}
  001960a8: 260417fc addiu r4,r16,0x17fc
+
00196084: a2000ed6 sb r0,0x0ed6(r16)                     |
  001960ac: 0806584f j 0x0019613c Jump to jump to exit
+
                                                      '''Else : no V-Sync Alert'''
  001960b0: 34020001 ori r2,r0,0x0001
+
  00196088: 0c065bf1 jal 0x00196fc4                        |{{f/jal|Compare_Set_Highest_Unit_Target_Priority_(00196fc4)|Compare_Set_Highest_Unit_Target_Priority_(00196fc4)}} {{f/std|Save AI 0x34 in stored Action if better outcome (AI 0x54 to AI 0x134)}}
 
+
  0019608c: 00000000 nop                                   |
  <Cancel Charge>
+
  00196090: 08065861 j 0x00196184                          |{{f/loc|Exit }} {{f/Returns|return 0x00}}
001960b4: 26050014 addiu r5,r16,0x0014
+
  00196094: 00001021 addu r2,r0,r0                        |
  001960b8: 0c066ac2 jal 0x0019ab08 Transfer Halfword Values
+
                                                  '''Else : Not a Song nor Dance Ability (consider canceling charge or not)'''
  001960bc: 34060020 ori r6,r0,0x0020
+
  00196098: 0c0674df jal 0x0019d37c                    |{{f/jal|AI_End_of_turn,_in_between_turn,_etc.|AI_End_of_turn,_in_between_turn,_etc.}} {{f/std|Simulate movement - Set a priority score of AI 0x14 Action (in AI 0x32)}}
001960c0: 8e0217f8 lw r2,0x17f8(r16)
+
  0019609c: 00000000 nop                               |
001960c4: 8e0317f8 lw r3,0x17f8(r16)
+
  001960a0: 2403ffff addiu r3,r0,-0x0001              |
001960c8: 9042015d lbu r2,0x015d(r2) Load Current Ability CT
+
  001960a4: 14430003 bne r2,r3,0x001960b4              {{f/Cond|<nowiki>If returned r2 = -0x01</nowiki>}} {{f/std|V_Sync Alert ?}}
  001960cc: 00000000 nop
+
  001960a8: 260417fc addiu r4,r16,0x17fc              |{{f/adr|Pointer to AI 0x17fc}} {{f/std|Selected action}}
001960d0: a2020ed0 sb r2,0x0ed0(r16) Save Current Ability CT to ?
+
  001960ac: 0806584f j 0x0019613c                          {{f/jump|<nowiki>Set AI 0xed6 = 0x01</nowiki>}} {{f/loc|Exit}} {{f/Returns|Returns -0x01}}
  001960d4: 90620058 lbu r2,0x0058(r3) Load Current Status 1
+
  001960b0: 34020001 ori r2,r0,0x0001                      |
  001960d8: 8e0317f8 lw r3,0x17f8(r16)
+
                                                      '''Else : do not abort'''
  001960dc: a2020ed1 sb r2,0x0ed1(r16) Save Current Status to ?
+
  001960b4: 26050014 addiu r5,r16,0x0014                  |
  001960e0: 906201bb lbu r2,0x01bb(r3) Load Inflict Status 1
+
  001960b8: 0c066ac2 jal 0x0019ab08                        |{{f/jal|Transfer Halfword Values|Transfer Halfword Values}} {{f/std|Transfer considered action to selected action (AI 0x14 to AI 0x17fc)}}
  001960e4: 8e0317f8 lw r3,0x17f8(r16)
+
001960bc: 34060020 ori r6,r0,0x0020                      |{{f/std|Transfer 0x20 bytes}}
  001960e8: a2020ed2 sb r2,0x0ed2(r16) Save Inflict Status 1 to ?
+
  001960c0: 8e0217f8 lw r2,0x17f8(r16)                     |{{f/adr|Acting Unit Battle data pointer}}
  001960ec: 340200ff ori r2,r0,0x00ff
+
  001960c4: 8e0317f8 lw r3,0x17f8(r16)                    |{{f/adr|Acting Unit Battle data pointer}}
  001960f0: a062015d sb r2,0x015d(r3) Charging abiilty = false
+
  001960c8: 9042015d lbu r2,0x015d(r2)                    |{{f/load|Load Current Ability CT}}
  001960f4: 8e0317f8 lw r3,0x17f8(r16)
+
001960cc: 00000000 nop                                  |
001960f8: 00000000 nop
+
  001960d0: a2020ed0 sb r2,0x0ed0(r16)                     |{{f/store|Save Current Ability CT to AI 0xed0}}
001960fc: 90620058 lbu r2,0x0058(r3) Load Current Status 1
+
  001960d4: 90620058 lbu r2,0x0058(r3)                     |{{f/load|Load Current Status 1}}
  00196100: 00000000 nop
+
  001960d8: 8e0317f8 lw r3,0x17f8(r16)                    |{{f/adr|Acting Unit Battle data pointer}}
  00196104: 304200f6 andi r2,r2,0x00f6
+
  001960dc: a2020ed1 sb r2,0x0ed1(r16)                     |{{f/store|Save Current Status to AI 0xed1}}
  00196108: a0620058 sb r2,0x0058(r3) Remove Charging
+
  001960e0: 906201bb lbu r2,0x01bb(r3)                     |{{f/load|Load Inflicted Status 1}}
0019610c: 8e0317f8 lw r3,0x17f8(r16)
+
  001960e4: 8e0317f8 lw r3,0x17f8(r16)                     |{{f/adr|Acting Unit Battle data pointer}}
  00196110: 00000000 nop
+
  001960e8: a2020ed2 sb r2,0x0ed2(r16)                     |{{f/store|Save Inflict Status 1 to AI 0xed2}}
00196114: 906201bb lbu r2,0x01bb(r3) Load Inflict Status
+
  001960ec: 340200ff ori r2,r0,0x00ff                      |
  00196118: 00000000 nop
+
001960f0: a062015d sb r2,0x015d(r3)                     |{{f/store|<nowiki>Set Current CT = 0xff (not charging)</nowiki>}}
  0019611c: 304200f6 andi r2,r2,0x00f6
+
001960f4: 8e0317f8 lw r3,0x17f8(r16)                    |{{f/adr|Acting Unit Battle data pointer}}
  00196120: a06201bb sb r2,0x01bb(r3) Remove Charging from Inflicted Status
+
001960f8: 00000000 nop                                  |
  00196124: 0c0674df jal 0x0019d37c Set Unit Target Priority/Accuracy/etc
+
001960fc: 90620058 lbu r2,0x0058(r3)                    |{{f/load|Load Current Status 1}}
  00196128: 00000000 nop
+
00196100: 00000000 nop                                  |
  0019612c: 2403ffff addiu r3,r0,0xffff
+
00196104: 304200f6 andi r2,r2,0x00f6                    |
00196130: 14430005 bne r2,r3,0x00196148 Branch if RNG said so
+
00196108: a0620058 sb r2,0x0058(r3)                      |{{f/store|Remove Charging}}
  00196134: 26041818 addiu r4,r16,0x1818
+
0019610c: 8e0317f8 lw r3,0x17f8(r16)                    |{{f/adr|Acting Unit Battle data pointer}}
  00196138: 34020002 ori r2,r0,0x0002
+
00196110: 00000000 nop                                  |
  0019613c: a2020ed6 sb r2,0x0ed6(r16) Save AI Progress as 2?
+
00196114: 906201bb lbu r2,0x01bb(r3)                    |{{f/load|Load Inflict Status}}
  00196140: 08065861 j 0x00196184 Exit and return -1
+
00196118: 00000000 nop                                  |
  00196144: 2402ffff addiu r2,r0,0xffff
+
0019611c: 304200f6 andi r2,r2,0x00f6                    |
 
+
00196120: a06201bb sb r2,0x01bb(r3)                      |{{f/store|Remove Charging from Inflicted Status}}
  <Set Charging>
+
00196124: 0c0674df jal 0x0019d37c                        |{{f/jal|AI_End_of_turn,_in_between_turn,_etc.|AI_End_of_turn,_in_between_turn,_etc.}} {{f/std|Simulate movement - Set a priority score of AI 0x14 Action (in AI 0x32)}}
00196148: 8e0317f8 lw r3,0x17f8(r16) Load Acting Unit's Data Pointer
+
00196128: 00000000 nop                                  |
  0019614c: 92020ed0 lbu r2,0x0ed0(r16) Current abiliity CT
+
0019612c: 2403ffff addiu r3,r0,-0x0001                  |
  00196150: 00000000 nop
+
00196130: 14430005 bne r2,r3,0x00196148                  {{f/Cond|<nowiki>If r2 = -0x01 (V-Sync Alert ?)</nowiki>}} {{f/std|Time to refresh animations}}
  00196154: a062015d sb r2,0x015d(r3) Save Current Ability CT
+
00196134: 26041818 addiu r4,r16,0x1818                  |{{f/adr|Pointer to AI 0x17fc + 0x1c}}
  00196158: 8e0317f8 lw r3,0x17f8(r16) Load Acting Unit's Data Pointer
+
00196138: 34020002 ori r2,r0,0x0002                          |{{f/std|<nowiki>Jump in Abort section : Set AI 0xed6 = 0x02</nowiki>}} {{f/loc|Exit}} {{f/Returns|Returns -0x01}}
  0019615c: 92020ed1 lbu r2,0x0ed1(r16) Load Current Status
+
  00196160: 00000000 nop
+
{{f/sec|<nowiki>=== ABORT SECTION ===</nowiki>}}
00196164: a0620058 sb r2,0x0058(r3) Save Current Status
+
0019613c: a2020ed6 sb r2,0x0ed6(r16)                        |{{f/store|Update AI 0xed6}}
  00196168: 8e0317f8 lw r3,0x17f8(r16) Load Acting Unit's Data Pointer
+
00196140: 08065861 j 0x00196184                              |{{f/loc|Exit}} {{f/Returns|Return -0x01}}
0019616c: 92020ed2 lbu r2,0x0ed2(r16) Load inflicted status 1
+
00196144: 2402ffff addiu r2,r0,-0x0001                      |
00196170: 26050030 addiu r5,r16,0x0030
+
  00196174: 0c065b6c jal 0x00196db0 Compare Current Target Priority/Accuracy to the Highest
+
                                                          '''Else if Not Aborting : restore battle data'''
00196178: a06201bb sb r2,0x01bb(r3) Save Inflicted Status 1
+
00196148: 8e0317f8 lw r3,0x17f8(r16)                        |{{f/adr|Acting Unit Battle data pointer}}
0019617c: 38420002 xori r2,r2,0x0002 Remove or add "Lower priority" flag
+
0019614c: 92020ed0 lbu r2,0x0ed0(r16)                        |{{f/load|Preserved Caster Abiliity CT}}
00196180: 2c420001 sltiu r2,r2,0x0001 1 if lower priority, 0 for all other cases
+
00196150: 00000000 nop                                      |
 
+
00196154: a062015d sb r2,0x015d(r3)                          |{{f/store|Restore Ability CT}}
 +
00196158: 8e0317f8 lw r3,0x17f8(r16)                        |{{f/adr|Acting Unit Battle data pointer}}
 +
0019615c: 92020ed1 lbu r2,0x0ed1(r16)                        |{{f/load|Preserved Current Status 0x01}}
 +
00196160: 00000000 nop                                      |
 +
00196164: a0620058 sb r2,0x0058(r3)                          |{{f/store|Restore Current Status 0x01}}
 +
00196168: 8e0317f8 lw r3,0x17f8(r16)                        |{{f/adr|Acting Unit Battle data pointer}}
 +
0019616c: 92020ed2 lbu r2,0x0ed2(r16)                        |{{f/load|Preserved inflictend Status 0x01}}
 +
00196170: 26050030 addiu r5,r16,0x0030                      |{{f/adr|Pointer to AI 0x14 + 0x1c}}
 +
  00196174: 0c065b6c jal 0x00196db0                            |{{f/jal|Compare_Target_Priority_and_Hit_Rate_(00196db0)|Compare_Target_Priority_and_Hit_Rate_(00196db0)}} {{f/std|Compare Considered Action (AI 0x14 + 0x1c) with selected Action (AI 0x17fc + 0x1c)}}
 +
00196178: a06201bb sb r2,0x01bb(r3)                          |{{f/store|Restore Inflicted Status 0x01}}
 +
0019617c: 38420002 xori r2,r2,0x0002                        |{{f/std|0x00 if Higher outcome, else 0x02 (or 0x03)}}
 +
00196180: 2c420001 sltiu r2,r2,0x0001                        |{{f/std|0x01 if Higher outcome else 0x00}}
 
  00196184: 8fbf0018 lw r31,0x0018(r29)
 
  00196184: 8fbf0018 lw r31,0x0018(r29)
 
  00196188: 8fb10014 lw r17,0x0014(r29)
 
  00196188: 8fb10014 lw r17,0x0014(r29)
Line 145: Line 156:
 
  00196194: 03e00008 jr r31
 
  00196194: 03e00008 jr r31
 
  00196198: 00000000 nop
 
  00196198: 00000000 nop
 +
===Return locations===
 +
'''BATTLE.BIN'''
 +
  00196218: [[Non-Specific_AI_AutoBattle_(Enemies)]]
 +
  0019820c: [[Fight_for_Life_-_Auto_Battle_(00197ff4)]]
 +
  00198714: [[Protect_Allies_-_Auto_Battle_(001984ec)]]
 +
  00198f4c: [[AI_Critical_or_Run_Like_Rabbit]]

Latest revision as of 10:30, 25 June 2024

BATTLE.BIN :  - Set_or_Remove_Charging_(00195f8c)
If Charging - Set Considered destination and simaulate movement while charging, or without charging (Aim, Dance and Song Hardcoded section)
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = 0x00 (Default)
         r2 = -0x01 if Routine has aborted (AI 0xed6 is updated) - V_Sync alert ?
         r2 = 0x01 Considered Action has better outcome than selected one (AI 0x17fc)
------------------------------------------------------------------------------------------
00195f8c: 3c04801a lui r4,0x801a             |
00195f90: 8c840bbc lw r4,0x0bbc(r4)          |Pointer to Acting Unit Battle data
00195f94: 3c02801a lui r2,0x801a             |
00195f98: 90420d7b lbu r2,0x0d7b(r2)         |AI 0x19b7
00195f9c: 27bdffe0 addiu r29,r29,-0x0020     |
00195fa0: afb00010 sw r16,0x0010(r29)        |
00195fa4: 3c10801a lui r16,0x801a            |
00195fa8: 2610f3c4 addiu r16,r16,0xf3c4      |0x8019f3c4
00195fac: afbf0018 sw r31,0x0018(r29)        |
00195fb0: afb10014 sw r17,0x0014(r29)        |

=== Return to where the code left off ===
00195fb4: 1040000a beq r2,r0,0x00195fe0      #If AI 0x19b7 <> 0x00
00195fb8: 2491016e addiu r17,r4,0x016e       |Acting Unit Current Action data
00195fbc: 3c03801a lui r3,0x801a                 |
00195fc0: 9063029a lbu r3,0x029a(r3)             |AI 0xed6 (this routine memory variable)
00195fc4: 00000000 nop                           |
00195fc8: 10600028 beq r3,r0,0x0019606c          #If Memory variable is 0x00 : Return to Song Dance movement evaluation
00195fcc: 34020001 ori r2,r0,0x0001              |
00195fd0: 10620031 beq r3,r2,0x00196098          #If Memory variable is 0x01 : Return to Default ability movement evaluation (while charging)
00195fd4: 00000000 nop                           |
00195fd8: 08065849 j 0x00196124                  #Else : Memory Variable is 0x02 Return to Default ability movement evaluation (without charging)
00195fdc: 00000000 nop                           |

=== Start from beginning ===
                                             Else : AI 0x19b7 = 0x00
00195fe0: 9083015d lbu r3,0x015d(r4)             |Acting Unit Current Ability CT
00195fe4: 340200ff ori r2,r0,0x00ff              |
00195fe8: 10620066 beq r3,r2,0x00196184          #If Acting Unit is not charging : Exit  Returns 0x00
00195fec: 00001021 addu r2,r0,r0                 |
00195ff0: 9082016f lbu r2,0x016f(r4)             |Acting Unit Skillset of Last Attack Used
00195ff4: 3c018006 lui r1,0x8006                 |
00195ff8: 00220821 addu r1,r1,r2                 |0x80060000 + Skillset offset (for action menu)
00195ffc: 90235cb4 lbu r3,0x5cb4(r1)             |Get Acting Unit Last used Action Menu
00196000: 3402000a ori r2,r0,0x000a              |

                  --- Set destination ---
00196004: 14620007 bne r3,r2,0x00196024          #If Action menu is [Aim] Charge skillset
00196008: 00000000 nop                               |
0019600c: 3c02801a lui r2,0x801a                     |
00196010: 8c4201f4 lw r2,0x01f4(r2)                  |Acting Unit XY Coordinates 0x8019f3c4 + 0x0e30
00196014: 3c01801a lui r1,0x801a                     |
00196018: ac22f3dc sw r2,-0x0c24(r1)                 |Save to AI Considered Action destination 0x8019f3c4 + 0x18
0019601c: 08065814 j 0x00196050                      |Avoid non-Charge section
00196020: a2000014 sb r0,0x0014(r16)                 |AI 0x14 = 0x00 labeled as IsTargetFlagsSet. Afaik seems to more likely related to Caster position or necessity to move
                                                 Else : Not Charge
00196024: 3c02801a lui r2,0x801a                     |
00196028: 904201f1 lbu r2,0x01f1(r2)                 |AI 0xe2d Destination consideration (0x1 close to target, 0x2 Away from Target)
0019602c: 00000000 nop                               |
00196030: 00021080 sll r2,r2,0x02                    |AI 0xe2d offset (Word)
00196034: 00501021 addu r2,r2,r16                    |
00196038: 8c420cc4 lw r2,0x0cc4(r2)                  |Load Destination of interest coordinates
0019603c: 3c01801a lui r1,0x801a                     |
00196040: ac22f3dc sw r2,-0x0c24(r1)                 |Save to AI Considered Action destination 0x8019f3c4 + 0x18
00196044: 0c066ec8 jal 0x0019bb20                    |-->AI_Check_if_Unit_is_a_Crystal/Treasure_(0019bb20) Set 0x801a0083 Value ("crystal on destination" flag)
00196048: 00000000 nop                               |
0019604c: a2000014 sb r0,0x0014(r16)                 |AI 0x14 = 0x00 labeled as IsTargetFlagsSet. Afaik seems to more likely related to Caster position or necessity to move
00196050: a200001d sb r0,0x001d(r16)             |Set Considered Skillset = 0x00 AI 0x1d (akaAI  0x14 + 0x9)  -  Move only

                  --- Simulate Movement ---
00196054: 96220002 lhu r2,0x0002(r17)            |Acting Unit  Last  Used Ability
00196058: 00000000 nop                           |
0019605c: 2442ffaa addiu r2,r2,-0x0056           |Attack ID - 0x56 (Angel Song ID)
00196060: 2c42000e sltiu r2,r2,0x000e            |0x1 if Any Song or Dance Ability
00196064: 1040000c beq r2,r0,0x00196098          #If Used Ability is a Song or Dance Ability Will hit the whole map 
00196068: 00000000 nop                               |
0019606c: 0c0674c2 jal 0x0019d308                    |-->Check_Set_Highest_Unit_Priority_(0019d308) Set priority score for considered action (Store Action data in AI 0x34)
00196070: 00000000 nop                               |
00196074: 2403ffff addiu r3,r0,-0x0001               |
00196078: 14430003 bne r2,r3,0x00196088              #If returned r2 = -0x01 V_Sync Alert ?
0019607c: 2402ffff addiu r2,r0,-0x0001                   |
00196080: 08065861 j 0x00196184                          >>Set AI 0xed6 = 0x00 Exit Returns -0x01
00196084: a2000ed6 sb r0,0x0ed6(r16)                     |
                                                     Else : no V-Sync Alert
00196088: 0c065bf1 jal 0x00196fc4                        |-->Compare_Set_Highest_Unit_Target_Priority_(00196fc4) Save AI 0x34 in stored Action if better outcome (AI 0x54 to AI 0x134)
0019608c: 00000000 nop                                   |
00196090: 08065861 j 0x00196184                          |Exit  return 0x00
00196094: 00001021 addu r2,r0,r0                         |
                                                 Else : Not a Song nor Dance Ability (consider canceling charge or not)
00196098: 0c0674df jal 0x0019d37c                    |-->AI_End_of_turn,_in_between_turn,_etc. Simulate movement - Set a priority score of AI 0x14 Action (in AI 0x32)
0019609c: 00000000 nop                               |
001960a0: 2403ffff addiu r3,r0,-0x0001               |
001960a4: 14430003 bne r2,r3,0x001960b4              #If returned r2 = -0x01 V_Sync Alert ?
001960a8: 260417fc addiu r4,r16,0x17fc               |Pointer to AI 0x17fc Selected action
001960ac: 0806584f j 0x0019613c                          >>Set AI 0xed6 = 0x01 Exit Returns -0x01
001960b0: 34020001 ori r2,r0,0x0001                      |
                                                     Else : do not abort
001960b4: 26050014 addiu r5,r16,0x0014                   |
001960b8: 0c066ac2 jal 0x0019ab08                        |-->Transfer Halfword Values Transfer considered action to selected action (AI 0x14 to AI 0x17fc)
001960bc: 34060020 ori r6,r0,0x0020                      |Transfer 0x20 bytes
001960c0: 8e0217f8 lw r2,0x17f8(r16)                     |Acting Unit Battle data pointer
001960c4: 8e0317f8 lw r3,0x17f8(r16)                     |Acting Unit Battle data pointer
001960c8: 9042015d lbu r2,0x015d(r2)                     |Load Current Ability CT
001960cc: 00000000 nop                                   |
001960d0: a2020ed0 sb r2,0x0ed0(r16)                     |Save Current Ability CT to AI 0xed0
001960d4: 90620058 lbu r2,0x0058(r3)                     |Load Current Status 1
001960d8: 8e0317f8 lw r3,0x17f8(r16)                     |Acting Unit Battle data pointer
001960dc: a2020ed1 sb r2,0x0ed1(r16)                     |Save Current Status to AI 0xed1
001960e0: 906201bb lbu r2,0x01bb(r3)                     |Load Inflicted Status 1
001960e4: 8e0317f8 lw r3,0x17f8(r16)                     |Acting Unit Battle data pointer
001960e8: a2020ed2 sb r2,0x0ed2(r16)                     |Save Inflict Status 1 to AI 0xed2
001960ec: 340200ff ori r2,r0,0x00ff                      |
001960f0: a062015d sb r2,0x015d(r3)                      |Set Current CT = 0xff (not charging)
001960f4: 8e0317f8 lw r3,0x17f8(r16)                     |Acting Unit Battle data pointer
001960f8: 00000000 nop                                   |
001960fc: 90620058 lbu r2,0x0058(r3)                     |Load Current Status 1
00196100: 00000000 nop                                   |
00196104: 304200f6 andi r2,r2,0x00f6                     |
00196108: a0620058 sb r2,0x0058(r3)                      |Remove Charging
0019610c: 8e0317f8 lw r3,0x17f8(r16)                     |Acting Unit Battle data pointer
00196110: 00000000 nop                                   |
00196114: 906201bb lbu r2,0x01bb(r3)                     |Load Inflict Status
00196118: 00000000 nop                                   |
0019611c: 304200f6 andi r2,r2,0x00f6                     |
00196120: a06201bb sb r2,0x01bb(r3)                      |Remove Charging from Inflicted Status
00196124: 0c0674df jal 0x0019d37c                        |-->AI_End_of_turn,_in_between_turn,_etc. Simulate movement - Set a priority score of AI 0x14 Action (in AI 0x32)
00196128: 00000000 nop                                   |
0019612c: 2403ffff addiu r3,r0,-0x0001                   |
00196130: 14430005 bne r2,r3,0x00196148                  #If r2 = -0x01 (V-Sync Alert ?) Time to refresh animations
00196134: 26041818 addiu r4,r16,0x1818                   |Pointer to AI 0x17fc + 0x1c
00196138: 34020002 ori r2,r0,0x0002                          |Jump in Abort section : Set AI 0xed6 = 0x02 Exit Returns -0x01

=== ABORT SECTION ===
0019613c: a2020ed6 sb r2,0x0ed6(r16)                         |Update AI 0xed6
00196140: 08065861 j 0x00196184                              |Exit Return -0x01
00196144: 2402ffff addiu r2,r0,-0x0001                       |

                                                         Else if Not Aborting : restore battle data
00196148: 8e0317f8 lw r3,0x17f8(r16)                         |Acting Unit Battle data pointer
0019614c: 92020ed0 lbu r2,0x0ed0(r16)                        |Preserved Caster Abiliity CT
00196150: 00000000 nop                                       |
00196154: a062015d sb r2,0x015d(r3)                          |Restore Ability CT
00196158: 8e0317f8 lw r3,0x17f8(r16)                         |Acting Unit Battle data pointer
0019615c: 92020ed1 lbu r2,0x0ed1(r16)                        |Preserved Current Status 0x01
00196160: 00000000 nop                                       |
00196164: a0620058 sb r2,0x0058(r3)                          |Restore Current Status 0x01
00196168: 8e0317f8 lw r3,0x17f8(r16)                         |Acting Unit Battle data pointer
0019616c: 92020ed2 lbu r2,0x0ed2(r16)                        |Preserved inflictend Status 0x01
00196170: 26050030 addiu r5,r16,0x0030                       |Pointer to AI 0x14 + 0x1c
00196174: 0c065b6c jal 0x00196db0                            |-->Compare_Target_Priority_and_Hit_Rate_(00196db0) Compare Considered Action (AI 0x14 + 0x1c) with selected Action (AI 0x17fc + 0x1c)
00196178: a06201bb sb r2,0x01bb(r3)                          |Restore Inflicted Status 0x01
0019617c: 38420002 xori r2,r2,0x0002                         |0x00 if Higher outcome, else 0x02 (or 0x03)
00196180: 2c420001 sltiu r2,r2,0x0001                        |0x01 if Higher outcome else 0x00
00196184: 8fbf0018 lw r31,0x0018(r29)
00196188: 8fb10014 lw r17,0x0014(r29)
0019618c: 8fb00010 lw r16,0x0010(r29)
00196190: 27bd0020 addiu r29,r29,0x0020
00196194: 03e00008 jr r31
00196198: 00000000 nop

Return locations

BATTLE.BIN
 00196218: Non-Specific_AI_AutoBattle_(Enemies)
 0019820c: Fight_for_Life_-_Auto_Battle_(00197ff4)
 00198714: Protect_Allies_-_Auto_Battle_(001984ec)
 00198f4c: AI_Critical_or_Run_Like_Rabbit