Find Action Highest Order Status Effect

From Final Fantasy Hacktics Wiki
Revision as of 12:25, 23 September 2016 by Glain (talk | contribs) (→‎Return Locations)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: FIND ACTION HIGHEST ORDER STATUS EFFECT
#       This routine finds the status effect with the highest order amongst status effects being inflicted or removed by the specified action and returns a corresponding [Find Result].
#       Parameters: 
#           r4 = Action
#       Returns:
#           r2 = [Find result]
#                   Flags:
#                       0x100: Status effect's Checks 2 0x08 flag was set
#                       0x080: Status is being removed, not inflicted
#                   Numeric:
#                       0x000 - 0x07f: [Status effect index] + 1
#                           (Zero if no status effect found)

0005e4e8: 240affff addiu r10,r0,-0x0001                     #   [Highest status effect order] = -1
0005e4ec: 00003021 addu r6,r0,r0                            #   result = 0
0005e4f0: 00002821 addu r5,r0,r0                            #   [Status effect index] = 0
0005e4f4: 340c0080 ori r12,r0,0x0080                        
0005e4f8: 3c088006 lui r8,0x8006
0005e4fc: 25085de6 addiu r8,r8,0x5de6                       #   [Status effect order pointer] = Base pointer for status effect order
0005e500: 00003821 addu r7,r0,r0                            #   [Status effect offset] = 0
                                                            #   do {
0005e504: 04a10002 bgez r5,0x0005e510
0005e508: 00a01021 addu r2,r5,r0                            #       [Status effect index]
                                                            #       if ([Status effect index] < 0) {
0005e50c: 24a20007 addiu r2,r5,0x0007                       #           [Status effect index] + 7 (Change rounding for negative number)
                                                            #       }
0005e510: 000248c3 sra r9,r2,0x03                           #       [Current status effect byte index] = [Status effect index] div 8 (Integer division)
0005e514: 30a20007 andi r2,r5,0x0007                        #       
0005e518: 004c1007 srav r2,r12,r2                           #       [Current status flag] = 0x80 >> ([Status effect index] mod 8)
0005e51c: 00891821 addu r3,r4,r9                            #       
0005e520: 90630020 lbu r3,0x0020(r3)                        #       [Action's Remove Status byte for current status]
0005e524: 00000000 nop
0005e528: 00621824 and r3,r3,r2                             #       Check if current status is being removed by the action
0005e52c: 1060000f beq r3,r0,0x0005e56c                     
0005e530: 00405821 addu r11,r2,r0                           #       [Current status flag]
                                                            #       if (Current status is being removed) {
0005e534: 91030000 lbu r3,0x0000(r8)                        #           [Status effect order]
0005e538: 00000000 nop
0005e53c: 0143102a slt r2,r10,r3                            
0005e540: 1040000b beq r2,r0,0x0005e570
0005e544: 00891021 addu r2,r4,r9                            
                                                            #           if ([Highest status effect order] < [Status effect order]) {
0005e548: 00605021 addu r10,r3,r0                           #               [Highest status effect order] = [Status effect order]
0005e54c: 3c018006 lui r1,0x8006
0005e550: 00270821 addu r1,r1,r7
0005e554: 90225de9 lbu r2,0x5de9(r1)                        #               [Current status effect Checks 2 flags]
0005e558: 00000000 nop
0005e55c: 30420008 andi r2,r2,0x0008                        #               Check for 0x08 flag on Checks 2 flags
0005e560: 10400002 beq r2,r0,0x0005e56c                     
0005e564: 24a60081 addiu r6,r5,0x0081                       #               result = [Status effect index] + 0x81
                                                            #               if (Checks 2 flags includes 0x08 flag) {
0005e568: 24a60181 addiu r6,r5,0x0181                       #                   result = [Status effect index] + 0x181
                                                            #               }
                                                            #           }
0005e56c: 00891021 addu r2,r4,r9                            #           
                                                            #       }
0005e570: 9042001b lbu r2,0x001b(r2)                        #       [Action's Inflict Status byte for current status]
0005e574: 00000000 nop
0005e578: 01621024 and r2,r11,r2                            #       Check if current status is being inflicted by the action
0005e57c: 1040000f beq r2,r0,0x0005e5bc                     #       if (Current status is being inflicted) {
0005e580: 00000000 nop
0005e584: 91030000 lbu r3,0x0000(r8)                        #           [Status effect order]
0005e588: 00000000 nop
0005e58c: 0143102a slt r2,r10,r3
0005e590: 1040000a beq r2,r0,0x0005e5bc                     #           if ([Highest status effect order] < [Status effect order]) {
0005e594: 00000000 nop
0005e598: 00605021 addu r10,r3,r0                           #               [Highest status effect order] = [Status effect order]
0005e59c: 3c018006 lui r1,0x8006
0005e5a0: 00270821 addu r1,r1,r7
0005e5a4: 90225de9 lbu r2,0x5de9(r1)                        #               [Current status effect Checks 2 flags]
0005e5a8: 00000000 nop
0005e5ac: 30420008 andi r2,r2,0x0008                        #               Check for 0x08 flag on Checks 2 flags
0005e5b0: 10400002 beq r2,r0,0x0005e5bc                     
0005e5b4: 24a60001 addiu r6,r5,0x0001                       #               result = [Status effect index] + 1
                                                            #               if (Checks 2 flags includes 0x08 flag) {
0005e5b8: 24a60101 addiu r6,r5,0x0101                       #                   result = [Status effect index] + 0x101
                                                            #               }
                                                            #           }
                                                            #       }
0005e5bc: 25080010 addiu r8,r8,0x0010                       #       [Status effect order pointer] = [Next status effect order pointer] (Status effect order pointer + sizeof(Status effect data))
0005e5c0: 24a50001 addiu r5,r5,0x0001                       #       [Status effect index] = [Status effect index] + 1
0005e5c4: 28a20028 slti r2,r5,0x0028
0005e5c8: 1440ffce bne r2,r0,0x0005e504
0005e5cc: 24e70010 addiu r7,r7,0x0010                       #       [Status effect offset] = [Next status effect offset] (Status effect offset + sizeof(Status effect data))
                                                            #   } while ([Status effect index] < 40)
0005e5d0: 03e00008 jr r31                                   #   return result (see [Find Result] definition at top)
0005e5d4: 00c01021 addu r2,r6,r0


Call Locations

00134de8: Display Projected Action Effect (Through call to Call Inner Subroutine)
00135148: Display Projected Action Effect (Through call to Call Inner Subroutine)