Compare Set Highest Unit Target Priority (00196fc4)

From Final Fantasy Hacktics Wiki
Revision as of 15:12, 15 June 2024 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN :  -  Compare and Set Highest Unit Target Priority
Insert Current Action outcome (AI 0x34) in Recorded Actions Outcome (AI 0x54 to AI 0x134). AI 0x54 has the higher outcome
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : Nothing
------------------------------------------------------------------------------------------
00196fc4: 27bdffd8 addiu r29,r29,-0x0028     |
00196fc8: afb40020 sw r20,0x0020(r29)        |
00196fcc: 3c14801a lui r20,0x801a            |
00196fd0: 2694f3c4 addiu r20,r20,0xf3c4      |0x8019f3c4
00196fd4: 26840050 addiu r4,r20,0x0050       |0x8019f3c4 + 0x50
00196fd8: 26850170 addiu r5,r20,0x0170       |0x8019f3c4 + 0x170
00196fdc: afbf0024 sw r31,0x0024(r29)        |
00196fe0: afb3001c sw r19,0x001c(r29)        |
00196fe4: afb20018 sw r18,0x0018(r29)        |
00196fe8: afb10014 sw r17,0x0014(r29)        |
00196fec: 0c065b6c jal 0x00196db0            |-->Compare Target Priority and Hit Rate Compare AI 0x50 ad 0x170
00196ff0: afb00010 sw r16,0x0010(r29)        |
00196ff4: 34030002 ori r3,r0,0x0002          |
00196ff8: 14430025 bne r2,r3,0x00197090      #if AI 0x50 has higher outcome  than AI 0x170 Else Exit ? (corrupted data ?)
00196ffc: 26840034 addiu r4,r20,0x0034           |0x8019f3c4 + 0x34
00197000: 0c065b88 jal 0x00196e20                |-->Set Highest Target Priority Check AI 0x50 Vs AI 0x150
00197004: 26850134 addiu r5,r20,0x0134           |0x8019f3c4 + 0x134
00197008: 10400021 beq r2,r0,0x00197090          #if AI 0x34 is not better then AI 0x134 : Reset AI 0x34 and Exit Ignore this weak outcome
0019700c: 34100054 ori r16,r0,0x0054             |Prepare dynamic pointer to AI action data
00197010: 00009821 addu r19,r0,r0                |initialize counter

=== Check if current considered action has a better outcome than previous simulation ===
                                                @LOOP
00197014: 26840034 addiu r4,r20,0x0034               |Static pointer to AI 0x34
00197018: 0c065b88 jal 0x00196e20                    |-->Set Highest Target Priority Check Current action score Vs best previous results
0019701c: 02902821 addu r5,r20,r16                   |Dynamic pointer (AI 0x54 to AI 0x134)
00197020: 14400006 bne r2,r0,0x0019703c              #If better score :  Exit loop and reorder action data
00197024: 34020008 ori r2,r0,0x0008                      |
00197028: 26730001 addiu r19,r19,0x0001              |counter +1
0019702c: 2a620008 slti r2,r19,0x0008                |
00197030: 1440fff8 bne r2,r0,0x00197014          Λ loop 8 times
00197034: 26100020 addiu r16,r16,0x0020              |Action data offset (+0x20 each iteration)
00197038: 34020008 ori r2,r0,0x0008                  |
0019703c: 12620014 beq r19,r2,0x00197090         #If AI 0x34 did not beat any previous record : branch to  Reset AI 0x34 and Exit Ignore this weak outcome (2nd check)
00197040: 2a620007 slti r2,r19,0x0007            |
00197044: 1040000c beq r2,r0,0x00197078          |
00197048: 34100007 ori r16,r0,0x0007             |Initialize counter (backward counter)
0019704c: 34120114 ori r18,r0,0x0114             |Prepare dynamic backward pointer (origin)
00197050: 34110134 ori r17,r0,0x0134             |Prepare dynamic backward pointer (destination)

=== Re-order recorded action outcome (and insert current action) ===
                                                @LOOP- reorder action result 
00197054: 02912021 addu r4,r20,r17                   |
00197058: 02922821 addu r5,r20,r18                   |
0019705c: 0c066ac2 jal 0x0019ab08                    |-->Transfer Halfword Values
00197060: 34060020 ori r6,r0,0x0020                  |copy 0x20 bytes
00197064: 2652ffe0 addiu r18,r18,-0x0020             |AI action data offset
00197068: 2610ffff addiu r16,r16,-0x0001             |Counter - 0x1
0019706c: 0270102a slt r2,r19,r16                    |
00197070: 1440fff8 bne r2,r0,0x00197054          Λ Loop while r19 < r16
00197074: 2631ffe0 addiu r17,r17,-0x20               |AI action data offset
00197078: 00102140 sll r4,r16,0x05               |Entry counter * 0x20
0019707c: 24840054 addiu r4,r4,0x0054            |
00197080: 02842021 addu r4,r20,r4                |New entry pointer
00197084: 26850034 addiu r5,r20,0x0034           |Current data pointer (AI 0x34)
00197088: 0c066ac2 jal 0x0019ab08                |-->Transfer Halfword Values Insert current action result in recorded results
0019708c: 34060020 ori r6,r0,0x0020              |

00197090: 0c0657db jal 0x00195f6c            |-->Reset_Highest_Target_Priority
00197094: 26840034 addiu r4,r20,0x0034
00197098: 8fbf0024 lw r31,0x0024(r29)
0019709c: 8fb40020 lw r20,0x0020(r29)
001970a0: 8fb3001c lw r19,0x001c(r29)
001970a4: 8fb20018 lw r18,0x0018(r29)
001970a8: 8fb10014 lw r17,0x0014(r29)
001970ac: 8fb00010 lw r16,0x0010(r29)
001970b0: 27bd0028 addiu r29,r29,0x0028
001970b4: 03e00008 jr r31
001970b8: 00000000 nop

Return locations

BATTLE.BIN
 00196090: Set_or_Remove_Charging_(00195f8c)
 0019b2e8: AI_ability_use_control_routine
 0019b4dc: Check_if_any_units_are_in_range_(0019b30c)
 0019bb00: AI_Targeting_Matrix_Analysis_(0019b7b8)
 0019bebc: Math_Skill_Targeting