Difference between revisions of "Get Random Unlocked Job"
Jump to navigation
Jump to search
(Created page with " # ROUTINE: GET RANDOM UNLOCKED JOB # Gets a random unlocked job ID for this unit. # Parameters: # r4 = (unit) Unit in-battle data pointer #...") |
|||
Line 51: | Line 51: | ||
8005b594: 1200000c beq r16,r0,0x8005b5c8 # if (numJobs == 0) return 0; | 8005b594: 1200000c beq r16,r0,0x8005b5c8 # if (numJobs == 0) return 0; | ||
8005b598: 00001021 addu r2,r0,r0 | 8005b598: 00001021 addu r2,r0,r0 | ||
− | 8005b59c: 0c0088c3 jal 0x8002230c # rngResult = rand() | + | 8005b59c: 0c0088c3 jal 0x8002230c # rngResult = [[rand]]() |
8005b5a0: 00000000 nop | 8005b5a0: 00000000 nop | ||
8005b5a4: 00500018 mult r2,r16 | 8005b5a4: 00500018 mult r2,r16 |
Latest revision as of 18:02, 28 November 2020
# ROUTINE: GET RANDOM UNLOCKED JOB # Gets a random unlocked job ID for this unit. # Parameters: # r4 = (unit) Unit in-battle data pointer # Returns: # r2 = JobID corresponding to random unlocked job for this unit, or 0 if no jobs are unlocked 8005b500: 27bdffd0 addiu r29,r29,-0x0030 8005b504: 00804021 addu r8,r4,r0 # unit 8005b508: 3c060080 lui r6,0x0080 # jobMask = 0x800000 8005b50c: afb00028 sw r16,0x0028(r29) 8005b510: 00008021 addu r16,r0,r0 # numJobs = 0 8005b514: 00002821 addu r5,r0,r0 # jobIndex = 0 8005b518: 27a70010 addiu r7,r29,0x0010 # jobArrayPtr = &jobArray[0] 8005b51c: afbf002c sw r31,0x002c(r29) 8005b520: 91020096 lbu r2,0x0096(r8) # unit.UnlockedJobs1 8005b524: 91030097 lbu r3,0x0097(r8) # unit.UnlockedJobs2 8005b528: 91040098 lbu r4,0x0098(r8) # unit.UnlockedJobs3 8005b52c: 00021400 sll r2,r2,0x10 # unit.UnlockedJobs1 << 16 8005b530: 00031a00 sll r3,r3,0x08 # unit.UnlockedJobs2 << 8 8005b534: 00431021 addu r2,r2,r3 # (unit.UnlockedJobs1 << 16) + (unit.UnlockedJobs2 << 8) 8005b538: 00442021 addu r4,r2,r4 # unlockedJobs = (unit.UnlockedJobs1 << 16) + (unit.UnlockedJobs2 << 8) + unit.UnlockedJobs3 # do { 8005b53c: 00861024 and r2,r4,r6 # unlockedJobs & jobMask 8005b540: 1040000d beq r2,r0,0x8005b578 # if (unlockedJobs & jobMask) { 8005b544: 00000000 nop 8005b548: 14a00008 bne r5,r0,0x8005b56c 8005b54c: 24a3004a addiu r3,r5,0x004a # jobID = jobIndex + 0x4a // 0x4A Squire # if (jobIndex == 0) { 8005b550: 91030000 lbu r3,0x0000(r8) # unit.BaseClass 8005b554: 00000000 nop 8005b558: 306200ff andi r2,r3,0x00ff 8005b55c: 2c420080 sltiu r2,r2,0x0080 8005b560: 14400002 bne r2,r0,0x8005b56c # if (unit.BaseClass >= 0x80) { 8005b564: 00000000 nop 8005b568: 3403004a ori r3,r0,0x004a # jobID = 0x4A // 0x4A Squire # } # } 8005b56c: a0e30000 sb r3,0x0000(r7) # *jobArrayPtr = jobID 8005b570: 24e70001 addiu r7,r7,0x0001 # jobArrayPtr = jobArrayPtr + 1 8005b574: 26100001 addiu r16,r16,0x0001 # numJobs = numJobs + 1 # } 8005b578: 24a50001 addiu r5,r5,0x0001 # jobIndex = jobIndex + 1 8005b57c: 000617c2 srl r2,r6,0x1f 8005b580: 00c21021 addu r2,r6,r2 8005b584: 00023043 sra r6,r2,0x01 # jobMask = jobMask >> 1 8005b588: 28a20013 slti r2,r5,0x0013 8005b58c: 1440ffeb bne r2,r0,0x8005b53c 8005b590: 00000000 nop # } while (jobIndex < 20); 8005b594: 1200000c beq r16,r0,0x8005b5c8 # if (numJobs == 0) return 0; 8005b598: 00001021 addu r2,r0,r0 8005b59c: 0c0088c3 jal 0x8002230c # rngResult = rand() 8005b5a0: 00000000 nop 8005b5a4: 00500018 mult r2,r16 8005b5a8: 00001012 mflo r2 # rngResult * numJobs 8005b5ac: 04410003 bgez r2,0x8005b5bc 8005b5b0: 00021bc2 srl r3,r2,0x0f # randomJobID = (rngResult * numJobs) >> 15 8005b5b4: 24427fff addiu r2,r2,0x7fff 8005b5b8: 00021bc2 srl r3,r2,0x0f 8005b5bc: 306200ff andi r2,r3,0x00ff 8005b5c0: 03a21021 addu r2,r29,r2 # &jobArray[randomJobID] 8005b5c4: 90420010 lbu r2,0x0010(r2) # return jobArray[randomJobID]; 8005b5c8: 8fbf002c lw r31,0x002c(r29) 8005b5cc: 8fb00028 lw r16,0x0028(r29) 8005b5d0: 27bd0030 addiu r29,r29,0x0030 8005b5d4: 03e00008 jr r31 8005b5d8: 00000000 nop