Award EXP and JP for actions
Jump to navigation
Jump to search
#Parameters #r4 = Unit ID #r5 = Misc Unit Data Pointer? + 1b0 [Earned Experience (For Display?)]
#Returns #r2 = 0 if Unit can earn EXP/JP #r2 = -1 (0xffffffff) if Unit cannot earn EXP/JP
0017e7e4: 27bdffc0 addiu r29,r29,0xffc0 0017e7e8: afb40028 sw r20,0x0028(r29) 0017e7ec: 00a0a021 addu r20,r5,r0 r20 = Misc Unit Data Pointer? + 1b0 [Earned Experience (For Display?)] 0017e7f0: afbf0038 sw r31,0x0038(r29) 0017e7f4: afb70034 sw r23,0x0034(r29) 0017e7f8: afb60030 sw r22,0x0030(r29) 0017e7fc: afb5002c sw r21,0x002c(r29) 0017e800: afb30024 sw r19,0x0024(r29) 0017e804: afb20020 sw r18,0x0020(r29) 0017e808: afb1001c sw r17,0x001c(r29) 0017e80c: afb00018 sw r16,0x0018(r29) 0017e810: a2800000 sb r0,0x0000(r20) set Earned EXP = 0 0017e814: a2800001 sb r0,0x0001(r20) set Earned JP = 0 0017e818: a2800002 sb r0,0x0002(r20) set Earned Level Up = 0 0017e81c: a2800003 sb r0,0x0003(r20) set Earned Job Level Up = 0
Award EXP and Level Up check: 0017e820: 3c028019 lui r2,0x8019 0017e824: 8c4238bc lw r2,0x38bc(r2) Load Hamedo flag 0017e828: 00000000 nop 0017e82c: 14400019 bne r2,r0,0x0017e894 Branch to END if attack is being skipped by Hamedo 0017e830: 0080a821 addu r21,r4,r0 r21 = Unit ID 0017e834: 3c028019 lui r2,0x8019 0017e838: 904238e8 lbu r2,0x38e8(r2) Load "can earn Exp/JP" flag 0017e83c: 00000000 nop 0017e840: 1040006c beq r2,r0,0x0017e9f4 Branch if Unit cant earn EXP/JP 0017e844: 001510c0 sll r2,r21,0x03 r2 = Unit ID * 8 0017e848: 00551023 subu r2,r2,r21 r2 = Unit ID * 7 0017e84c: 00021180 sll r2,r2,0x06 r2 = Unit ID * 448 (448 = 0x1c0) 0017e850: 3c038019 lui r3,0x8019 0017e854: 246308cc addiu r3,r3,0x08cc Load Unit's Data 0017e858: 00439021 addu r18,r2,r3 r18 = Unit offset? 0017e85c: 92430001 lbu r3,0x0001(r18) Load ID of Unit 0017e860: 340200ff ori r2,r0,0x00ff 0017e864: 10620064 beq r3,r2,0x0017e9f8 Branch to END if Unit doesn't exist 0017e868: 2402ffff addiu r2,r0,-0x0001 r2 = -1 (Unit cannot earn EXP/JP) if nonexistant 0017e86c: 92420058 lbu r2,0x0058(r18) Load 1st set of statuses 0017e870: 00000000 nop 0017e874: 30420060 andi r2,r2,0x0060 0017e878: 1440005f bne r2,r0,0x0017e9f8 Branch to END if Unit is Dead/Crystal 0017e87c: 2402ffff addiu r2,r0,-0x0001 r2 = -1 (Unit cannot earn EXP/JP) if Dead/Crystal 0017e880: 92420059 lbu r2,0x0059(r18) Load 2nd set of statuses 0017e884: 00000000 nop 0017e888: 30420081 andi r2,r2,0x0081 0017e88c: 10400003 beq r2,r0,0x0017e89c Branch if Unit is not Petrify/Treasure 0017e890: 00000000 nop 0017e894: 0805fa7e j 0x0017e9f8 Jump to END if Unit is Petrify/Treasure 0017e898: 2402ffff addiu r2,r0,-0x0001 r2 = -1 (Unit cannot earn EXP/JP) if Petrify/Treasure 0017e89c: 92420021 lbu r2,0x0021(r18) Load Unit's Experience 0017e8a0: 3c038019 lui r3,0x8019 0017e8a4: 906338e7 lbu r3,0x38e7(r3) Load Earned Experience 0017e8a8: 92510022 lbu r17,0x0022(r18) r17 = Unit's Level 0017e8ac: 00431821 addu r3,r2,r3 Add Earned EXP to Unit's EXP 0017e8b0: 28620100 slti r2,r3,0x0100 Check if new EXP value is less than 0x100 (256) 0017e8b4: 14400002 bne r2,r0,0x0017e8c0 Branch if less than 0x100 0017e8b8: 00000000 nop 0017e8bc: 340300ff ori r3,r0,0x00ff Set new EXP to 0xff (255) if it was greater than 0xff 0017e8c0: a2430021 sb r3,0x0021(r18) Store Unit's new Experience 0017e8c4: 0c017620 jal 0x0005d880 Check if Unit Leveled UP 0017e8c8: 02402021 addu r4,r18,r0 0017e8cc: 14400006 bne r2,r0,0x0017e8e8 Branch if Unit leveled up 0017e8d0: 00000000 nop 0017e8d4: 3c028019 lui r2,0x8019 0017e8d8: 9042390c lbu r2,0x390c(r2) Load Ability type 0017e8dc: 00000000 nop 0017e8e0: 10400004 beq r2,r0,0x0017e8f4 Branch if Ability type = 0 0017e8e4: 00000000 nop 0017e8e8: 92420022 lbu r2,0x0022(r18) Load Unit Level 0017e8ec: 00000000 nop 0017e8f0: a2820002 sb r2,0x0002(r20) Store Earned Level Up 0017e8f4: 3c108019 lui r16,0x8019 0017e8f8: 261038e7 addiu r16,r16,0x38e7 r16 = Earned Experience pointer 0017e8fc: 92020000 lbu r2,0x0000(r16) Load Earned Experience 0017e900: 00000000 nop 0017e904: a2820000 sb r2,0x0000(r20) Save Earned EXP 0017e908: 92420006 lbu r2,0x0006(r18) Load Unit's Gender 0017e90c: 00000000 nop 0017e910: 30420020 andi r2,r2,0x0020 0017e914: 14400038 bne r2,r0,0x0017e9f8 Branch to END if unit is a Monster 0017e918: 00001021 addu r2,r0,r0 r2 = 0 (can earn EXP/JP)
Calculate JP and Award Spillover JP: 0017e91c: 02402021 addu r4,r18,r0 r4 = Unit Data 0017e920: 92560003 lbu r22,0x0003(r18) r22 = Unit Job ID 0017e924: 27a60010 addiu r6,r29,0x0010 0017e928: 0c05fa8a jal 0x0017ea28 Load Job Level 0017e92c: 02c02821 addu r5,r22,r0 0017e930: 0040b821 addu r23,r2,r0 r23 = Unit's current Job's Lv 0017e934: 00171040 sll r2,r23,0x01 r2 = Job Lv * 2 0017e938: 00111882 srl r3,r17,0x02 r3 = Unit's Level / 4 0017e93c: 24630008 addiu r3,r3,0x0008 r3 = [Unit's Level / 4] + 8 0017e940: 92040000 lbu r4,0x0000(r16) r4 = Earned Experience 0017e944: 00000000 nop 0017e948: 14800002 bne r4,r0,0x0017e954 Branch if Earned EXP is not 0 0017e94c: 00438821 addu r17,r2,r3 r17 (Earned JP) = (Job Lv * 2) + [(Unit's Level / 4) + 8] 0017e950: 00008821 addu r17,r0,r0 r17 (Earned JP) = 0 if Earned EXP = 0 0017e954: 92420005 lbu r2,0x0005(r18) Load Unit's Team (for spillover JP) 0017e958: 00008021 addu r16,r0,r0 Clear r16 (Counter = 0) 0017e95c: 30530030 andi r19,r2,0x0030 Check if Team is not Blue 0017e960: 12150009 beq r16,r21,0x0017e988 Loop Start: Branch if Unit ID = Acting Unit 0017e964: 00000000 nop 0017e968: 06210002 bgez r17,0x0017e974 Branch if Earned JP is not negative 0017e96c: 02202821 addu r5,r17,r0 r5 = Earned JP 0017e970: 26250003 addiu r5,r17,0x0003 r5 = Earned JP + 3 0017e974: 02002021 addu r4,r16,r0 r4 = Counter (Unit pointer) 0017e978: 00052883 sra r5,r5,0x02 r5 = Earned JP / 4 0017e97c: 8fa70010 lw r7,0x0010(r29) r7 = Stack pointer offset 0017e980: 0c05faa0 jal 0x0017ea80 Store JP; Calculate Unlocked Jobs 0017e984: 326600ff andi r6,r19,0x00ff r6 = Team flags 0017e988: 26100001 addiu r16,r16,0x0001 Counter ++ 0017e98c: 2a020015 slti r2,r16,0x0015 0017e990: 1440fff3 bne r2,r0,0x0017e960 Loop to next Unit 0017e994: 00000000 nop
Gained JP Up calculation and Award JP: 0017e998: 92420090 lbu r2,0x0090(r18) Load 2nd Set of Supports 0017e99c: 00000000 nop 0017e9a0: 30420040 andi r2,r2,0x0040 0017e9a4: 10400006 beq r2,r0,0x0017e9c0 Branch if Unit doesn't have Gained JP Up 0017e9a8: 02a02021 addu r4,r21,r0 r4 = Unit ID 0017e9ac: 00111040 sll r2,r17,0x01 0017e9b0: 00511021 addu r2,r2,r17 0017e9b4: 00021fc2 srl r3,r2,0x1f 0017e9b8: 00431021 addu r2,r2,r3 0017e9bc: 00028843 sra r17,r2,0x01 0017e9c0: 02202821 addu r5,r17,r0 r5 = Earned JP (*3/2 if Gained JP Up) 0017e9c4: 924601ba lbu r6,0x01ba(r18) r6 = Team Flags 0017e9c8: 8fa70010 lw r7,0x0010(r29) r7 = Stack pointer offset 0017e9cc: 0c05faa0 jal 0x0017ea80 Store JP; Calculate Unlocked Jobs 0017e9d0: 30c60030 andi r6,r6,0x0030 Blue Team check
Job Level Up check: 0017e9d4: 02402021 addu r4,r18,r0 r4 = Unit ID 0017e9d8: 02c02821 addu r5,r22,r0 r5 = Unit Job ID 0017e9dc: 0c05fa8a jal 0x0017ea28 Load Job Level 0017e9e0: 27a60010 addiu r6,r29,0x0010 r6 = Stack pointer offset 0017e9e4: 10570002 beq r2,r23,0x0017e9f0 Branch if new Job Lv = old Job Lv (no Job Lv Up) 0017e9e8: 00000000 nop 0017e9ec: a2820003 sb r2,0x0003(r20) Save Earned Job Lv Up 0017e9f0: a2910001 sb r17,0x0001(r20) Save Earned JP 0017e9f4: 00001021 addu r2,r0,r0 r2 = 0 (can earn EXP/JP)
End: 0017e9f8: 8fbf0038 lw r31,0x0038(r29) 0017e9fc: 8fb70034 lw r23,0x0034(r29) 0017ea00: 8fb60030 lw r22,0x0030(r29) 0017ea04: 8fb5002c lw r21,0x002c(r29) 0017ea08: 8fb40028 lw r20,0x0028(r29) 0017ea0c: 8fb30024 lw r19,0x0024(r29) 0017ea10: 8fb20020 lw r18,0x0020(r29) 0017ea14: 8fb1001c lw r17,0x001c(r29) 0017ea18: 8fb00018 lw r16,0x0018(r29) 0017ea1c: 27bd0040 addiu r29,r29,0x0040 0017ea20: 03e00008 jr r31 0017ea24: 00000000 nop
Return Locations
0007366c: - 00073638 - 000736d0