Difference between revisions of "Calculate Unit Jobs and Skillsets from ENTD"
Jump to navigation
Jump to search
(Created page with " # ROUTINE: Calculate Unit Jobs and Skillsets from ENTD # Calculates a generated unit's jobs and skillsets from the ENTD. # Parameters: # r4 = (unit...") |
|||
Line 67: | Line 67: | ||
8005b390: 10c00002 beq r6,r0,0x8005b39c | 8005b390: 10c00002 beq r6,r0,0x8005b39c | ||
8005b394: 34040001 ori r4,r0,0x0001 # jobUnlockLevel = 1 | 8005b394: 34040001 ori r4,r0,0x0001 # jobUnlockLevel = 1 | ||
− | # if (index | + | # if (index != 0) { |
8005b398: 34040011 ori r4,r0,0x0011 # jobUnlockLevel = 0x11 | 8005b398: 34040011 ori r4,r0,0x0011 # jobUnlockLevel = 0x11 | ||
# } | # } |
Latest revision as of 03:35, 12 November 2021
# ROUTINE: Calculate Unit Jobs and Skillsets from ENTD # Calculates a generated unit's jobs and skillsets from the ENTD. # Parameters: # r4 = (unit) Unit in-battle data pointer # r5 = (ENTDUnit) ENTD unit pointer 8005b2b4: 27bdffe0 addiu r29,r29,-0x0020 8005b2b8: afb00010 sw r16,0x0010(r29) 8005b2bc: 00808021 addu r16,r4,r0 # unit 8005b2c0: afb10014 sw r17,0x0014(r29) 8005b2c4: 00a08821 addu r17,r5,r0 # ENTDUnit 8005b2c8: 260400d2 addiu r4,r16,0x00d2 8005b2cc: afbf0018 sw r31,0x0018(r29) 8005b2d0: 0c017991 jal 0x8005e644 # Data Nullifying (&unit.JobLevels1, 10); // Clear Job Levels 8005b2d4: 3405000a ori r5,r0,0x000a 8005b2d8: 1620000b bne r17,r0,0x8005b308 8005b2dc: 00002821 addu r5,r0,r0 # jobsUnlocked = 0 # if (ENTDUnit == null) { 8005b2e0: 0c016d77 jal 0x8005b5dc # Transfer Job's Data to Unit's Data (unit); 8005b2e4: 02002021 addu r4,r16,r0 8005b2e8: 26040096 addiu r4,r16,0x0096 8005b2ec: 00002821 addu r5,r0,r0 8005b2f0: 34020020 ori r2,r0,0x0020 # FLAG_MONSTER 8005b2f4: a2000013 sb r0,0x0013(r16) # unit.SecondarySkillset = 0 8005b2f8: 0c0177b6 jal 0x8005ded8 # Store 3-Byte Data (&unit.JobsUnlocked1, 0); // Clear Unlocked Jobs 8005b2fc: a2020006 sb r2,0x0006(r16) # unit.Flags = FLAG_MONSTER 8005b300: 08016d3a j 0x8005b4e8 # return; 8005b304: 00000000 nop # } 8005b308: 922a0001 lbu r10,0x0001(r17) # ENTDUnit.Flags 8005b30c: 00000000 nop 8005b310: 31420020 andi r2,r10,0x0020 # ENTDUnit.Flags & FLAG_MONSTER 8005b314: 14400042 bne r2,r0,0x8005b420 # if ((ENTDUnit.Flags & FLAG_MONSTER) == 0) { 8005b318: 00000000 nop 8005b31c: 92260008 lbu r6,0x0008(r17) # ENTDUnit.JobUnlocked 8005b320: 00000000 nop 8005b324: 30c700ff andi r7,r6,0x00ff # ENTDUnit.JobUnlocked 8005b328: 2ce20014 sltiu r2,r7,0x0014 8005b32c: 1040003c beq r2,r0,0x8005b420 # if (ENTDUnit.JobUnlocked < 20) { 8005b330: 00000000 nop 8005b334: 92220009 lbu r2,0x0009(r17) # ENTDUnit.JobLevel 8005b338: 00000000 nop 8005b33c: 3043000f andi r3,r2,0x000f # jobLevel = ENTDUnit.JobLevel & 0x0f // Caps at 15 8005b340: 30c20001 andi r2,r6,0x0001 # ENTDUnit.JobUnlocked & 0x01 // (Same as ENTDUnit.JobUnlocked % 2) 8005b344: 14400002 bne r2,r0,0x8005b350 8005b348: 00602021 addu r4,r3,r0 # jobLevelStoreValue = jobLevel # if ((ENTDUnit.JobUnlocked & 0x01) == 0) { 8005b34c: 00032100 sll r4,r3,0x04 # jobLevelStoreValue = jobLevel << 4 # } 8005b350: 00071042 srl r2,r7,0x01 # ENTDUnit.JobUnlocked / 2 8005b354: 02021021 addu r2,r16,r2 # unit + (ENTDUnit.JobUnlocked / 2) 8005b358: a04400d2 sb r4,0x00d2(r2) # *(&unit.JobLevels1 + (ENTDUnit.JobUnlocked / 2)) = jobLevelStoreValue 8005b35c: 00003021 addu r6,r0,r0 # index = 0 8005b360: 00e04821 addu r9,r7,r0 # ENTDUnit.JobUnlocked 8005b364: 3c038006 lui r3,0x8006 8005b368: 246360ba addiu r3,r3,0x60ba # jobUnlockRequirements 8005b36c: 00091080 sll r2,r9,0x02 # ENTDUnit.JobUnlocked * 4 8005b370: 00491021 addu r2,r2,r9 # ENTDUnit.JobUnlocked * 5 8005b374: 00021040 sll r2,r2,0x01 # ENTDUnit.JobUnlocked * 10 8005b378: 00434021 addu r8,r2,r3 # jobUnlockRequirementsPtr = jobUnlockRequirements + (ENTDUnit.JobUnlocked * 10) # do { 8005b37c: 11200004 beq r9,r0,0x8005b390 # 8005b380: 02063821 addu r7,r16,r6 # unit + index # if (ENTDUnit.JobUnlocked != 0) { 8005b384: 91040000 lbu r4,0x0000(r8) # jobUnlockLevel = *jobUnlockRequirementsPtr 8005b388: 08016ce8 j 0x8005b3a0 8005b38c: 00000000 nop # } else { 8005b390: 10c00002 beq r6,r0,0x8005b39c 8005b394: 34040001 ori r4,r0,0x0001 # jobUnlockLevel = 1 # if (index != 0) { 8005b398: 34040011 ori r4,r0,0x0011 # jobUnlockLevel = 0x11 # } 8005b39c: 02063821 addu r7,r16,r6 # } 8005b3a0: 90e200d2 lbu r2,0x00d2(r7) # jobLevelValue = *(&unit.JobLevels1 + index) 8005b3a4: 00000000 nop 8005b3a8: 00821825 or r3,r4,r2 # combinedJobLevelValue = jobLevelValue | jobUnlockLevel 8005b3ac: 3062000f andi r2,r3,0x000f # combinedJobLevelValue & 0x0f 8005b3b0: 14400002 bne r2,r0,0x8005b3bc 8005b3b4: 00602021 addu r4,r3,r0 # newJobLevelValue = combinedJobLevelValue # if ((combinedJobLevelValue & 0x0f) == 0) { 8005b3b8: 34640001 ori r4,r3,0x0001 # newJobLevelValue = combinedJobLevelValue | 1 # } 8005b3bc: 308200f0 andi r2,r4,0x00f0 # newJobLevelValue & 0xf0 8005b3c0: 14400002 bne r2,r0,0x8005b3cc 8005b3c4: 25080001 addiu r8,r8,0x0001 # jobUnlockRequirementsPtr = jobUnlockRequirementsPtr + 1 # if ((newJobLevelValue & 0xf0) == 0) { 8005b3c8: 34840010 ori r4,r4,0x0010 # newJobLevelValue = newJobLevelValue | 0x10 # } 8005b3cc: 24c60001 addiu r6,r6,0x0001 # index = index + 1 8005b3d0: 28c2000a slti r2,r6,0x000a 8005b3d4: 1440ffe9 bne r2,r0,0x8005b37c 8005b3d8: a0e400d2 sb r4,0x00d2(r7) # *(&unit.JobLevels1 + index) = newJobLevelValue # } while (index < 10); 8005b3dc: 31420040 andi r2,r10,0x0040 8005b3e0: 10400006 beq r2,r0,0x8005b3fc 8005b3e4: 31420080 andi r2,r10,0x0080 # if (ENTDUnit.Flags & FLAG_FEMALE) { 8005b3e8: 920200da lbu r2,0x00da(r16) # unit.CalcBardJobLevel 8005b3ec: 00000000 nop 8005b3f0: 304200f0 andi r2,r2,0x00f0 # unit.CalcBardJobLevel & 0xf0 // Set Bard job level = 0 8005b3f4: a20200da sb r2,0x00da(r16) # unit.CalcBardJobLevel = unit.CalcBardJobLevel & 0xf0 8005b3f8: 31420080 andi r2,r10,0x0080 # } 8005b3fc: 10400005 beq r2,r0,0x8005b414 8005b400: 260400d2 addiu r4,r16,0x00d2 # &unit.JobLevels1 # if (ENTDUnit.Flags & FLAG_MALE) { 8005b404: 920200db lbu r2,0x00db(r16) # unit.DancerMimeJobLevel 8005b408: 00000000 nop 8005b40c: 3042000f andi r2,r2,0x000f # unit.DancerMimeJobLevel & 0x0f // Set Dancer job level = 0 8005b410: a20200db sb r2,0x00db(r16) # unit.DancerMimeJobLevel = unit.DancerMimeJobLevel & 0x0f # } 8005b414: 0c017705 jal 0x8005dc14 # jobsUnlocked = Calculate Unlocked Jobs (&unit.jobLevels1, ENTDUnit.Flags); 8005b418: 01402821 addu r5,r10,r0 8005b41c: 00402821 addu r5,r2,r0 # jobsUnlocked # } # } 8005b420: 0c0177b6 jal 0x8005ded8 # Store 3-Byte Data (&unit.JobsUnlocked1, jobsUnlocked); 8005b424: 26040096 addiu r4,r16,0x0096 8005b428: 9222000a lbu r2,0x000a(r17) # ENTDUnit.JobID 8005b42c: 02002021 addu r4,r16,r0 8005b430: 0c016d77 jal 0x8005b5dc # Transfer Job's Data to Unit's Data (unit); 8005b434: a2020003 sb r2,0x0003(r16) # unit.JobID = ENTDUnit.JobID 8005b438: 9226001d lbu r6,0x001d(r17) # ENTDUnit.PrimarySkillset 8005b43c: 340200ff ori r2,r0,0x00ff 8005b440: 30c300ff andi r3,r6,0x00ff # ENTDUnit.PrimarySkillset 8005b444: 10620005 beq r3,r2,0x8005b45c # if ((ENTDUnit.PrimarySkillset != 0xff) 8005b448: 00000000 nop 8005b44c: 10600003 beq r3,r0,0x8005b45c # and (ENTDUnit.PrimarySkillset != 0)) # { 8005b450: 340200ff ori r2,r0,0x00ff 8005b454: a2060012 sb r6,0x0012(r16) # unit.PrimarySkillset = ENTDUnit.PrimarySkillset 8005b458: a2020189 sb r2,0x0189(r16) # unit.0x189 = 0xff # } 8005b45c: 9226000b lbu r6,0x000b(r17) # ENTDUnit.SecondarySkillset 8005b460: 340200fe ori r2,r0,0x00fe 8005b464: 30c300ff andi r3,r6,0x00ff # ENTDUnit.SecondarySkillset 8005b468: 1462001e bne r3,r2,0x8005b4e4 # if (ENTDUnit.SecondarySkillset == 0xfe) { 8005b46c: 00000000 nop 8005b470: 92020006 lbu r2,0x0006(r16) # unit.Flags 8005b474: 00000000 nop 8005b478: 30420020 andi r2,r2,0x0020 8005b47c: 10400003 beq r2,r0,0x8005b48c # if (unit.Flags & FLAG_MONSTER) { 8005b480: 00000000 nop 8005b484: 08016d3a j 0x8005b4e8 8005b488: a2000013 sb r0,0x0013(r16) # unit.SecondarySkillset = 0 # return; # } 8005b48c: 0c016d40 jal 0x8005b500 # jobID = Get Random Unlocked Job (unit); 8005b490: 02002021 addu r4,r16,r0 8005b494: 00402021 addu r4,r2,r0 # jobID 8005b498: 308300ff andi r3,r4,0x00ff # jobID 8005b49c: 10600009 beq r3,r0,0x8005b4c4 8005b4a0: 00031040 sll r2,r3,0x01 # jobID * 2 # if (jobID != 0) { 8005b4a4: 00431021 addu r2,r2,r3 # jobID * 3 8005b4a8: 3c038006 lui r3,0x8006 8005b4ac: 8c636194 lw r3,0x6194(r3) # baseJobDataPtr (*0x80066194 (= 0x800610b8)) 8005b4b0: 00021100 sll r2,r2,0x04 # jobID * 48 8005b4b4: 00431021 addu r2,r2,r3 # job = baseJobDataPtr + (jobID * 48) 8005b4b8: 90430000 lbu r3,0x0000(r2) # skillset = job.Skillset 8005b4bc: 08016d32 j 0x8005b4c8 8005b4c0: 00000000 nop # } else { 8005b4c4: 308300ff andi r3,r4,0x00ff # skillset = jobID // skillset = 0 because jobID == 0 # } 8005b4c8: 92020012 lbu r2,0x0012(r16) # unit.PrimarySkillset 8005b4cc: 00000000 nop 8005b4d0: 14620002 bne r3,r2,0x8005b4dc # if (unit.PrimarySkillset == skillset) { 8005b4d4: 00000000 nop 8005b4d8: 00001821 addu r3,r0,r0 # skillset = 0 # } 8005b4dc: 08016d3a j 0x8005b4e8 8005b4e0: a2030013 sb r3,0x0013(r16) # unit.SecondarySkillset = skillset # } else { 8005b4e4: a2060013 sb r6,0x0013(r16) # unit.SecondarySkillset = ENTDUnit.SecondarySkillset # } 8005b4e8: 8fbf0018 lw r31,0x0018(r29) 8005b4ec: 8fb10014 lw r17,0x0014(r29) 8005b4f0: 8fb00010 lw r16,0x0010(r29) 8005b4f4: 27bd0020 addiu r29,r29,0x0020 8005b4f8: 03e00008 jr r31 8005b4fc: 00000000 nop