Set Animation Based On Unit Status

From Final Fantasy Hacktics Wiki
Revision as of 04:36, 17 January 2024 by Talcall (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: SET ANIMATION BASED ON UNIT STATUS
#       Parameters:
#           r4 = (miscUnit) Unit misc data pointer

80082eec: 27bdffe0 addiu r29,r29,-0x0020
80082ef0: afb10014 sw r17,0x0014(r29)
80082ef4: 00808821 addu r17,r4,r0                   #   miscUnit
80082ef8: afbf0018 sw r31,0x0018(r29)
80082efc: 0c0209e3 jal 0x8008278c                   #   result = Movement validation - float/fly? (miscUnit);
80082f00: afb00010 sw r16,0x0010(r29)
80082f04: 304200ff andi r2,r2,0x00ff                #   result = result & 0xff
80082f08: 0440007f bltz r2,0x80083108
80082f0c: 00008021 addu r16,r0,r0                   #   value = 0
                                                    #   if ((result >= 0)          
80082f10: 28420002 slti r2,r2,0x0002
80082f14: 1040007c beq r2,r0,0x80083108             #       and (result < 2))                                        // if unit is flying, submerged with swim, or crystallised, branch
80082f18: 00000000 nop                              #   {
80082f1c: 8e230144 lw r3,0x0144(r17)                #       miscUnit.statusFlagsWord2
80082f20: 00000000 nop
80082f24: 30620001 andi r2,r3,0x0001                #       miscUnit.statusFlagsWord2 & STATUS_MISC_CRYSTAL
80082f28: 14400097 bne r2,r0,0x80083188             #       if (miscUnit.statusFlagsWord2 & STATUS_MISC_CRYSTAL) value = 9;                                // If crystal, use animation 0x12 & 13
80082f2c: 30620008 andi r2,r3,0x0008
80082f30: 1440007e bne r2,r0,0x8008312c             #       else if (miscUnit.statusFlagsWord2 & STATUS_MISC_TREASURE) value = 21;                         // if treasure, use animation 0x2A & 2B
80082f34: 00000000 nop                              #       else {
80082f38: 8e230140 lw r3,0x0140(r17)                #           miscUnit.statusFlagsWord1                        // 1st 4 bytes of misc unit status flags
80082f3c: 00000000 nop
80082f40: 30623fff andi r2,r3,0x3fff                #           miscUnit.statusFlagsWord1 & 0x03ff               // (Masks off Reflect and Undead)
                                                    #           if (miscUnit.statusFlagsWord1 & 0x03ff) == 0) useHeight3 = true;
80082f44: 10400069 beq r2,r0,0x800830ec             #           else {
80082f48: 00000000 nop
80082f4c: 92220006 lbu r2,0x0006(r17)               #               miscUnit.spritesheetID
80082f50: 00000000 nop
80082f54: 00021080 sll r2,r2,0x02                   #               (miscUnit.spritesheetID * 4)
80082f58: 3c018009 lui r1,0x8009
80082f5c: 00220821 addu r1,r1,r2
80082f60: 90224749 lbu r2,0x4749(r1)                #               spritesheetData[miscUnit.spritesheetID].SEQ_ID
80082f64: 00000000 nop
80082f68: 2c420005 sltiu r2,r2,0x0005               
80082f6c: 1440001b bne r2,r0,0x80082fdc             #               if (spritesheetData[miscUnit.spritesheetID].SEQ_ID < 5) {                              // animations for all types except RUKA, ARUTE, KANZEN.
80082f70: 30620004 andi r2,r3,0x0004
80082f74: 14400076 bne r2,r0,0x80083150             #                   if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEAD) value = 26;
80082f78: 30620010 andi r2,r3,0x0010
80082f7c: 14400054 bne r2,r0,0x800830d0             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_STOP) value = 2;                  // animation 2 points to stopped animations.
80082f80: 30620040 andi r2,r3,0x0040
80082f84: 14400026 bne r2,r0,0x80083020             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_SLEEP) value = 36;
80082f88: 30620020 andi r2,r3,0x0020
80082f8c: 14400050 bne r2,r0,0x800830d0             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_PETRIFY) value = 2;
80082f90: 30620080 andi r2,r3,0x0080
80082f94: 14400028 bne r2,r0,0x80083038             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_CONFUSION) value = 37;
80082f98: 30620100 andi r2,r3,0x0100
80082f9c: 1440002c bne r2,r0,0x80083050             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_PERFORMING) useAbilityID = true;
80082fa0: 30620200 andi r2,r3,0x0200
80082fa4: 1440002a bne r2,r0,0x80083050             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_CHARGING) useAbilityID = true;
80082fa8: 30620400 andi r2,r3,0x0400
80082fac: 14400032 bne r2,r0,0x80083078             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEFENDING) value = 23;
80082fb0: 30620800 andi r2,r3,0x0800
80082fb4: 14400034 bne r2,r0,0x80083088             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_SLOW) useHeight1 = true;
80082fb8: 30621000 andi r2,r3,0x1000
80082fbc: 1440003b bne r2,r0,0x800830ac             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_HASTE) useHeight2 = true;
80082fc0: 30622000 andi r2,r3,0x2000
80082fc4: 14400042 bne r2,r0,0x800830d0             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_CURSED) value = 2;
80082fc8: 30620001 andi r2,r3,0x0001
80082fcc: 1440006f bne r2,r0,0x8008318c             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_BLANK) value = 33;
80082fd0: 34100021 ori r16,r0,0x0021
80082fd4: 08020c3b j 0x800830ec
80082fd8: 00000000 nop
                                                    #               } else {
