Handle Steal Exp

From Final Fantasy Hacktics Wiki
Revision as of 22:42, 10 June 2018 by Glain (talk | contribs) (Created page with " # ROUTINE: HANDLE STEAL EXP (0x18eb50) # Parameters: # r4 = (targetUnit) Target unit in-battle data pointer # r5 = (action_0x28) 0x28 byte of a...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: HANDLE STEAL EXP (0x18eb50)
#       Parameters:
#           r4 = (targetUnit) Target unit in-battle data pointer
#           r5 = (action_0x28) 0x28 byte of action data

8018eb50: 27bdffe8 addiu r29,r29,-0x0018
8018eb54: afb00010 sw r16,0x0010(r29)
8018eb58: 00808021 addu r16,r4,r0                   #   targetUnit
8018eb5c: 3c028019 lui r2,0x8019
8018eb60: 8c42f5fc lw r2,-0x0a04(r2)                #   actionStatus
8018eb64: 00a01821 addu r3,r5,r0                    #   action_0x28
8018eb68: 14400024 bne r2,r0,0x8018ebfc             #   if (actionStatus != ACTION_EXECUTING) return;
8018eb6c: afbf0014 sw r31,0x0014(r29)
8018eb70: 30a20080 andi r2,r5,0x0080                #   action_0x28 & 0x80
8018eb74: 14400018 bne r2,r0,0x8018ebd8
8018eb78: 306300ff andi r3,r3,0x00ff                #   action_0x28
                                                    #   if (action_0x28 & 0x80 == 0) {
8018eb7c: 92020021 lbu r2,0x0021(r16)               #       targetUnit.experience
8018eb80: 00000000 nop
8018eb84: 00431021 addu r2,r2,r3                    #       targetUnit.experience + action_0x28
8018eb88: 00401821 addu r3,r2,r0                    #       value = targetUnit.experience + action_0x28
8018eb8c: 28420100 slti r2,r2,0x0100
8018eb90: 14400002 bne r2,r0,0x8018eb9c             #       if (value >= 256) {
8018eb94: 00000000 nop
8018eb98: 340300ff ori r3,r0,0x00ff                 #           value = 255
                                                    #       }
8018eb9c: a2030021 sb r3,0x0021(r16)                #       targetUnit.experience = value
8018eba0: 0c017620 jal 0x8005d880                   #       didLevelUp = Check if Unit Leveled UP (targetUnit);
8018eba4: 02002021 addu r4,r16,r0                   #       targetUnit
8018eba8: 10400014 beq r2,r0,0x8018ebfc             #       if (!didLevelUp) return;
8018ebac: 00000000 nop
8018ebb0: 9203018a lbu r3,0x018a(r16)               #       targetUnit.unitIndex_0x18a
8018ebb4: 3c028019 lui r2,0x8019
8018ebb8: 8c42f8c8 lw r2,-0x0738(r2)                #       actingUnitIndex
8018ebbc: 00000000 nop
8018ebc0: 1462000e bne r3,r2,0x8018ebfc             #       if (targetUnit.unitIndex_0x18a != actingUnitIndex) return;
8018ebc4: 34020001 ori r2,r0,0x0001
8018ebc8: 3c018019 lui r1,0x8019
8018ebcc: a022390c sb r2,0x390c(r1)                 #       *0x8019390c = 1
8018ebd0: 08063aff j 0x8018ebfc                     
8018ebd4: 00000000 nop                              #   } else {
8018ebd8: 92020021 lbu r2,0x0021(r16)               #       targetUnit.experience
8018ebdc: 30a3007f andi r3,r5,0x007f                #       action_0x28 & 0x7f
8018ebe0: 00431023 subu r2,r2,r3                    #       targetUnit.experience - (action_0x28 & 0x7f)
8018ebe4: 00401821 addu r3,r2,r0                    #       value = targetUnit.experience - (action_0x28 & 0x7f)
8018ebe8: 00021400 sll r2,r2,0x10                   #       value * 1024
8018ebec: 04410002 bgez r2,0x8018ebf8               #       if ((value * 1024) < 0) {
8018ebf0: 00000000 nop
8018ebf4: 00001821 addu r3,r0,r0                    #           value = 0
                                                    #       }
8018ebf8: a2030021 sb r3,0x0021(r16)                #       targetUnit.experience = value
                                                    #   }
8018ebfc: 8fbf0014 lw r31,0x0014(r29)
8018ec00: 8fb00010 lw r16,0x0010(r29)
8018ec04: 27bd0018 addiu r29,r29,0x0018
8018ec08: 03e00008 jr r31
8018ec0c: 00000000 nop