Process Unit Staged Status Data

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: PROCESS UNIT STAGED STATUS DATA
#       Either applies staged status data to a unit, or updates the staged status data from the unit's own status. 
#       Also applies some other updates to unit status.
#
#       Parameters:
#           r4 = (UnitID) Unit ID (e.g. from an event)
#           r5 = (IsApplyingStagedData) Whether or not to apply the staged status data to the unit (1 = true, 0 = false)

80148cd8: 3c028017 lui r2,0x8017
80148cdc: 8c424048 lw r2,0x4048(r2)                 #   *0x80174048
80148ce0: 3c038016 lui r3,0x8016
80148ce4: 94635ff6 lhu r3,0x5ff6(r3)                #   *0x80165ff6
80148ce8: 27bdffd0 addiu r29,r29,-0x0030
80148cec: afb10024 sw r17,0x0024(r29)
80148cf0: afbf0028 sw r31,0x0028(r29)
80148cf4: afb00020 sw r16,0x0020(r29)
80148cf8: a7a40010 sh r4,0x0010(r29)                #   tempID = UnitID
80148cfc: 244205f0 addiu r2,r2,0x05f0               #   *0x80174048 + 0x5f0
80148d00: 3c018017 lui r1,0x8017
80148d04: ac223c78 sw r2,0x3c78(r1)                 #   *0x80173c78 = *0x80174048 + 0x5f0
80148d08: 14600059 bne r3,r0,0x80148e70             #   if (*0x80165ff6 != 0) return;
80148d0c: 00a08821 addu r17,r5,r0                   #   IsApplyingStagedData
80148d10: 27a40010 addiu r4,r29,0x0010
80148d14: 0c051e4a jal 0x80147928                   #   findMiscUnitResultCode = Try Get Unit Misc Data By Unit ID (&tempID, &findMiscUnitStateValue);
80148d18: 27a50014 addiu r5,r29,0x0014
80148d1c: 10400054 beq r2,r0,0x80148e70             #   if (findMiscUnitResultCode == 0) return;
80148d20: 00000000 nop
80148d24: 3c028017 lui r2,0x8017
80148d28: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148d2c: afa00018 sw r0,0x0018(r29)                #   tempUnitMiscID = 0
80148d30: a44003f0 sh r0,0x03f0(r2)                 #   *(*0x80173c78 + 0x3f0) = 0
                                                    #   do {
80148d34: 27a40010 addiu r4,r29,0x0010
80148d38: 27a50018 addiu r5,r29,0x0018
80148d3c: 0c051e6b jal 0x801479ac                   #       processResult = Process Unit Misc State Value (&tempID, &tempUnitMiscID, &findMiscUnitStateValue);
80148d40: 27a60014 addiu r6,r29,0x0014
80148d44: 10400027 beq r2,r0,0x80148de4             #       if (processResult != 0) {
80148d48: 00000000 nop
80148d4c: 97a40010 lhu r4,0x0010(r29)               #           unitMiscID = tempID
80148d50: 0c023374 jal 0x8008cdd0                   #           battleUnitIndex = Get Battle Unit Index By Unit Misc ID (tempID);
80148d54: 00000000 nop
80148d58: 00408021 addu r16,r2,r0                   #           battleUnitIndex
80148d5c: 2402ffff addiu r2,r0,-0x0001              #           -1
80148d60: 1202001c beq r16,r2,0x80148dd4            #           if (battleUnitIndex != -1) {
80148d64: 00000000 nop
80148d68: 0c0602bf jal 0x80180afc                   #               unit = Get Unit's Data Pointer (battleUnitIndex);
80148d6c: 02002021 addu r4,r16,r0
80148d70: 90440161 lbu r4,0x0161(r2)                #               unit.ENTD_ID 
80148d74: 0c060324 jal 0x80180c90                   #               entdUnit = Find Unit Data Pointer For ENTD Unit ID (unit.ENTD_ID, &resultCode);
80148d78: 27a5001c addiu r5,r29,0x001c             
80148d7c: 8fa2001c lw r2,0x001c(r29)                #               resultCode
80148d80: 00000000 nop
80148d84: 04400013 bltz r2,0x80148dd4               #               if (resultCode >= 0) {
80148d88: 3222ffff andi r2,r17,0xffff
80148d8c: 1440000e bne r2,r0,0x80148dc8             #                   if (IsApplyingStagedData == 0) {
80148d90: 00000000 nop
80148d94: 0c052160 jal 0x80148580                   #                       isUpdate = Update Unit Status And Staged Status Data (battleUnitIndex);
80148d98: 02002021 addu r4,r16,r0
80148d9c: 1040000d beq r2,r0,0x80148dd4             #                       if (isUpdate) {
80148da0: 00000000 nop
80148da4: 97a40010 lhu r4,0x0010(r29)               #                           unitMiscID
80148da8: 3c028009 lui r2,0x8009
80148dac: 2442bde4 addiu r2,r2,-0x421c              #                           0x8008bde4
80148db0: 3c018017 lui r1,0x8017
80148db4: ac223ca8 sw r2,0x3ca8(r1)                 #                           routine = 0x8008bde4 (Update Status/Sprite/Animation Display By Unit Misc ID (Wrapper Function))
80148db8: 0c0533ad jal 0x8014ceb4                   #                           Call Inner Subroutine (unitMiscID);
80148dbc: 00000000 nop
80148dc0: 08052375 j 0x80148dd4                     #                       }
80148dc4: 00000000 nop                              #                   } else {
80148dc8: 97a50010 lhu r5,0x0010(r29)
80148dcc: 0c05222a jal 0x801488a8                   #                       Apply Staged Status Data To Unit (battleUnitIndex, unitMiscID);
80148dd0: 02002021 addu r4,r16,r0
                                                    #                   }
                                                    #               }
                                                    #           }
