Steal Routine

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
No Parameters

Returns r2 : 0x01 if something is broken/stolen
             0x00 if nothing is done

Routine is skipped if TCA special flags 0x10 and 0x04 are null
Check if targeted item exists or can be removed (Item's type flag 0x01 is null)
Set targeted equipment ID to 0xff
If Item is stolen, add it to inventory
Update Unit stats without the targeted equipment
Cancel charging status if target was charging a charge ability 
-----------------------------------------------------------------------------
0018d3c0: 3c028019 lui r2,0x8019            |
0018d3c4: 8c422d90 lw r2,0x2d90(r2)         |r2 = TCA data pointer
0018d3c8: 27bdffe0 addiu r29,r29,-0x0020    |
0018d3cc: afbf001c sw r31,0x001c(r29)       |
0018d3d0: afb20018 sw r18,0x0018(r29)       |
0018d3d4: afb10014 sw r17,0x0014(r29)       |
0018d3d8: afb00010 sw r16,0x0010(r29)       |
0018d3dc: 94420010 lhu r2,0x0010(r2)        |r2 = TCA special flags (1 and 2)
0018d3e0: 00000000 nop                      |
0018d3e4: 30420014 andi r2,r2,0x0014        |r2 <> 0x00 if TCA has steal or break enabled
0018d3e8: 10400059 beq r2,r0,0x0018d550     #If Something has been stolen or broken /Else branch to  END!  (r2 will be set to 0x00)
0018d3ec: 00008821 addu r17,r0,r0           |r17 = 0x00
0018d3f0: 00008021 addu r16,r0,r0               |r16 = 0x00 (loop counter )
0018d3f4: 341200ff ori r18,r0,0x00ff            |r18 = 0x0ff
0018d3f8: 3c028019 lui r2,0x8019                @LOOP - each iteration test 1 Target unit equipment slot and 1 bit of TCA 0x19 byte
0018d3fc: 8c422d90 lw r2,0x2d90(r2)                 |r2 = TCA data pointer
0018d400: 34030080 ori r3,r0,0x0080                 |r3 = 0x80
0018d404: 90420019 lbu r2,0x0019(r2)                |r2 = TCA removed equipment
0018d408: 02031807 srav r3,r3,r16                   |r3 = This iteration bit mask ( from 0x80 to 0x01)
0018d40c: 00431024 and r2,r2,r3                     |r2 = This iteration removed equipment check
0018d410: 10400021 beq r2,r0,0x0018d498             #If This iteration Equipment will be removed
0018d414: 00000000 nop                                  |
0018d418: 3c028019 lui r2,0x8019                        |
0018d41c: 8c422d98 lw r2,0x2d98(r2)                     |r2 = Target unit data pointer
0018d420: 00000000 nop                                  |
0018d424: 00501821 addu r3,r2,r16                       |r3 = This Iteration Target unit equiped Item data pointer
0018d428: 9065001a lbu r5,0x001a(r3)                    |r5 = This Iteration equiped item
0018d42c: 00000000 nop                                  |
0018d430: 10a00019 beq r5,r0,0x0018d498                 #If Target unit has no item equiped in desired slot (Item ID = 0x00)
0018d434: 00000000 nop                                      |
0018d438: 10b20017 beq r5,r18,0x0018d498                    #If Target unit Equiped Item exists (not 0x00ff)
0018d43c: 00051040 sll r2,r5,0x01                               |r2 = This Iteration Equiped Item ID * 2
0018d440: 00451021 addu r2,r2,r5                                |r2 = This Iteration Equiped Item ID * 3
0018d444: 00021080 sll r2,r2,0x02                               |r2 = This Iteration Equiped Item ID * 12
0018d448: 3c018006 lui r1,0x8006                                |
0018d44c: 00220821 addu r1,r1,r2                                |r1 = 0x8006 0000  + Item data offset
0018d450: 90222ebb lbu r2,0x2ebb(r1)                            |r2 = Item Type                *80062ebb + 0x03
0018d454: 00000000 nop                                          |
0018d458: 30420001 andi r2,r2,0x0001                            |r2 = 0x00 if regular item type (0x01 is not referenced in the wiki)
0018d45c: 1440000e bne r2,r0,0x0018d498                         #If Item type 0x01 is not enabled
0018d460: 00000000 nop                                              |
0018d464: a072001a sb r18,0x001a(r3)                                |Store 0x0ff as Target unit Equiped Item ID
0018d468: 3c028019 lui r2,0x8019                                    |
0018d46c: 8c422d90 lw r2,0x2d90(r2)                                 |r2 = TCA data pointer
0018d470: 00000000 nop                                              |
0018d474: 94420010 lhu r2,0x0010(r2)                                |r2 = TCA specials flags
0018d478: 00000000 nop                                              |
0018d47c: 30420010 andi r2,r2,0x0010                                |r2 = 0x10 if item is stolen (0x00 if broken)
0018d480: 10400005 beq r2,r0,0x0018d498                             #If Item is stolen
0018d484: 26310001 addiu r17,r17,0x0001                             |r17 = 0x01 (something broken/stolen flag ?)
0018d488: 3c048019 lui r4,0x8019                                        |
0018d48c: 8c842d94 lw r4,0x2d94(r4)                                     |r4 = Acting unit data pointer
0018d490: 0c063a7a jal 0x0018e9e8                                       |-->Item_quantity_increment_for_steal/break%3F Add item to inventory or 25% of price
0018d494: 00000000 nop                                                  |
0018d498: 26100001 addiu r16,r16,0x0001             |r16 = loop counter + 1
0018d49c: 2a020007 slti r2,r16,0x0007               |r2 = 0x01 if loop counter < 0x07
0018d4a0: 1440ffd5 bne r2,r0,0x0018d3f8         Λ loop 7 Times (each equipment slot)
0018d4a4: 00000000 nop                              |
0018d4a8: 1220002a beq r17,r0,0x0018d554        #If Something has been stolen/broken /Else branch to  END (r2 = 0x00)
0018d4ac: 00001021 addu r2,r0,r0                |r2 = 0x00
0018d4b0: 3c028019 lui r2,0x8019                    |
0018d4b4: 8c42f5fc lw r2,-0x0a04(r2)                |r2 = Action State   0x8018f5fc
0018d4b8: 00000000 nop                              |
0018d4bc: 14400005 bne r2,r0,0x0018d4d4             #if Action is being executed
0018d4c0: 00000000 nop                                  |
0018d4c4: 3c048019 lui r4,0x8019                        |
0018d4c8: 8c842d98 lw r4,0x2d98(r4)                     |r4 = Target unit data pointer
0018d4cc: 0c017578 jal 0x0005d5e0                       |-->status setting/checking + equip  R/S/M stats check Update unit stats (equipment removed)
0018d4d0: 00000000 nop                                  |
0018d4d4: 3c058019 lui r5,0x8019                    |
0018d4d8: 8ca52d90 lw r5,0x2d90(r5)                 |r5 = TCA data pointer
0018d4dc: 00000000 nop                              |
0018d4e0: 90a30019 lbu r3,0x0019(r5)                |r3 = TCA removed equipment
0018d4e4: 34020010 ori r2,r0,0x0010                 |
0018d4e8: 10620003 beq r3,r2,0x0018d4f8             #If removed equipment is not RH weapon
0018d4ec: 34020004 ori r2,r0,0x0004                     |
0018d4f0: 14620018 bne r3,r2,0x0018d554                 #If equipment is LH weapon /Else branch to END with r2 = 0x01 (not a weapon ?)
0018d4f4: 34020001 ori r2,r0,0x0001                         |
0018d4f8: 3c048019 lui r4,0x8019                    #E   
0018d4fc: 8c842d98 lw r4,0x2d98(r4)                         |r4 = Target unit data pointer
0018d500: 00000000 nop                                      |
0018d504: 90820058 lbu r2,0x0058(r4)                        |r2 = Target current status (1st set)
0018d508: 00000000 nop                                      |
0018d50c: 30420008 andi r2,r2,0x0008                        |r2 = 0x08 if Target is charging
0018d510: 1040000d beq r2,r0,0x0018d548                     #If Target is charging
0018d514: 340200ff ori r2,r0,0x00ff                             |r2 = 0x00ff
0018d518: 9083015d lbu r3,0x015d(r4)                            |r3 =  target current ability CT
0018d51c: 00000000 nop                                          |
0018d520: 10620009 beq r3,r2,0x0018d548                         #If CT of charged Ability is valid (not 0x00ff)
0018d524: 34020008 ori r2,r0,0x0008                                 |
0018d528: 9083016f lbu r3,0x016f(r4)                                |r3 = Target last used skillset
0018d52c: 00000000 nop                                              |
0018d530: 14620005 bne r3,r2,0x0018d548                             #If last used skillset is charge
0018d534: 00000000 nop                                                  |
0018d538: 90a20020 lbu r2,0x0020(r5)                                    |r2 = TCA status removal (1st set)
0018d53c: 00000000 nop                                                  |
0018d540: 34420008 ori r2,r2,0x0008                                     |
0018d544: a0a20020 sb r2,0x0020(r5)                                     |store remove charge
0018d548: 08063555 j 0x0018d554                                         >>jump to End with r2 = 0x01
0018d54c: 34020001 ori r2,r0,0x0001                                     |
0018d550: 00001021 addu r2,r0,r0            |r2 = 0x00 (No break/steal special flags - Nothing done) 
0018d554: 8fbf001c lw r31,0x001c(r29) 
0018d558: 8fb20018 lw r18,0x0018(r29)
0018d55c: 8fb10014 lw r17,0x0014(r29)
0018d560: 8fb00010 lw r16,0x0010(r29)
0018d564: 27bd0020 addiu r29,r29,0x0020
0018d568: 03e00008 jr r31 
0018d56c: 00000000 nop

Return location

Battle.bin
0018c170: Attack_Finalisation_&_Reaction_Flagging