Get Ability ID From Skillset

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: Get Ability ID From Skillset          DUPLICATED : Load_Ability_From_Skillset
#       Parameters:
#           r4 = (skillsetID)       Skillset ID
#           r5 = (abilityIndex)     Ability index within the specified skillset
#       Returns:
#           r2 = Ability ID at slot (abilityIndex) of skillset with ID (skillsetID)

8005a568: 288200b0 slti r2,r4,0x00b0                
8005a56c: 10400017 beq r2,r0,0x8005a5cc
8005a570: 28a20016 slti r2,r5,0x0016
                                                    #   if (skillsetID < 0xB0)  {               // If this is NOT a monster skillset
8005a574: 1040002d beq r2,r0,0x8005a62c             #       if (skillsetID == 0) return 0;      // Skillset 0 only contains Attack
8005a578: 00a03021 addu r6,r5,r0                    #       abilityIndex
8005a57c: 3c038006 lui r3,0x8006
8005a580: 24634a94 addiu r3,r3,0x4a94               #       skillsets
8005a584: 00041040 sll r2,r4,0x01
8005a588: 00441021 addu r2,r2,r4
8005a58c: 000210c0 sll r2,r2,0x03
8005a590: 00441021 addu r2,r2,r4
8005a594: 04a10002 bgez r5,0x8005a5a0
8005a598: 00432021 addu r4,r2,r3                    #       skillsets[skillsetID]
8005a59c: 24a60007 addiu r6,r5,0x0007
8005a5a0: 000618c3 sra r3,r6,0x03                   #       abilityFlagsIndex = abilityIndex / 8
8005a5a4: 00831021 addu r2,r4,r3                    #       &skillsets[skillsetID].flags[abilityFlagsIndex]
8005a5a8: 000318c0 sll r3,r3,0x03                   #       abilityIndex / 8 * 8
8005a5ac: 00a31823 subu r3,r5,r3                    #       abilityIndex % 8    (abilityIndex - (abilityIndex / 8 * 8))
8005a5b0: 90420000 lbu r2,0x0000(r2)                #       skillsets[skillsetID].flags[abilityFlagsIndex]
8005a5b4: 24630001 addiu r3,r3,0x0001               #       (abilityIndex % 8) + 1
8005a5b8: 00621004 sllv r2,r2,r3                    #       skillsets[skillsetID].flags[abilityFlagsIndex] << ((abilityIndex % 8) + 1)
8005a5bc: 00851821 addu r3,r4,r5
8005a5c0: 90630003 lbu r3,0x0003(r3)                #       abilityIDLowByte = skillsets[skillsetID].abilityIDLowBytes[abilityIndex]
8005a5c4: 08016989 j 0x8005a624
8005a5c8: 30420100 andi r2,r2,0x0100                #       abilityIDHighBit = (skillsets[skillsetID].flags[abilityFlagsIndex] << ((abilityIndex % 8) + 1)) & 0x100
                                                    #   } else {
8005a5cc: 288200e0 slti r2,r4,0x00e0                
8005a5d0: 10400016 beq r2,r0,0x8005a62c             #       if (skillsetID >= 0xE0) return 0;   //  Skillset ID exceeds maximum value
8005a5d4: 28a20004 slti r2,r5,0x0004
8005a5d8: 10400014 beq r2,r0,0x8005a62c             #       if (abilityIndex >= 4) return 0;
8005a5dc: 00a03021 addu r6,r5,r0                    #       abilityIndex
8005a5e0: 3c038006 lui r3,0x8006
8005a5e4: 24635854 addiu r3,r3,0x5854
8005a5e8: 00041080 sll r2,r4,0x02
8005a5ec: 00441021 addu r2,r2,r4
8005a5f0: 04a10002 bgez r5,0x8005a5fc
8005a5f4: 00432021 addu r4,r2,r3                    #       monsterSkillset = monsterSkillsets[skillsetID - 0xB0]
8005a5f8: 24a60007 addiu r6,r5,0x0007
8005a5fc: 000618c3 sra r3,r6,0x03                   #       abilityFlagsIndex = abilityIndex / 8
8005a600: 00831021 addu r2,r4,r3                    #       &monsterSkillset.flags[abilityFlagsIndex]
8005a604: 000318c0 sll r3,r3,0x03                   #       abilityIndex / 8 * 8
8005a608: 00a31823 subu r3,r5,r3                    #       abilityIndex % 8    (abilityIndex - (abilityIndex / 8 * 8))
8005a60c: 90420000 lbu r2,0x0000(r2)                #       monsterSkillset.flags[abilityFlagsIndex]
8005a610: 24630001 addiu r3,r3,0x0001               #       (abilityIndex % 8) + 1
8005a614: 00621004 sllv r2,r2,r3                    #       monsterSkillset.flags[abilityFlagsIndex] << ((abilityIndex % 8) + 1)
8005a618: 00851821 addu r3,r4,r5                    #       
8005a61c: 90630001 lbu r3,0x0001(r3)                #       abilityIDLowByte = monsterSkillset.abilityIDLowBytes[abilityIndex]
8005a620: 30420100 andi r2,r2,0x0100                #       abilityIDHighBit = (monsterSkillset.flags[abilityFlagsIndex] << ((abilityIndex % 8) + 1)) & 0x100
                                                    #   }
8005a624: 0801698c j 0x8005a630                     #   return abilityIDLowByte | abilityIDHighBit;
8005a628: 00621025 or r2,r3,r2
8005a62c: 00001021 addu r2,r0,r0
8005a630: 03e00008 jr r31
8005a634: 00000000 nop