Update Unit Status And Staged Status Data

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: UPDATE UNIT STATUS AND STAGED STATUS DATA
#       Updates unit staged status data (0x80173c78), removes Charm from the unit, and updates ENTD flags on the unit (from modified ENTD flags).
#       Skips updating if a certain flag on the staged status data is set.
#
#       Parameters:
#           r4 = (battleUnitIndex) Battle unit index
#       Returns:
#           r2 =    1, if update occurred (skip flag was not set)
#                   0, otherwise

80148580: 3c028017 lui r2,0x8017
80148584: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148588: 27bdffd8 addiu r29,r29,-0x0028
8014858c: afb3001c sw r19,0x001c(r29)
80148590: 00809821 addu r19,r4,r0                   #   battleUnitIndex
80148594: afbf0024 sw r31,0x0024(r29)
80148598: afb40020 sw r20,0x0020(r29)
8014859c: afb20018 sw r18,0x0018(r29)
801485a0: afb10014 sw r17,0x0014(r29)
801485a4: afb00010 sw r16,0x0010(r29)
801485a8: 00531021 addu r2,r2,r19                   #   *0x80173c78 + battleUnitIndex
801485ac: 9042039c lbu r2,0x039c(r2)                #   testValue = *(*0x80173c78 + battleUnitIndex + 0x39c)
801485b0: 00000000 nop
801485b4: 144000b3 bne r2,r0,0x80148884             #   if (testValue != 0)
801485b8: 00001021 addu r2,r0,r0                    #       return 0;
801485bc: 0c0602bf jal 0x80180afc                   #   battleUnit = Get Unit's Data Pointer (battleUnitIndex);
801485c0: 00008021 addu r16,r0,r0                   #   statusByteIndex = 0
801485c4: 00409021 addu r18,r2,r0                   #   battleUnit
801485c8: 00131080 sll r2,r19,0x02                  #   battleUnitIndex * 4
801485cc: 00532821 addu r5,r2,r19                   #   battleUnitIndex * 5
801485d0: 02502021 addu r4,r18,r16                  #   (battleUnit + statusByteIndex)
                                                    #   do {
801485d4: 3c028017 lui r2,0x8017
801485d8: 8c423c78 lw r2,0x3c78(r2)                 #       *0x80173c78
801485dc: 9083004e lbu r3,0x004e(r4)                #       battleUnit.innateStatus[statusByteIndex]
801485e0: 00a21021 addu r2,r5,r2                    #       *0x80173c78 + (battleUnitIndex * 5)
801485e4: 00501021 addu r2,r2,r16                   #       *0x80173c78 + (battleUnitIndex * 5) + statusByteIndex
801485e8: a0430000 sb r3,0x0000(r2)                 #       *(*0x80173c78 + (battleUnitIndex * 5) + statusByteIndex) = battleUnit.innateStatus[statusByteIndex]
801485ec: 3c028017 lui r2,0x8017
801485f0: 8c423c78 lw r2,0x3c78(r2)                 #       *0x80173c78
801485f4: 908301bb lbu r3,0x01bb(r4)                #       battleUnit.inflictedStatus[statusByteIndex]
801485f8: 00a21021 addu r2,r5,r2                    #       *0x80173c78 + (battleUnitIndex * 5)
801485fc: 244200d2 addiu r2,r2,0x00d2               #       *0x80173c78 + (battleUnitIndex * 5) + 0xd2
80148600: 00501021 addu r2,r2,r16                   #       *0x80173c78 + (battleUnitIndex * 5) + 0xd2 + statusByteIndex
80148604: a0430000 sb r3,0x0000(r2)                 #       *(*0x80173c78 + (battleUnitIndex * 5) + 0xd2 + statusByteIndex) = battleUnit.inflictedStatus[statusByteIndex]
80148608: 3c028017 lui r2,0x8017
8014860c: 8c423c78 lw r2,0x3c78(r2)                 #       *0x80173c78
80148610: 90830058 lbu r3,0x0058(r4)                #       battleUnit.currentStatus[statusByteIndex]
80148614: 00a21021 addu r2,r5,r2                    #       *0x80173c78 + (battleUnitIndex * 5)
80148618: 24420069 addiu r2,r2,0x0069               #       *0x80173c78 + (battleUnitIndex * 5) + 0x69
8014861c: 00501021 addu r2,r2,r16                   #       *0x80173c78 + (battleUnitIndex * 5) + 0x69 + statusByteIndex
80148620: 26100001 addiu r16,r16,0x0001             #       statusByteIndex = statusByteIndex + 1
80148624: a0430000 sb r3,0x0000(r2)                 #       *(*0x80173c78 + (battleUnitIndex * 5) + 0x69 + statusByteIndex) = battleUnit.currentStatus[statusByteIndex]
80148628: 2a020005 slti r2,r16,0x0005
8014862c: 1440ffe9 bne r2,r0,0x801485d4
80148630: 02502021 addu r4,r18,r16                  #       (battleUnit + statusByteIndex)
                                                    #   } while (statusByteIndex < 5);