80082fdc: 1440005c bne r2,r0,0x80083150             #                   if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEAD) value = 26;
80082fe0: 30620002 andi r2,r3,0x0002
80082fe4: 1440005e bne r2,r0,0x80083160             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_MOUNT) value = 34;
80082fe8: 30620008 andi r2,r3,0x0008
80082fec: 10400005 beq r2,r0,0x80083004             #                   else
                                                    #                       if ((miscUnit.statusFlagsWord1 & STATUS_MISC_CRITICAL)
80082ff0: 34020002 ori r2,r0,0x0002
80082ff4: 92230130 lbu r3,0x0130(r17)               #                           
80082ff8: 00000000 nop
80082ffc: 14620008 bne r3,r2,0x80083020             #                           and (miscUnit.mountRiderValue == 2))  // Unit is a mount
80083000: 00000000 nop                              #                               value = 36;
80083004: 8e230140 lw r3,0x0140(r17)
80083008: 00000000 nop
8008300c: 30620010 andi r2,r3,0x0010
80083010: 1440002f bne r2,r0,0x800830d0             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_STOP) value = 2;
80083014: 30620040 andi r2,r3,0x0040
80083018: 10400003 beq r2,r0,0x80083028             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_SLEEP) value = 36;
8008301c: 30620020 andi r2,r3,0x0020
80083020: 08020c63 j 0x8008318c
80083024: 34100024 ori r16,r0,0x0024
80083028: 14400029 bne r2,r0,0x800830d0             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_PETRIFY) value = 2;
8008302c: 30620080 andi r2,r3,0x0080
80083030: 10400003 beq r2,r0,0x80083040             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_CONFUSION) value = 37;
80083034: 30620100 andi r2,r3,0x0100
80083038: 08020c63 j 0x8008318c
8008303c: 34100025 ori r16,r0,0x0025
80083040: 14400003 bne r2,r0,0x80083050             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_PERFORMING) useAbilityID = true;                   
80083044: 30620200 andi r2,r3,0x0200
80083048: 10400009 beq r2,r0,0x80083070             #                   else if (miscUnit.statusFlagsWord1 & STATUS_MISC_CHARGING) moreStatusChecks = true;
8008304c: 30620400 andi r2,r3,0x0400
                                                    #               }
                                                    #           }
                                                    #           if (useAbilityID) {
