Status infliction/removal

From Final Fantasy Hacktics Wiki
Revision as of 22:31, 8 February 2024 by RetroTypes (talk | contribs)
Jump to navigation Jump to search
Parameters : r4 = Acting unit's data pointer
             r5 = Input value (*4 to determine offset in 0x80059830 table)

Will update Acting's unit's 0x1bb (infilcted status set 1) and 0x58 (current status set 1)
If r5 = 0x00 : remove everything
   r5 = 0x05 : inflict charging, remove everything else
   r5 = 0x06 : inflict jump, remove everything else
   r5 = 0x07 : inflict defending, remove everything else
   r5 = 0x08 : inflict performing, remove everything else
   r5 = 0xff : if r4 unit is performing act like r5 = 0x08, else r5 = 0x00
If r5 = 0x00 0x07 or 0x08  Update r4's 0x015d (Ability CT) with 0x0ff or last used ability CT
-------------------------------------------------------------------------------------------------
0005e7a8: 27bdffd8 addiu r29,r29,-0x0028                     
0005e7ac: afb20018 sw r18,0x0018(r29)                        
0005e7b0: 00809021 addu r18,r4,r0           |r18 = Acting Unit's Data Pointer
0005e7b4: 30a300ff andi r3,r5,0x00ff        |r3 = Input Value
0005e7b8: 340200ff ori r2,r0,0x00ff         |r2 = 0x0ff
0005e7bc: afbf0024 sw r31,0x0024(r29)       |
0005e7c0: afb40020 sw r20,0x0020(r29)       |
0005e7c4: afb3001c sw r19,0x001c(r29)       |
0005e7c8: afb10014 sw r17,0x0014(r29)       |
0005e7cc: afb00010 sw r16,0x0010(r29)       |
0005e7d0: 92540058 lbu r20,0x0058(r18)      |r20 = Acting unit's current status (0x58)
0005e7d4: 9253018a lbu r19,0x018a(r18)      |r19 = Acting unit raw ID (0x18a)
0005e7d8: 14620005 bne r3,r2,0x0005e7f0     #If Input Value = 0x0ff
0005e7dc: 2c620009 sltiu r2,r3,0x0009       |r2 = 0x01 if Input Value < 0x09
0005e7e0: 32820001 andi r2,r20,0x0001            |r2 = 0x01 if Acting unit is performing / Else 0x00
0005e7e4: 000228c0 sll r5,r2,0x03                |r5 = 0x08 if Acting unit is performing / Else 0x00
0005e7e8: 30a300ff andi r3,r5,0x00ff             |r3 = Force Input Value to be  0x08 if Unit is performing else 0x00
0005e7ec: 2c620009 sltiu r2,r3,0x0009            |r2 = 0x01 if Input Value < 0x09
0005e7f0: 10400016 beq r2,r0,0x0005e84c     #If Input Value < 0x08
0005e7f4: 00031080 sll r2,r3,0x02                |r2 = Input Value * 4
0005e7f8: 3c018006 lui r1,0x8006                 |
0005e7fc: 00220821 addu r1,r1,r2                 |
0005e800: 8c229830 lw r2,-0x67d0(r1)             |r2 = Jump Adress from Input Value  0x80059830
0005e804: 00000000 nop                           |
0005e808: 00400008 jr r2                         >>jump to section
0005e80c: 00000000 nop                           |

                                            -- Normal Action Input Value = 0x00 --
0005e810: 00008821 addu r17,r0,r0                    |r17 = 0x00 (no status)
0005e814: 08017a12 j 0x0005e848                      >>jump after sections (store 0x0ff as Ability CT)
0005e818: 340200ff ori r2,r0,0x00ff                  |r2 = 0x0ff

                                            -- Charging Input Value = 0x05 --
0005e81c: 08017a13 j 0x0005e84c                      >>jump after sections (no Ability CT)
0005e820: 34110008 ori r17,r0,0x0008                 |r17  =0x08 (Charge flag in status set 1)

                                            -- Jump Input Value = 0x06 --
0005e824: 08017a13 j 0x0005e84c                      >>jump after sections (no Ability CT)
0005e828: 34110004 ori r17,r0,0x0004                 |r17 = 0x04 (Jump flag in status set 1)

                                            -- Defending Input Value = 0x07 --
0005e82c: 34110002 ori r17,r0,0x0002                 |r17 = 0x02 (Defending flag in status set 1)
0005e830: 08017a12 j 0x0005e848                      >>jump after sections (store 0x0ff as Ability CT)
0005e834: 340200ff ori r2,r0,0x00ff                  |CT = 0x0ff

                                            -- Performing Input Value = 0x08 --