80148634: 00008021 addu r16,r0,r0                   #   statusCTIndex = 0
80148638: 00132100 sll r4,r19,0x04                  #   battleUnitIndex * 16
8014863c: 02501821 addu r3,r18,r16                  #   (battleUnit + statusCTIndex)
                                                    #   do {
80148640: 3c028017 lui r2,0x8017
80148644: 8c423c78 lw r2,0x3c78(r2)                 #       *0x80173c78
80148648: 9063005d lbu r3,0x005d(r3)                #       battleUnit.statusCT[statusCTIndex]
8014864c: 00821021 addu r2,r4,r2                    #       *0x80173c78 + (battleUnit + statusCTIndex)
80148650: 2442020d addiu r2,r2,0x020d               #       *0x80173c78 + (battleUnit + statusCTIndex) + 0x20d
80148654: 00501021 addu r2,r2,r16                   #       *0x80173c78 + (battleUnit + statusCTIndex) + 0x20d + statusCTIndex
80148658: 26100001 addiu r16,r16,0x0001             #       statusCTIndex = statusCTIndex + 1
8014865c: a0430000 sb r3,0x0000(r2)                 #       *(*0x80173c78 + (battleUnit + statusCTIndex) + 0x20d + statusCTIndex) = battleUnit.statusCT[statusCTIndex]
80148660: 2a020010 slti r2,r16,0x0010
80148664: 1440fff6 bne r2,r0,0x80148640
80148668: 02501821 addu r3,r18,r16                  #       (battleUnit + statusCTIndex)
                                                    #   } while (statusCTIndex < 16);
8014866c: 00008021 addu r16,r0,r0                   #   statusByteIndex = 0
80148670: 00131080 sll r2,r19,0x02                  #   battleUnitIndex * 4
80148674: 0053a021 addu r20,r2,r19                  #   battleUnitIndex * 5
80148678: 02408821 addu r17,r18,r0                  #   (battleUnitValuePtr = battleUnit)
8014867c: 3c028017 lui r2,0x8017
80148680: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148684: 9243015d lbu r3,0x015d(r18)               #   abilityCT
80148688: 00531021 addu r2,r2,r19                   #   *0x80173c78 + battleUnitIndex
8014868c: a043035d sb r3,0x035d(r2)                 #   *(*0x80173c78 + battleUnitIndex) + 0x35d) = abilityCT
80148690: 3c028017 lui r2,0x8017
80148694: 8c423c78 lw r2,0x3c78(r2)                 #   *0x80173c78
80148698: 92430007 lbu r3,0x0007(r18)               #   battleUnit.deathCounter
8014869c: 00531021 addu r2,r2,r19                   #   *0x80173c78 + battleUnitIndex  
801486a0: a0430372 sb r3,0x0372(r2)                 #   *(*0x80173c78 + battleUnitIndex + 0x372) = battleUnit.deathCounter
801486a4: 00131040 sll r2,r19,0x01                  #   battleUnitIndex * 2
801486a8: 3c038017 lui r3,0x8017
801486ac: 8c633c78 lw r3,0x3c78(r3)                 #   *0x80173c78
801486b0: 96440028 lhu r4,0x0028(r18)               #   battleUnit.HP
801486b4: 00431021 addu r2,r2,r3                    #   *0x80173c78 + (battleUnitIndex * 2)
801486b8: a44403c6 sh r4,0x03c6(r2)                 #   *(*0x80173c78 + (battleUnitIndex * 2) + 0x3c6) = battleUnit.HP
801486bc: 92420005 lbu r2,0x0005(r18)               #   battleUnit.ENTDFlags
801486c0: 00731821 addu r3,r3,r19                   #   *0x80173c78 + battleUnitIndex
801486c4: a0620387 sb r2,0x0387(r3)                 #   *(*0x80173c78 + battleUnitIndex + 0x387) = battleUnit.ENTDFlags
                                                    #   do {
