Store JP; Calculate Unlocked Jobs

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
Store JP; Calculate Unlocked Jobs
0017ea80: 27bdffe0 addiu r29,r29,0xffe0
0017ea84: afb10014 sw r17,0x0014(r29)
0017ea88: 00e08821 addu r17,r7,r0		r17 = Generic Job ID
0017ea8c: afbf0018 sw r31,0x0018(r29)
0017ea90: 04a0002b bltz r5,0x 0017eb40		Branch if JP < 0
0017ea94: afb00010 sw r16,0x0010(r29)
0017ea98: 000410c0 sll r2,r4,0x03		ID * 8
0017ea9c: 00441023 subu r2,r2,r4		ID * 7
0017eaa0: 00021180 sll r2,r2,0x06		ID * 1c0
0017eaa4: 3c038019 lui r3,0x8019
0017eaa8: 246308cc addiu r3,r3,0x08cc
0017eaac: 00438021 addu r16,r2,r3
0017eab0: 92030001 lbu r3,0x0001(r16)		Load Unit's Unit ID
0017eab4: 340200ff ori r2,r0,0x00ff		r2 = FF
0017eab8: 10620051 beq r3,r2,0x 0017ec00		Branch if Unit doesn't exist
0017eabc: 2402ffff addiu r2,r0,0xffff		r2 = FFFF (Fail)
0017eac0: 92020058 lbu r2,0x0058(r16)		Load Unit's Current Statuses 1
0017eac4: 00000000 nop
0017eac8: 30420060 andi r2,r2,0x0060
0017eacc: 1440004c bne r2,r0,0x 0017ec00		Branch if Unit is a Crystal/Dead
0017ead0: 2402ffff addiu r2,r0,0xffff		r2 = FFFF (Fail)
0017ead4: 92020059 lbu r2,0x0059(r16)		Load Unit's Current Statuses 2
0017ead8: 00000000 nop
0017eadc: 30420001 andi r2,r2,0x0001
0017eae0: 14400047 bne r2,r0,0x 0017ec00		Branch if Unit is Treasure
0017eae4: 2402ffff addiu r2,r0,0xffff		r2 = FFFF (Fail)
0017eae8: 92040006 lbu r4,0x0006(r16)		Load Gender Byte
0017eaec: 00000000 nop
0017eaf0: 30820020 andi r2,r4,0x0020
0017eaf4: 14400042 bne r2,r0,0x 0017ec00		Branch if Unit is a monster
0017eaf8: 2402ffff addiu r2,r0,0xffff		r2 = FFFF (Fail)
0017eafc: 920201ba lbu r2,0x01ba(r16)		Load Unit's Modified ENTD Flags
0017eb00: 30c300ff andi r3,r6,0x00ff		r3 = Team Flags
0017eb04: 30420030 andi r2,r2,0x0030		r2 = Team Flags
0017eb08: 1443003d bne r2,r3,0x 0017ec00		Branch if the Teams differ
0017eb0c: 2402ffff addiu r2,r0,0xffff		r2 = FFFF (Fail)
0017eb10: 34020011 ori r2,r0,0x0011		r2 = 11
0017eb14: 16220005 bne r17,r2,0x 0017eb2c	Branch if Generic Job ID = Bard
0017eb18: 34020012 ori r2,r0,0x0012		r2 = 12
0017eb1c: 30820040 andi r2,r4,0x0040
0017eb20: 14400037 bne r2,r0,0x 0017ec00		Branch if Unit is Female
0017eb24: 2402ffff addiu r2,r0,0xffff		r2 = FFFF
0017eb28: 34020012 ori r2,r0,0x0012		r2 = 12
0017eb2c: 16220006 bne r17,r2,0x 0017eb48	Branch if Generic Job ID = Dancer
0017eb30: 00111040 sll r2,r17,0x01		ID * 2
0017eb34: 30820080 andi r2,r4,0x0080
0017eb38: 10400003 beq r2,r0,0x 0017eb48		Branch if Unit is Male
0017eb3c: 00111040 sll r2,r17,0x01		ID * 2
0017eb40: 0805fb00 j 0x 0017ec00
0017eb44: 2402ffff addiu r2,r0,0xffff		r2 = FFFF
0017eb48: 00503021 addu r6,r2,r16
0017eb4c: 94c200dc lhu r2,0x00dc(r6)		Load Job's JP
0017eb50: 00000000 nop
0017eb54: 00451821 addu r3,r2,r5		r3 = Job's JP += JP
0017eb58: 28622710 slti r2,r3,0x2710
0017eb5c: 14400002 bne r2,r0,0x 0017eb68		Branch if JP < 10000
0017eb60: 00000000 nop
0017eb64: 3403270f ori r3,r0,0x270f		Job's JP = 9999
0017eb68: 94c20104 lhu r2,0x0104(r6)		Load Job's Total JP
0017eb6c: a4c300dc sh r3,0x00dc(r6)		Store Job's new JP
0017eb70: 00451821 addu r3,r2,r5		r3 = Job's Total JP += JP
0017eb74: 28622710 slti r2,r3,0x2710
0017eb78: 14400003 bne r2,r0,0x 0017eb88		Branch if JP < 10000
0017eb7c: 3064ffff andi r4,r3,0xffff		r4 = Job's Total JP
0017eb80: 3403270f ori r3,r0,0x270f		r3 = 9999
0017eb84: 3064ffff andi r4,r3,0xffff		r4 = Job's Total JP
0017eb88: 0c0177bd jal 0x0005def4		Calculate Job Level
0017eb8c: a4c30104 sh r3,0x0104(r6)		Store Job's new Total JP
0017eb90: 00111fc2 srl r3,r17,0x1f
0017eb94: 02231821 addu r3,r17,r3
0017eb98: 00031843 sra r3,r3,0x01		ID * 2
0017eb9c: 02031821 addu r3,r16,r3
0017eba0: 00402021 addu r4,r2,r0		r4 = Job Level
0017eba4: 32220001 andi r2,r17,0x0001		r2 = Generic Job ID AND 0x1 (find nybble)
0017eba8: 906300d2 lbu r3,0x00d2(r3)		Load Job Level
0017ebac: 10400004 beq r2,r0,0x 0017ebc0		Branch if replacing high nybble
0017ebb0: 00802821 addu r5,r4,r0		r5 = Job Level
0017ebb4: 306200f0 andi r2,r3,0x00f0		r2 = High nybble Job Level (keep as is)
0017ebb8: 0805faf4 j 0x 0017ebd0
0017ebbc: 00821821 addu r3,r4,r2		r3 = new Job Level (replaces low nybble)
0017ebc0: 3063000f andi r3,r3,0x000f		r3 = low nybble Job Level (keep as is)
0017ebc4: 30a200ff andi r2,r5,0x00ff		r2 = Job Level
0017ebc8: 00021100 sll r2,r2,0x04		Job Level * 16
0017ebcc: 00621825 or r3,r3,r2			r3 = new Job Level (replaces high nybble)
0017ebd0: 001117c2 srl r2,r17,0x1f
0017ebd4: 02221021 addu r2,r17,r2
0017ebd8: 00021043 sra r2,r2,0x01		ID / 2
0017ebdc: 02021021 addu r2,r16,r2
0017ebe0: a04300d2 sb r3,0x00d2(r2)		Store Job's new Job Level
0017ebe4: 92050006 lbu r5,0x0006(r16)		Load Unit's Gender Byte
0017ebe8: 0c017705 jal 0x0005dc14		Calculate Unlocked Jobs
0017ebec: 260400d2 addiu r4,r16,0x00d2		r4 = Pointer to Unit's Job Levels
0017ebf0: 26040096 addiu r4,r16,0x0096		r4 = Pointer to Unit's Unlocked Jobs
0017ebf4: 0c0177b6 jal 0x0005ded8		Store 3-Byte Data (unlocked jobs)
0017ebf8: 00402821 addu r5,r2,r0		r5 = Unlocked Jobs
0017ebfc: 00001021 addu r2,r0,r0		r2 = 0 (Success)
0017ec00: 8fbf0018 lw r31,0x0018(r29)
0017ec04: 8fb10014 lw r17,0x0014(r29)
0017ec08: 8fb00010 lw r16,0x0010(r29)
0017ec0c: 27bd0020 addiu r29,r29,0x0020
0017ec10: 03e00008 jr r31
0017ec14: 00000000 nop



Return Locations

0017e980: - Award EXP and JP for actions
0017e9cc: - Award EXP and JP for actions