0005e838: 0c0179de jal 0x0005e778                    |-->Transfer_Last_Ability_Used_CT
0005e83c: 02402021 addu r4,r18,r0                    |r4 = Acting Unit's Data Pointer
0005e840: 9242018b lbu r2,0x018b(r18)                |Load Acting Unit's Last Used Ability CT
0005e844: 34110001 ori r17,r0,0x0001                 |r17 = 1 (Performing flag in status set 1)
0005e848: a242015d sb r2,0x015d(r18)                 |Store Unit's Ability CT

                                            -- Default  (or Input Value = 0x01 / 0x02 / 0x03 / 0x04 or invalid) - (not seen anywhere) --
0005e84c: 3a30000f xori r16,r17,0x000f      |r16 = everything but the Status flag from above section
0005e850: 02402021 addu r4,r18,r0           |r4 = Acting unit's data pointer
0005e854: 00002821 addu r5,r0,r0            |r5 = 0 (Status Set 1 for routine below)
0005e858: 322600ff andi r6,r17,0x00ff       |r6 = Status flag from above section
0005e85c: 0c0179b3 jal 0x0005e6cc           |-->Inflicted_Status_Changes Add status r17 in Unit inflicted (0x1bb) and current (0x58) status
0005e860: 00003821 addu r7,r0,r0            |r7 = 0 (Enable Statuses)
0005e864: 02402021 addu r4,r18,r0           |r4 = Unit's Data Pointer
0005e868: 00002821 addu r5,r0,r0            |r5 = 0 (Status Set 1)
0005e86c: 320600ff andi r6,r16,0x00ff       |r6 = Statuses to Disable
0005e870: 0c0179b3 jal 0x0005e6cc           |-->Inflicted_Status_Changes Remove every status but r17 in Unit inflicted (0x1bb) and current (0x58) status 
0005e874: 34070001 ori r7,r0,0x0001         |r7 = 1 (Disable Statuses)
0005e878: 34110008 ori r17,r0,0x0008        |Status Check = 0x08
0005e87c: 92420058 lbu r2,0x0058(r18)       |r2 = Acting Unit's Current Statuses
0005e880: 34100005 ori r16,r0,0x0005        |r16 = 0x05
0005e884: 02821026 xor r2,r20,r2            |r2 = Difference between Current status at the start of the routine and now (= Added/removed status)
0005e888: 00409021 addu r18,r2,r0           |r18 = Statuses that were added or removed
0005e88c: 02511024 and r2,r18,r17           @LOOP r2 <> 0x00 if this iteration status was added/removed (charging(0x08), then jumping (0x04), defending, performing)
0005e890: 10400008 beq r2,r0,0x0005e8b4          #if Performing has been updtaed /Else go to next iteration
0005e894: 02911024 and r2,r20,r17                    |r2 = this iteration status was present at the start of the routine (so it has been removed now)
0005e898: 10400003 beq r2,r0,0x0005e8a8              #If This iteration status has been removed
0005e89c: 02002021 addu r4,r16,r0                    |r4 = Counter (0x05 to 0x08)
0005e8a0: 08017a2b j 0x0005e8ac                          >>jump to next jal routine with r5 = 0x00
0005e8a4: 00002821 addu r5,r0,r0                         |r5 = 0 (Status Removed)
0005e8a8: 34050001 ori r5,r0,0x0001                  #Else (status  added) r5 = 1 (Status added)
0005e8ac: 0c063a6f jal 0x0018e9bc                    |-->Determine_if_Status_Flags_can_be_Enabled Update Acting unit misc 0x148 0x14C 0x150 0x154
0005e8b0: 02603021 addu r6,r19,r0                    |r6 = Acting unit's raw ID
0005e8b4: 26100001 addiu r16,r16,0x0001          |r16 = loop counter + 1
0005e8b8: 2a020009 slti r2,r16,0x0009            |r2 = 0x01 while counter < 0x09
0005e8bc: 1440fff3 bne r2,r0,0x0005e88c     Λ loop while counter < 0x09 (4 iterations)
0005e8c0: 00118842 srl r17,r17,0x01              |r17 = 0x04, then 0x02, then 0x01
0005e8c4: 8fbf0024 lw r31,0x0024(r29)            
0005e8c8: 8fb40020 lw r20,0x0020(r29)            
0005e8cc: 8fb3001c lw r19,0x001c(r29)            
0005e8d0: 8fb20018 lw r18,0x0018(r29)            
0005e8d4: 8fb10014 lw r17,0x0014(r29)            
0005e8d8: 8fb00010 lw r16,0x0010(r29)            
0005e8dc: 27bd0028 addiu r29,r29,0x0028          
0005e8e0: 03e00008 jr r31                        
0005e8e4: 00000000 nop                           

Return locations

Battle.bin
0017c78c: Attack_Preparation                     r5 = 0x06 (jump section)
0017c8d4: Attack_Preparation                     r5 = 0x05	
0017da6c: Ability_Usage_Checks_and_MP_Reduction  r5 = 0xff  
00180220: Disable_acting_statuses                r5 = 0x00	
00183df0: Enable/disable_acting_status           r5 = 0x00	
00183e28: Another_intermediate_routine           r5 = 0x07