801486c8: 0c04ed64 jal 0x8013b590                   #       isInitialization = Get Script Variable (0x1fd);
801486cc: 340401fd ori r4,r0,0x01fd
801486d0: 1040002a beq r2,r0,0x8014877c             #       if (isInitialization) {
801486d4: 00000000 nop
801486d8: 92420012 lbu r2,0x0012(r18)               #           battleUnit.primarySkillset
801486dc: 00000000 nop
801486e0: 24420050 addiu r2,r2,0x0050               #           battleUnit.primarySkillset + 0x50
801486e4: 304200ff andi r2,r2,0x00ff                
801486e8: 2c420030 sltiu r2,r2,0x0030               
801486ec: 14400017 bne r2,r0,0x8014874c             #           if ((battleUnit.primarySkillset + 0x50 < 0x30)      //  Between 0x50 and 0x79 (Boss skillsets?)
801486f0: 34020041 ori r2,r0,0x0041
801486f4: 92430000 lbu r3,0x0000(r18)
801486f8: 00000000 nop
801486fc: 10620013 beq r3,r2,0x8014874c             #               or (battleUnit.baseClass == 0x41)               //  Holy Angel
80148700: 34020049 ori r2,r0,0x0049
80148704: 10620011 beq r3,r2,0x8014874c             #               or (battleUnit.baseClass == 0x49)               //  Arch Angel
80148708: 3402003d ori r2,r0,0x003d
8014870c: 92430003 lbu r3,0x0003(r18)
80148710: 00000000 nop
80148714: 1062000d beq r3,r2,0x8014874c             #               or (battleUnit.jobID == 0x3d)                   //  Undead Knight
80148718: 3402003f ori r2,r0,0x003f
8014871c: 1062000b beq r3,r2,0x8014874c             #               or (battleUnit.jobID == 0x3f)                   //  Undead Archer
80148720: 34020042 ori r2,r0,0x0042
80148724: 10620009 beq r3,r2,0x8014874c             #               or (battleUnit.jobID == 0x42)                   //  Undead Wizard
80148728: 34020044 ori r2,r0,0x0044
8014872c: 10620007 beq r3,r2,0x8014874c             #               or (battleUnit.jobID == 0x44)                   //  Undead Time Mage
80148730: 00000000 nop
80148734: 92420003 lbu r2,0x0003(r18)
80148738: 00000000 nop
8014873c: 2442ffba addiu r2,r2,-0x0046
80148740: 2c420002 sltiu r2,r2,0x0002
80148744: 10400007 beq r2,r0,0x80148764             #               or ((battleUnit.jobID - 0x46) < 2)              //  Undead Oracle or Undead Summoner
80148748: 00000000 nop                              #           )
                                                    #           {