80083050: 8e220134 lw r2,0x0134(r17)                #               battleUnit = miscUnit.battleUnit
80083054: 00000000 nop
80083058: 94420170 lhu r2,0x0170(r2)                #               battleUnit.lastAbilityUsedID
8008305c: 02202021 addu r4,r17,r0
80083060: 0c020ae0 jal 0x80082b80                   #               value = Set attack animation flags and facing 2 (miscUnit);
80083064: a6220138 sh r2,0x0138(r17)                #               miscUnit.usedAbilityID = battleUnit.lastAbilityUsedID
80083068: 08020c63 j 0x8008318c
8008306c: 00000000 nop                              #           }
                                                    #           if (moreStatusChecks) {
80083070: 10400003 beq r2,r0,0x80083080             #               if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEFENDING)
80083074: 30620800 andi r2,r3,0x0800
80083078: 08020c63 j 0x8008318c
8008307c: 34100017 ori r16,r0,0x0017                #                   value = 23
80083080: 10400008 beq r2,r0,0x800830a4             #               if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEFENDING) useHeight1 = true; else moreStatusChecks2 = true;
80083084: 30621000 andi r2,r3,0x1000
                                                    #           }
                                                    #           if (useHeight1) {
80083088: 92240006 lbu r4,0x0006(r17)
8008308c: 0c0206bc jal 0x80081af0                   #               height = Get Spritesheet Graphic Height (miscUnit.spritesheetID);
80083090: 34100008 ori r16,r0,0x0008                #               value = 8                     <-- value if unit sprite is flying (idle fly haste (for monsters))
80083094: 1440003d bne r2,r0,0x8008318c             #               if (height == 0)              // if unit is not flying
80083098: 00000000 nop
8008309c: 08020c63 j 0x8008318c
800830a0: 34100005 ori r16,r0,0x0005                #                   value = 5
                                                    #           }
                                                    #           if (moreStatusChecks2) {
800830a4: 10400008 beq r2,r0,0x800830c8             #               if (miscUnit.statusFlagsWord1 & STATUS_MISC_HASTE) useHeight2 = true; else moreStatusChecks3 = true;
800830a8: 30622000 andi r2,r3,0x2000
                                                    #           }
                                                    #           if (useHeight2) {
800830ac: 92240006 lbu r4,0x0006(r17)
800830b0: 0c0206bc jal 0x80081af0                   #               height = Get Spritesheet Graphic Height (miscUnit.spritesheetID);
800830b4: 34100007 ori r16,r0,0x0007                #               value = 7                     <-- value if unit sprite is flying (idle fly (for monsters))
800830b8: 14400034 bne r2,r0,0x8008318c             #               if (height == 0)               // if unit is not flying
800830bc: 00000000 nop
800830c0: 08020c63 j 0x8008318c
800830c4: 34100004 ori r16,r0,0x0004                #                   value = 4
                                                    #           }
                                                    #           if (moreStatusChecks3) {
800830c8: 10400003 beq r2,r0,0x800830d8             #               if (miscUnit.statusFlagsWord1 & STATUS_MISC_HASTE) {
800830cc: 00000000 nop
800830d0: 08020c63 j 0x8008318c
800830d4: 34100002 ori r16,r0,0x0002                #                   value = 2
                                                    #               } else {
800830d8: 8e220140 lw r2,0x0140(r17)                #                   miscUnit.statusFlagsWord1
800830dc: 00000000 nop
800830e0: 30420001 andi r2,r2,0x0001                #                   miscUnit.statusFlagsWord1 & STATUS_MISC_BLANK
800830e4: 14400029 bne r2,r0,0x8008318c             #                   if (miscUnit.statusFlagsWord1 & STATUS_MISC_BLANK) value = 33; else useHeight3 = true;
800830e8: 34100021 ori r16,r0,0x0021
                                                    #               }
                                                    #           }
                                                    #           if (useHeight3) {
800830ec: 92240006 lbu r4,0x0006(r17)
800830f0: 0c0206bc jal 0x80081af0                   #               height = Get Spritesheet Graphic Height (miscUnit.spritesheetID);
800830f4: 34100006 ori r16,r0,0x0006
800830f8: 14400024 bne r2,r0,0x8008318c             #               if (height != 0) value = 6; else value = 3;
800830fc: 00000000 nop
80083100: 08020c63 j 0x8008318c
80083104: 34100003 ori r16,r0,0x0003
                                                    #           }
                                                    #       }
                                                    #   } else { 
