Calculate Job Wheel Jobs
Jump to navigation
Jump to search
# ROUTINE: CALCULATE JOB WHEEL JOBS # Determines which jobs are visible on the job wheel for the current unit? # Parameters: # r4 = (formationUnitIndex) Formation unit index # r5 = (outputArray) Array to output jobs into (Sometimes 0x801c83f8) # r6 = (optionValue) If equal to 2, disable current job, and show jobs unlocked by other units as disabled # Returns: # r2 = How many jobs are visible on the job wheel for the current unit # (Saved to *0x801c83f0 in routine 0x8011a378 (0x8011a3b0) when opening Change Job screen) 8012257c: 27bdffd0 addiu r29,r29,-0x0030 80122580: afb60028 sw r22,0x0028(r29) 80122584: 00a0b021 addu r22,r5,r0 # outputArray 80122588: afb50024 sw r21,0x0024(r29) 8012258c: 00c0a821 addu r21,r6,r0 # optionValue 80122590: afb10014 sw r17,0x0014(r29) 80122594: 00808821 addu r17,r4,r0 # formationUnitIndex 80122598: 322200ff andi r2,r17,0x00ff # formationUnitIndex 8012259c: 3c03801d lui r3,0x801d 801225a0: 2463d5ec addiu r3,r3,-0x2a14 # 0x801cd5ec 801225a4: 00021080 sll r2,r2,0x02 # formationUnitIndex * 4 801225a8: afb3001c sw r19,0x001c(r29) 801225ac: 00439821 addu r19,r2,r3 # &formationUnit = (formationUnitIndex * 4) + 0x801cd5ec 801225b0: afbf002c sw r31,0x002c(r29) 801225b4: afb40020 sw r20,0x0020(r29) 801225b8: afb20018 sw r18,0x0018(r29) 801225bc: afb00010 sw r16,0x0010(r29) 801225c0: 8e640000 lw r4,0x0000(r19) # formationUnit 801225c4: 00009021 addu r18,r0,r0 # jobIndex = 0 801225c8: 0c04ac6d jal 0x8012b1b4 # Store Combined Bit Value Pointer (&formationUnit.unlockedJobs1); 801225cc: 24840077 addiu r4,r4,0x0077 801225d0: 0c04890f jal 0x8012243c # baseJob = Get Base Job (Formation Screen) (formationUnitIndex); 801225d4: 322400ff andi r4,r17,0x00ff 801225d8: 00408021 addu r16,r2,r0 # jobOutputValue = baseJob 801225dc: 34020002 ori r2,r0,0x0002 801225e0: 16a20008 bne r21,r2,0x80122604 801225e4: 00121040 sll r2,r18,0x01 # if ((optionValue == 2) 801225e8: 8e620000 lw r2,0x0000(r19) 801225ec: 00000000 nop 801225f0: 84420024 lh r2,0x0024(r2) 801225f4: 00000000 nop 801225f8: 16020002 bne r16,r2,0x80122604 801225fc: 00121040 sll r2,r18,0x01 # and (baseJob == formationUnit.Job)) # { 80122600: 36104000 ori r16,r16,0x4000 # jobOutputValue = jobOutputValue | 0x4000 // Can't pick this job (base job) # } 80122604: 00561021 addu r2,r2,r22 # (jobIndex * 2) + outputArray 80122608: a4500000 sh r16,0x0000(r2) # *((jobIndex * 2) + outputArray) = jobOutputValue 8012260c: 322200ff andi r2,r17,0x00ff # formationUnitIndex 80122610: 3c03801d lui r3,0x801d 80122614: 2463d5ec addiu r3,r3,-0x2a14 # formationUnits 80122618: 00021080 sll r2,r2,0x02 # formationUnitIndex * 4 8012261c: 00438021 addu r16,r2,r3 # formationUnitPtr = formationUnits[formationUnitIndex] 80122620: 8e020000 lw r2,0x0000(r16) # formationUnit = *formationUnitPtr 80122624: 00000000 nop 80122628: 84440024 lh r4,0x0024(r2) # formationUnit.jobID 8012262c: 0c0482e4 jal 0x80120b90 # isSpecialMonster = Special monster check (formationUnit.jobID); 80122630: 26520001 addiu r18,r18,0x0001 # numJobs = numJobs + 1 80122634: 1440003e bne r2,r0,0x80122730 80122638: 00121040 sll r2,r18,0x01 # if ((isSpecialMonster == false) 8012263c: 8e020000 lw r2,0x0000(r16) 80122640: 00000000 nop 80122644: 8442003e lh r2,0x003e(r2) 80122648: 00000000 nop 8012264c: 14400038 bne r2,r0,0x80122730 # and (formationUnit.isPrimarySkillsetMonster == 0)) 80122650: 00121040 sll r2,r18,0x01 # { 80122654: 0c04ac7b jal 0x8012b1ec # Get Combined Bit Value From Stored Pointer (1); // Get base job unlock value (ignored) 80122658: 34040001 ori r4,r0,0x0001 8012265c: 34130001 ori r19,r0,0x0001 # jobOffset = 1 80122660: 0200a021 addu r20,r16,r0 # formationUnitPtr 80122664: 00121040 sll r2,r18,0x01 80122668: 00568821 addu r17,r2,r22 # outputArrayJobPtr = (jobIndex * 2) + outputArray # for (; jobOffset < 20; jobOffset++) { 8012266c: 2670004a addiu r16,r19,0x004a # jobID = jobOffset + 0x4a // 0x4A is Squire job ID 80122670: 0c04ac7b jal 0x8012b1ec # isJobUnlocked = Get Combined Bit Value From Stored Pointer (1); 80122674: 34040001 ori r4,r0,0x0001 80122678: 00401821 addu r3,r2,r0 # isJobUnlocked 8012267c: 3402005b ori r2,r0,0x005b 80122680: 16020008 bne r16,r2,0x801226a4 # if (jobID == JOB_ID_BARD) { 80122684: 3402005c ori r2,r0,0x005c 80122688: 8e820000 lw r2,0x0000(r20) # formationUnit = *formationUnitPtr 8012268c: 00000000 nop 80122690: 90420070 lbu r2,0x0070(r2) # formationUnit.Flags 80122694: 00000000 nop 80122698: 30420040 andi r2,r2,0x0040 # formationUnit.Flags | FLAG_FEMALE 8012269c: 14400020 bne r2,r0,0x80122720 # if (formationUnit.Flags | FLAG_FEMALE) { continue; } // Go to next iteration 801226a0: 3402005c ori r2,r0,0x005c # } 801226a4: 16020008 bne r16,r2,0x801226c8 # if (jobID == JOB_ID_DANCER) { 801226a8: 34020002 ori r2,r0,0x0002 801226ac: 8e820000 lw r2,0x0000(r20) # formationUnit = *formationUnitPtr 801226b0: 00000000 nop 801226b4: 90420070 lbu r2,0x0070(r2) # formationUnit.Flags 801226b8: 00000000 nop 801226bc: 30420080 andi r2,r2,0x0080 # formationUnit.Flags | FLAG_MALE 801226c0: 14400017 bne r2,r0,0x80122720 # if (formationUnit.Flags | FLAG_MALE) { continue; } // Go to next iteration 801226c4: 34020002 ori r2,r0,0x0002 # } # isStoringDisabledValue = true # jobDisabledValue = jobID | 0x4000 801226c8: 16a20007 bne r21,r2,0x801226e8 # if ((optionValue != 2) 801226cc: 00000000 nop 801226d0: 8e820000 lw r2,0x0000(r20) 801226d4: 00000000 nop 801226d8: 84420024 lh r2,0x0024(r2) 801226dc: 00000000 nop 801226e0: 1202000c beq r16,r2,0x80122714 # or ((jobID != formationUnit.jobID)) 801226e4: 36024000 ori r2,r16,0x4000 # { 801226e8: 10600003 beq r3,r0,0x801226f8 # if (isJobUnlocked) { 801226ec: 34020002 ori r2,r0,0x0002 801226f0: 080489c6 j 0x80122718 # isStoringDisabledValue = false 801226f4: a6300000 sh r16,0x0000(r17) # *outputArrayJobPtr = jobID # } else { 801226f8: 16a20009 bne r21,r2,0x80122720 # if (optionValue != 2) { continue; } // Go to next iteration 801226fc: 00000000 nop 80122700: 00102400 sll r4,r16,0x10 80122704: 0c048922 jal 0x80122488 # isUnlocked = Set Jobs unlocked by others (jobID); 80122708: 00042403 sra r4,r4,0x10 8012270c: 14400004 bne r2,r0,0x80122720 # if (isUnlocked == false) { continue; } // Go to next iteration 80122710: 26024000 addiu r2,r16,0x4000 # jobDisabledValue = jobID + 0x4000 # } # } # if (isStoringDisabledValue) { 80122714: a6220000 sh r2,0x0000(r17) # *outputArrayJobPtr = jobDisabledValue // Store job as disabled # } 80122718: 26310002 addiu r17,r17,0x0002 # outputArrayJobPtr = outputArrayJobPtr + 2 8012271c: 26520001 addiu r18,r18,0x0001 # jobIndex = jobIndex + 1 80122720: 26730001 addiu r19,r19,0x0001 # (jobOffset = jobOffset + 1) 80122724: 2a620014 slti r2,r19,0x0014 80122728: 1440ffd0 bne r2,r0,0x8012266c # } # } 8012272c: 00121040 sll r2,r18,0x01 80122730: 00561021 addu r2,r2,r22 # (jobIndex * 2) + outputArray 80122734: 2403ffff addiu r3,r0,-0x0001 # -1 80122738: a4430000 sh r3,0x0000(r2) # *((jobIndex * 2) + outputArray) = -1 // Sentinel value for entry after last available job 8012273c: 02401021 addu r2,r18,r0 # return jobIndex; // Equal to number of jobs written into the output array 80122740: 8fbf002c lw r31,0x002c(r29) 80122744: 8fb60028 lw r22,0x0028(r29) 80122748: 8fb50024 lw r21,0x0024(r29) 8012274c: 8fb40020 lw r20,0x0020(r29) 80122750: 8fb3001c lw r19,0x001c(r29) 80122754: 8fb20018 lw r18,0x0018(r29) 80122758: 8fb10014 lw r17,0x0014(r29) 8012275c: 8fb00010 lw r16,0x0010(r29) 80122760: 27bd0030 addiu r29,r29,0x0030 80122764: 03e00008 jr r31 80122768: 00000000 nop