8014874c: 92240058 lbu r4,0x0058(r17)               #               statusByteValue = battleUnit.currentStatus[statusByteIndex]
80148750: 3c018017 lui r1,0x8017
80148754: 00300821 addu r1,r1,r16
80148758: 90229768 lbu r2,-0x6898(r1)               #               statusMask = *(0x80169768 + statusByteIndex)
8014875c: 080521e3 j 0x8014878c
80148760: 00000000 nop                              #           } else {
80148764: 92240058 lbu r4,0x0058(r17)               #               statusByteValue = battleUnit.currentStatus[statusByteIndex]
80148768: 3c018017 lui r1,0x8017
8014876c: 00300821 addu r1,r1,r16
80148770: 90229760 lbu r2,-0x68a0(r1)               #               statusMask = *(0x80169760 + statusByteIndex)
80148774: 080521e3 j 0x8014878c
80148778: 00000000 nop                              
                                                    #           }
                                                    #       } else {
8014877c: 92240058 lbu r4,0x0058(r17)               #           statusByteValue = battleUnit.currentStatus[statusByteIndex]
80148780: 3c018017 lui r1,0x8017
80148784: 00300821 addu r1,r1,r16
80148788: 90229758 lbu r2,-0x68a8(r1)               #           statusMask = *(0x80169758 + statusByteIndex)
                                                    #       }
8014878c: 3c038017 lui r3,0x8017
80148790: 8c633c78 lw r3,0x3c78(r3)                 #       *0x80173c78
80148794: 00822024 and r4,r4,r2                     #       statusByte = statusByteValue & statusMask
80148798: 02831821 addu r3,r20,r3                   #       *0x80173c78 + (battleUnitIndex * 5)
8014879c: 246201a4 addiu r2,r3,0x01a4               #       *0x80173c78 + (battleUnitIndex * 5) + 0x1a4
801487a0: 00501021 addu r2,r2,r16                   #       *0x80173c78 + (battleUnitIndex * 5) + 0x1a4 + statusByteIndex
801487a4: 2463013b addiu r3,r3,0x013b               #       *0x80173c78 + (battleUnitIndex * 5) + 0x13b
801487a8: 00701821 addu r3,r3,r16                   #       *0x80173c78 + (battleUnitIndex * 5) + 0x13b + statusByteIndex
801487ac: a22401ac sb r4,0x01ac(r17)                #       battleUnit.statusRemoval[statusByteIndex] = statusByte
801487b0: a0440000 sb r4,0x0000(r2)                 #       *(*0x80173c78 + (battleUnitIndex * 5) + 0x1a4 + statusByteIndex) = statusByte
801487b4: a0640000 sb r4,0x0000(r3)                 #       *(*0x80173c78 + (battleUnitIndex * 5) + 0x13b + statusByteIndex) = statusByte
801487b8: 26100001 addiu r16,r16,0x0001             #       statusByteIndex = statusByteIndex + 1
801487bc: 2a020005 slti r2,r16,0x0005
801487c0: 1440ffc1 bne r2,r0,0x801486c8
801487c4: 26310001 addiu r17,r17,0x0001             #       (battleUnitValuePtr = battleUnitValuePtr + 1)
                                                    #   } while (statusByteIndex < 5);
801487c8: 00131080 sll r2,r19,0x02                  #   battleUnitIndex * 4
801487cc: 3c038017 lui r3,0x8017
801487d0: 8c633c78 lw r3,0x3c78(r3)                 #   *0x80173c78
801487d4: 00532021 addu r4,r2,r19                   #   battleUnitIndex * 5
801487d8: 00641021 addu r2,r3,r4                    #   *0x80173c78 + (battleUnitIndex * 5)
801487dc: 9042013b lbu r2,0x013b(r2)                #   *(*0x80173c78 + (battleUnitIndex * 5) + 0x13b)
801487e0: 00000000 nop
801487e4: 30420004 andi r2,r2,0x0004                #   *(*0x80173c78 + (battleUnitIndex * 5) + 0x13b) & 0x04
801487e8: 10400009 beq r2,r0,0x80148810
801487ec: 00641021 addu r2,r3,r4                    #   *0x80173c78 + (battleUnitIndex * 5)
                                                    #    do {
