Set or Remove Charging (00195f8c)

From Final Fantasy Hacktics Wiki
Revision as of 10:30, 25 June 2024 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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