80148dd4: 8fa20014 lw r2,0x0014(r29)                #           findMiscUnitStateValue
80148dd8: 00000000 nop
80148ddc: 10400008 beq r2,r0,0x80148e00             #           if (findMiscUnitStateValue == 0) break;
80148de0: 00000000 nop                              #       }
80148de4: 8fa20018 lw r2,0x0018(r29)                #       tempUnitMiscID
80148de8: 00000000 nop
80148dec: 24420001 addiu r2,r2,0x0001               #       tempUnitMiscID + 1
80148df0: afa20018 sw r2,0x0018(r29)                #       tempUnitMiscID = tempUnitMiscID + 1
80148df4: 28420015 slti r2,r2,0x0015
80148df8: 1440ffce bne r2,r0,0x80148d34             #   } while (tempUnitMiscID < 21);
80148dfc: 00000000 nop
80148e00: 3c028017 lui r2,0x8017
80148e04: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148e08: 00000000 nop
80148e0c: 944203f0 lhu r2,0x03f0(r2)                #   testValue = *(*0x80173c78 + 0x3f0)
80148e10: 00000000 nop
80148e14: 10400003 beq r2,r0,0x80148e24             #   if (testValue != 0) {
80148e18: 00000000 nop
80148e1c: 0c053216 jal 0x8014c858                   #       Wait (40);
80148e20: 34040028 ori r4,r0,0x0028
                                                    #   }
80148e24: 3c028017 lui r2,0x8017
80148e28: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148e2c: 00000000 nop
80148e30: 944203f0 lhu r2,0x03f0(r2)                #   testValue = *(*0x80173c78 + 0x3f0)
80148e34: 00000000 nop
80148e38: 30420001 andi r2,r2,0x0001                #   testValue = testValue % 2
80148e3c: 10400004 beq r2,r0,0x80148e50             #   if (testValue != 0) {
80148e40: 3222ffff andi r2,r17,0xffff
80148e44: 0c053216 jal 0x8014c858                   #       Wait (40);
80148e48: 34040028 ori r4,r0,0x0028
80148e4c: 3222ffff andi r2,r17,0xffff
                                                    #   }
80148e50: 14400007 bne r2,r0,0x80148e70             #   if (IsApplyingStagedData == 0) {
80148e54: 00000000 nop
80148e58: 3c028009 lui r2,0x8009
80148e5c: 2442d1c8 addiu r2,r2,-0x2e38              #       0x8008d1c8
80148e60: 3c018017 lui r1,0x8017
80148e64: ac223ca8 sw r2,0x3ca8(r1)                 #       routine = 0x8008d1c8 (Reset Jumping Unit Graphic Triggers)
80148e68: 0c0533ad jal 0x8014ceb4                   #       Call Inner Subroutine ();
80148e6c: 00000000 nop                              #   }
80148e70: 8fbf0028 lw r31,0x0028(r29)
80148e74: 8fb10024 lw r17,0x0024(r29)
80148e78: 8fb00020 lw r16,0x0020(r29)
80148e7c: 27bd0030 addiu r29,r29,0x0030
80148e80: 03e00008 jr r31
80148e84: 00000000 nop