801487f0: 946203f0 lhu r2,0x03f0(r3)                #       *(0x80173c78 + 0x3f0)
801487f4: 00000000 nop
801487f8: 34420001 ori r2,r2,0x0001                 #       *(0x80173c78 + 0x3f0) + 1
801487fc: a46203f0 sh r2,0x03f0(r3)                 #       *(0x80173c78 + 0x3f0) = *(0x80173c78 + 0x3f0) + 1
80148800: 3c038017 lui r3,0x8017
80148804: 8c633c78 lw r3,0x3c78(r3)                 #       *0x80173c78
80148808: 00000000 nop
8014880c: 00641021 addu r2,r3,r4                    #       *0x80173c78 + (battleUnitIndex * 5)
                                                    #   }
80148810: 9042013d lbu r2,0x013d(r2)                #   value = *(*0x80173c78 + (battleUnitIndex * 5) + 0x13d)
80148814: 00000000 nop
80148818: 30420040 andi r2,r2,0x0040                #   value & 0x40
8014881c: 10400005 beq r2,r0,0x80148834             #   if (value & 0x40) {
80148820: 00000000 nop
80148824: 946203f0 lhu r2,0x03f0(r3)                #       *(0x80173c78 + 0x3f0)
80148828: 00000000 nop
8014882c: 34420002 ori r2,r2,0x0002                 #       *(0x80173c78 + 0x3f0) | 0x02
80148830: a46203f0 sh r2,0x03f0(r3)                 #       *(0x80173c78 + 0x3f0) = *(0x80173c78 + 0x3f0) | 0x02
                                                    #   }
80148834: 924201b0 lbu r2,0x01b0(r18)               #   battleUnit.actionStatusRemoval[4]     // 5th set
80148838: 00000000 nop
8014883c: 30420020 andi r2,r2,0x0020                #   battleUnit.actionStatusRemoval[4] & STATUS_CHARM
80148840: 10400004 beq r2,r0,0x80148854             #   if (battleUnit.actionStatusRemoval[4] & STATUS_CHARM) {
80148844: 00000000 nop
80148848: 924201ba lbu r2,0x01ba(r18)               #       battleUnit.modifiedENTDFlags
8014884c: 00000000 nop
80148850: a2420005 sb r2,0x0005(r18)                #       battleUnit.ENTDFlags = battleUnit.modifiedENTDFlags
                                                    #   }
80148854: 3c028019 lui r2,0x8019
80148858: 2442ec44 addiu r2,r2,-0x13bc              #   0x8018ec44
8014885c: 3c018017 lui r1,0x8017
80148860: ac223ca8 sw r2,0x3ca8(r1)                 #   routine = 0x8018ec44 (Apply Unit Action Status Removal)
80148864: 0c0533ad jal 0x8014ceb4                   #   Call Inner Subroutine (battleUnit);
80148868: 02402021 addu r4,r18,r0
8014886c: 34020001 ori r2,r0,0x0001                 #   result = 1
80148870: 3c038017 lui r3,0x8017
80148874: 8c633c78 lw r3,0x3c78(r3)                 #   *0x80173c78
80148878: 34040001 ori r4,r0,0x0001                 #   1
8014887c: 00731821 addu r3,r3,r19                   #   *0x80173c78 + battleUnitIndex
80148880: a064039c sb r4,0x039c(r3)                 #   *(*0x80173c78 + battleUnitIndex + 0x39c) = 1
80148884: 8fbf0024 lw r31,0x0024(r29)               #   return result;
80148888: 8fb40020 lw r20,0x0020(r29)
8014888c: 8fb3001c lw r19,0x001c(r29)
80148890: 8fb20018 lw r18,0x0018(r29)
80148894: 8fb10014 lw r17,0x0014(r29)
80148898: 8fb00010 lw r16,0x0010(r29)
8014889c: 27bd0028 addiu r29,r29,0x0028
801488a0: 03e00008 jr r31
801488a4: 00000000 nop