80083108: 8e230144 lw r3,0x0144(r17)                #       miscUnit.statusFlagsWord2                           // if unit sprite is flagged flying, or is submerged/crystalised
8008310c: 00000000 nop
80083110: 3062000f andi r2,r3,0x000f
80083114: 10400007 beq r2,r0,0x80083134             #       if (miscUnit.statusFlagsWord2 & 0x0f) {         // Charm, Silence, Death Sentence, Darkness
80083118: 30620001 andi r2,r3,0x0001
8008311c: 1440001a bne r2,r0,0x80083188             #           if (miscUnit.statusFlagsWord2 & STATUS_MISC_CHARM) value = 9;
80083120: 30620008 andi r2,r3,0x0008
80083124: 10400019 beq r2,r0,0x8008318c             #           else if (miscUnit.statusFlagsWord2 & STATUS_MISC_TREASURE)
80083128: 00000000 nop
8008312c: 08020c63 j 0x8008318c
80083130: 34100015 ori r16,r0,0x0015                #               value = 21;
                                                    #       } else {
80083134: 8e230140 lw r3,0x0140(r17)                #           miscUnit.statusFlagsWord1
80083138: 00000000 nop
8008313c: 30623fff andi r2,r3,0x3fff                #           miscUnit.statusFlagsWord1 & 0x03ff           // (Masks off Reflect and Undead)
80083140: 10400011 beq r2,r0,0x80083188             #           if ((miscUnit.statusFlagsWord1 & 0x03ff) == 0) value = 9;
80083144: 30620004 andi r2,r3,0x0004
80083148: 10400003 beq r2,r0,0x80083158             #           else if (miscUnit.statusFlagsWord1 & STATUS_MISC_DEAD)
8008314c: 30620002 andi r2,r3,0x0002
80083150: 08020c63 j 0x8008318c
80083154: 3410001a ori r16,r0,0x001a                #               value = 26;
80083158: 10400003 beq r2,r0,0x80083168             #           else if (miscUnit.statusFlagsWord1 & STATUS_MISC_MOUNT)
8008315c: 30621000 andi r2,r3,0x1000
80083160: 08020c63 j 0x8008318c
80083164: 34100032 ori r16,r0,0x0032                #               value = 50;
80083168: 10400003 beq r2,r0,0x80083178             #           else if (miscUnit.statusFlagsWord1 & STATUS_MISC_HASTE)
8008316c: 30620800 andi r2,r3,0x0800
80083170: 08020c63 j 0x8008318c
80083174: 3410000a ori r16,r0,0x000a                #               value = 10;
80083178: 10400004 beq r2,r0,0x8008318c             #           else if (miscUnit.statusFlagsWord1 & STATUS_MISC_SLOW)
8008317c: 34100009 ori r16,r0,0x0009
80083180: 08020c63 j 0x8008318c
80083184: 3410000b ori r16,r0,0x000b                #               value = 11;
80083188: 34100009 ori r16,r0,0x0009                #           else value = 9;            // covers hasted flying monster case (idle fly haste)
                                                    #       }
                                                    #   }
8008318c: 12000004 beq r16,r0,0x800831a0            #   if (value != 0) {
80083190: 02002021 addu r4,r16,r0
80083194: 86250070 lh r5,0x0070(r17)
80083198: 0c02065e jal 0x80081978                   #       Store unit animation and facing value (value, miscUnit.currentFacing, miscUnit);
8008319c: 02203021 addu r6,r17,r0
                                                    #   }
800831a0: 8fbf0018 lw r31,0x0018(r29)
800831a4: 8fb10014 lw r17,0x0014(r29)
800831a8: 8fb00010 lw r16,0x0010(r29)
800831ac: 27bd0020 addiu r29,r29,0x0020
800831b0: 03e00008 jr r31
800831b4: 00000000 nop