Get known skillsets

From Final Fantasy Hacktics Wiki
Revision as of 16:49, 7 December 2024 by Glain (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
#   ROUTINE: GET KNOWN SKILLSETS
#       Gets the skillsets known by the specified formation unit.
#       Parameters:
#           r4 = (formationUnitIndex) Formation unit index
#           r5 = (outputArray) Array to write result into
#       Returns:
#           r2 = Number of skillsets

80122790: 27bdffa8 addiu r29,r29,-0x0058
80122794: 00801021 addu r2,r4,r0                    #   formationUnitIndex
80122798: afb40050 sw r20,0x0050(r29)
8012279c: 00a0a021 addu r20,r5,r0                   #   outputArray
801227a0: 304400ff andi r4,r2,0x00ff                #   formationUnitIndex
801227a4: afb20048 sw r18,0x0048(r29)
801227a8: 00009021 addu r18,r0,r0                   #   jobWheelIndex = 0
801227ac: 00021400 sll r2,r2,0x10
801227b0: 00021383 sra r2,r2,0x0e                   #   formationUnitIndex * 4
801227b4: 27a50010 addiu r5,r29,0x0010              #   jobWheelOutputArray
801227b8: afbf0054 sw r31,0x0054(r29)
801227bc: afb3004c sw r19,0x004c(r29)
801227c0: afb10044 sw r17,0x0044(r29)
801227c4: afb00040 sw r16,0x0040(r29)
801227c8: 3c01801d lui r1,0x801d
801227cc: 00220821 addu r1,r1,r2
801227d0: 8c22d5ec lw r2,-0x2a14(r1)                #   formationUnit = *formationUnits[formationUnitIndex]
801227d4: 00000000 nop
801227d8: 94500024 lhu r16,0x0024(r2)               #   formationUnit.jobID
801227dc: 0c04895f jal 0x8012257c                   #   Calculate Job Wheel Jobs (formationUnitIndex, jobWheelOutputArray, 1);
801227e0: 34060001 ori r6,r0,0x0001
801227e4: 87a30010 lh r3,0x0010(r29)                #   jobWheelOutputArray[0]
801227e8: 2402ffff addiu r2,r0,-0x0001
801227ec: 10620017 beq r3,r2,0x8012284c             #   if (jobWheelOutputArray[0] != -1) {         // There is at least one job
801227f0: 27a40010 addiu r4,r29,0x0010              #       jobWheelOutputArray
801227f4: 00101400 sll r2,r16,0x10
801227f8: 00029c03 sra r19,r2,0x10                  #       formationUnit.jobID
801227fc: 00008021 addu r16,r0,r0                   #       jobWheelPtrOffset = 0
80122800: 02808821 addu r17,r20,r0                  #       outputArrayPtr = outputArray
80122804: 02041021 addu r2,r16,r4                   #       jobWheelPtr = jobWheelPtrOffset + jobWheelOutputArray
                                                    #       do {
80122808: 84440000 lh r4,0x0000(r2)                 #           jobWheelJobID = *jobWheelPtr
8012280c: 00000000 nop
80122810: 12640008 beq r19,r4,0x80122834
80122814: 26100002 addiu r16,r16,0x0002             #           jobWheelPtrOffset = jobWheelPtrOffset + 2
                                                    #           if ((formationUnit.jobID != jobWheelJobID) 
80122818: 3402005d ori r2,r0,0x005d
8012281c: 10820005 beq r4,r2,0x80122834             #               and (jobWheelJobID != JOB_ID_MIME))
80122820: 00000000 nop                              #           {
80122824: 0c0489db jal 0x8012276c                   #               skillsetID = Get job's skillset (jobWheelJobID);
80122828: 26520001 addiu r18,r18,0x0001             #               jobWheelIndex = jobWheelIndex + 1
8012282c: a6220000 sh r2,0x0000(r17)                #               *outputArrayPtr = skillsetID            
80122830: 26310002 addiu r17,r17,0x0002             #               outputArrayPtr = outputArrayPtr + 2
                                                    #           }
80122834: 27a40010 addiu r4,r29,0x0010              #           jobWheelOutputArray
80122838: 02041021 addu r2,r16,r4                   #           jobWheelPtr = jobWheelPtrOffset + jobWheelOutputArray
8012283c: 84430000 lh r3,0x0000(r2)                 #           jobWheelJobID = *jobWheelPtr
80122840: 2402ffff addiu r2,r0,-0x0001
80122844: 1462fff0 bne r3,r2,0x80122808
80122848: 02041021 addu r2,r16,r4                   #           jobWheelPtr = jobWheelPtrOffset + jobWheelOutputArray
                                                    #       } while (jobWheelJobID != -1);
                                                    #   }
8012284c: 00121040 sll r2,r18,0x01                  #   jobWheelIndex * 2
80122850: 00541021 addu r2,r2,r20                   #   outputArray
80122854: 2403ffff addiu r3,r0,-0x0001
80122858: a4430000 sh r3,0x0000(r2)                 #   outputArray[jobWheelIndex * 2] = -1     // Sentinel value
8012285c: 02401021 addu r2,r18,r0                   #   return jobWheelIndex;                   // Equal to number of skillsets in list
80122860: 8fbf0054 lw r31,0x0054(r29)
80122864: 8fb40050 lw r20,0x0050(r29)
80122868: 8fb3004c lw r19,0x004c(r29)
8012286c: 8fb20048 lw r18,0x0048(r29)
80122870: 8fb10044 lw r17,0x0044(r29)
80122874: 8fb00040 lw r16,0x0040(r29)
80122878: 27bd0058 addiu r29,r29,0x0058
8012287c: 03e00008 jr r31
80122880: 00000000 nop