Apply Unit Action Status Removal

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: APPLY UNIT ACTION STATUS REMOVAL
#       Applies a battle unit's status removal (from its action).  Statuses are removed from both current and innate statuses!
#       Parameters:
#           r4 = (unit) Battle unit

8018ec44: 27bdffd8 addiu r29,r29,-0x0028
8018ec48: afb10014 sw r17,0x0014(r29)
8018ec4c: 00808821 addu r17,r4,r0                   #   unit
8018ec50: afb00010 sw r16,0x0010(r29)
8018ec54: 00008021 addu r16,r0,r0                   #   statusByteIndex = 0
8018ec58: 2622018c addiu r2,r17,0x018c              #   (unit + 0x18c)
8018ec5c: afbf0020 sw r31,0x0020(r29)
8018ec60: afb3001c sw r19,0x001c(r29)
8018ec64: afb20018 sw r18,0x0018(r29)
8018ec68: 3c018019 lui r1,0x8019
8018ec6c: ac222d90 sw r2,0x2d90(r1)                 #   action = unit + 0x18c
8018ec70: 9232018a lbu r18,0x018a(r17)              #   unit.index
                                                    #   do {
8018ec74: 02302021 addu r4,r17,r16                  #       (unit + 0x18c + statusByteIndex)
8018ec78: 3c038019 lui r3,0x8019
8018ec7c: 8c632d90 lw r3,0x2d90(r3)                 #       action
8018ec80: 90840058 lbu r4,0x0058(r4)                #       unit.currentStatus[statusByteIndex]
8018ec84: 00701821 addu r3,r3,r16                   #       (action + statusByteIndex)
8018ec88: 90620020 lbu r2,0x0020(r3)                #       action.statusRemoval[statusByteIndex]
8018ec8c: 26100001 addiu r16,r16,0x0001             #       statusByteIndex = statusByteIndex + 1
8018ec90: 00441024 and r2,r2,r4                     #       action.statusRemoval[statusByteIndex] & unit.currentStatus[statusByteIndex]
8018ec94: a0620020 sb r2,0x0020(r3)                 #       action.statusRemoval[statusByteIndex] = action.statusRemoval[statusByteIndex] & unit.currentStatus[statusByteIndex]
8018ec98: 2a020005 slti r2,r16,0x0005
8018ec9c: 1440fff5 bne r2,r0,0x8018ec74             #   } while (statusByteIndex < 5);
8018eca0: 34130080 ori r19,r0,0x0080                #   0x80
8018eca4: 00008021 addu r16,r0,r0                   #   statusIndex = 0
                                                    #   do {
8018eca8: 06010002 bgez r16,0x8018ecb4
8018ecac: 02002021 addu r4,r16,r0
8018ecb0: 26040007 addiu r4,r16,0x0007
8018ecb4: 000420c3 sra r4,r4,0x03                   #       statusByteIndex = statusIndex / 8
8018ecb8: 3c028019 lui r2,0x8019
8018ecbc: 8c422d90 lw r2,0x2d90(r2)                 #       action
8018ecc0: 32030007 andi r3,r16,0x0007               #       statusValue = statusIndex % 8
8018ecc4: 00441021 addu r2,r2,r4                    #       (action + statusByteIndex)
8018ecc8: 90420020 lbu r2,0x0020(r2)                #       action.statusRemoval[statusByteIndex]
8018eccc: 00731807 srav r3,r19,r3                   #       0x80 >> statusValue
8018ecd0: 00431024 and r2,r2,r3                     #       newStatusFlags = action.statusRemoval[statusByteIndex] & (0x80 >> statusValue)
8018ecd4: 10400008 beq r2,r0,0x8018ecf8             #       if (newStatusFlags != 0) {
8018ecd8: 02202021 addu r4,r17,r0
8018ecdc: 02002821 addu r5,r16,r0
8018ece0: 0c0176dc jal 0x8005db70                   #           Status CT Setting (unit, statusIndex, 0);
8018ece4: 00003021 addu r6,r0,r0
8018ece8: 26040001 addiu r4,r16,0x0001
8018ecec: 00002821 addu r5,r0,r0
8018ecf0: 0c063a6f jal 0x8018e9bc                   #           Enable Special Status Flags (statusIndex + 1, 0, unit.index);
8018ecf4: 02403021 addu r6,r18,r0
                                                    #       }
8018ecf8: 26100001 addiu r16,r16,0x0001             #       statusIndex = statusIndex + 1
8018ecfc: 2a020028 slti r2,r16,0x0028
8018ed00: 1440ffe9 bne r2,r0,0x8018eca8             #   } while (statusIndex < 40);
8018ed04: 00000000 nop
8018ed08: 00008021 addu r16,r0,r0                   #   statusByteIndex = 0
                                                    #   do {
8018ed0c: 3c028019 lui r2,0x8019
8018ed10: 8c422d90 lw r2,0x2d90(r2)                 #       action
8018ed14: 02302021 addu r4,r17,r16                  #       (unit + statusByteIndex)
8018ed18: 00501021 addu r2,r2,r16                   #       (action + statusByteIndex)
8018ed1c: 90420020 lbu r2,0x0020(r2)                #       action.statusRemoval[statusByteIndex]
8018ed20: 90830058 lbu r3,0x0058(r4)                #       unit.currentStatus[statusByteIndex]
8018ed24: 00021027 nor r2,r0,r2                     #       ~action.statusRemoval[statusByteIndex]      // Invert bits (binary NOT operation) (Statuses will be removed)
8018ed28: 00621824 and r3,r3,r2                     #       unit.currentStatus[statusByteIndex] & ~action.statusRemoval[statusByteIndex]
8018ed2c: a0830058 sb r3,0x0058(r4)                 #       unit.currentStatus[statusByteIndex] = unit.currentStatus[statusByteIndex] & ~action.statusRemoval[statusByteIndex]
8018ed30: 3c028019 lui r2,0x8019
8018ed34: 8c422d90 lw r2,0x2d90(r2)                 #       action
8018ed38: 9083004e lbu r3,0x004e(r4)                #       unit.innateStatus[statusByteIndex]
8018ed3c: 00501021 addu r2,r2,r16                   #       (action + statusByteIndex)
8018ed40: 90420020 lbu r2,0x0020(r2)                #       action.statusRemoval[statusByteIndex]
8018ed44: 26100001 addiu r16,r16,0x0001             #       statusByteIndex = statusByteIndex + 1
8018ed48: 00021027 nor r2,r0,r2                     #       ~action.statusRemoval[statusByteIndex]      // Invert bits (binary NOT operation) (Statuses will be removed)
8018ed4c: 00621824 and r3,r3,r2                     #       unit.innateStatus[statusByteIndex] & ~action.statusRemoval[statusByteIndex]
8018ed50: 2a020005 slti r2,r16,0x0005
8018ed54: 1440ffed bne r2,r0,0x8018ed0c
8018ed58: a083004e sb r3,0x004e(r4)                 #       unit.innateStatus[statusByteIndex] = unit.innateStatus[statusByteIndex] & ~action.statusRemoval[statusByteIndex]
                                                    #   } while (statusByteIndex < 5);
8018ed5c: 8fbf0020 lw r31,0x0020(r29)
8018ed60: 8fb3001c lw r19,0x001c(r29)
8018ed64: 8fb20018 lw r18,0x0018(r29)
8018ed68: 8fb10014 lw r17,0x0014(r29)
8018ed6c: 8fb00010 lw r16,0x0010(r29)
8018ed70: 27bd0028 addiu r29,r29,0x0028
8018ed74: 03e00008 jr r31
8018ed78: 00000000 nop