Sprite Set and Random Secondary Job Calculation

From Final Fantasy Hacktics Wiki
Revision as of 13:58, 29 February 2012 by Choto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Sprite Set and Random Secondary Job Calculation
0005b500: 27bdffd0 addiu r29,r29,0xffd0
0005b504: 00804021 addu r8,r4,r0		r8 = Unit's Data Pointer
0005b508: 3c060080 lui r6,0x0080		Job Check = 0x800000
0005b50c: afb00028 sw r16,0x0028(r29)
0005b510: 00008021 addu r16,r0,r0		Unlocked Job Counter = 0
0005b514: 00002821 addu r5,r0,r0		Counter = 0
0005b518: 27a70010 addiu r7,r29,0x0010		r7 = Stack Pointer
0005b51c: afbf002c sw r31,0x002c(r29)
0005b520: 91020096 lbu r2,0x0096(r8)		Load Unit's Unlocked Jobs 1
0005b524: 91030097 lbu r3,0x0097(r8)		Load Unit's Unlocked Jobs 2
0005b528: 91040098 lbu r4,0x0098(r8)		Load Unit's Unlocked Jobs 3
0005b52c: 00021400 sll r2,r2,0x10		UJ1 * 0x10000
0005b530: 00031a00 sll r3,r3,0x08		UJ2 * 0x100
0005b534: 00431021 addu r2,r2,r3
0005b538: 00442021 addu r4,r2,r4		r4 = Unlocked Jobs
0005b53c: 00861024 and r2,r4,r6
0005b540: 1040000d beq r2,r0,0x 0005b578		Branch if Job isn't Unlocked
0005b544: 00000000 nop
0005b548: 14a00008 bne r5,r0,0x 0005b56c		Branch if Counter != 0
0005b54c: 24a3004a addiu r3,r5,0x004a		Job ID = Counter + 0x4a
0005b550: 91030000 lbu r3,0x0000(r8)		Load Unit's Sprite Set
0005b554: 00000000 nop
0005b558: 306200ff andi r2,r3,0x00ff
0005b55c: 2c420080 sltiu r2,r2,0x0080
0005b560: 14400002 bne r2,r0,0x 0005b56c		Branch if Sprite Set is Special
0005b564: 00000000 nop
0005b568: 3403004a ori r3,r0,0x004a		Job ID = Squire
0005b56c: a0e30000 sb r3,0x0000(r7)		Store Temp Job ID = Squire/Sprite Set ID
0005b570: 24e70001 addiu r7,r7,0x0001		Stack Pointer ++
0005b574: 26100001 addiu r16,r16,0x0001		Unlocked Job Counter ++
0005b578: 24a50001 addiu r5,r5,0x0001		Counter ++
0005b57c: 000617c2 srl r2,r6,0x1f
0005b580: 00c21021 addu r2,r6,r2
0005b584: 00023043 sra r6,r2,0x01		Job Check / 2 (next job)
0005b588: 28a20013 slti r2,r5,0x0013
0005b58c: 1440ffeb bne r2,r0,0x 0005b53c		Branch if Counter < 0x13 (Skip Mime)
0005b590: 00000000 nop
0005b594: 1200000c beq r16,r0,0x 0005b5c8	Branch if No Jobs are Unlocked
0005b598: 00001021 addu r2,r0,r0		Skillset = 0
0005b59c: 0c0088c3 jal 0x0002230c		Random Number Generator
0005b5a0: 00000000 nop
0005b5a4: 00500018 mult r2,r16			Random * Jobs Unlocked Counter
0005b5a8: 00001012 mflo r2			r2 = "
0005b5ac: 04410003 bgez r2,0x 0005b5bc		Branch if Random is positive
0005b5b0: 00021bc2 srl r3,r2,0x0f		rand(0..(Jobs Unlocked Counter - 1))
0005b5b4: 24427fff addiu r2,r2,0x7fff
0005b5b8: 00021bc2 srl r3,r2,0x0f
0005b5bc: 306200ff andi r2,r3,0x00ff
0005b5c0: 03a21021 addu r2,r29,r2		r2 = Pointer to chosen Secondary
0005b5c4: 90420010 lbu r2,0x0010(r2)		Load Chosen Job ID
0005b5c8: 8fbf002c lw r31,0x002c(r29)
0005b5cc: 8fb00028 lw r16,0x0028(r29)
0005b5d0: 27bd0030 addiu r29,r29,0x0030
0005b5d4: 03e00008 jr r31
0005b5d8: 00000000 nop


Return Locations

0005b48c: Calculate ENTD Unit Jobs