Attacker's Earned Experience

From Final Fantasy Hacktics Wiki
Revision as of 22:07, 4 October 2020 by EnderC (talk | contribs) (Fix comment spacing)
Jump to navigation Jump to search
Attacker's Earned Experience and Gained EXP Up
0018d620: 3c028019 lui r2,0x8019
0018d624: 8c42f5f0 lw r2,-0x0a10(r2)
0018d628: 00000000 nop
0018d62c: 14400035 bne r2,r0,0x0018d704        ;   branch if not commencing attack
0018d630: 00000000 nop
0018d634: 10800033 beq r4,r0,0x0018d704        ;   branch if ??
0018d638: 34020001 ori r2,r0,0x0001
0018d63c: 14820003 bne r4,r2,0x0018d64c        ;   branch if ?? is not 1
0018d640: 00000000 nop
0018d644: 0806359f j 0x0018d67c
0018d648: 3404000a ori r4,r0,0x000a            ;   Default to 10 experience
0018d64c: 3c028019 lui r2,0x8019
0018d650: 8c422d98 lw r2,0x2d98(r2)            ;   Load Defender's Data
0018d654: 00000000 nop
0018d658: 9043015c lbu r3,0x015c(r2)           ;   load dead byte
0018d65c: 00000000 nop
0018d660: 10600008 beq r3,r0,0x0018d684        ;   branch if defender was not killed
0018d664: 34040014 ori r4,r0,0x0014
0018d668: 34020014 ori r2,r0,0x0014
0018d66c: 0043001a div r2,r3                   ;   0x14 / 1? wtf?
0018d670: 00001012 mflo r2
0018d674: 00000000 nop
0018d678: 00402021 addu r4,r2,r0               ;   r4 = 0x14?
0018d67c: 3c028019 lui r2,0x8019
0018d680: 8c422d98 lw r2,0x2d98(r2)            ;   Load Defender's Data
0018d684: 3c058019 lui r5,0x8019
0018d688: 8ca52d94 lw r5,0x2d94(r5)            ;   Load Attacker's Data
0018d68c: 90420022 lbu r2,0x0022(r2)           ;   Load Defender's Level
0018d690: 90a30022 lbu r3,0x0022(r5)           ;   Load Attacker's Level
0018d694: 00821021 addu r2,r4,r2               ;   exp + defenders level
0018d698: 00431023 subu r2,r2,r3               ;   exp + defenders level - attackers level
0018d69c: 00402021 addu r4,r2,r0               ;   r4 = result
0018d6a0: 00021400 sll r2,r2,0x10
0018d6a4: 1c400002 bgtz r2,0x0018d6b0
0018d6a8: 00000000 nop
0018d6ac: 34040001 ori r4,r0,0x0001            ;   make positive
0018d6b0: 90a20090 lbu r2,0x0090(r5)           ;   Load Attacker's Second Set of  Support
0018d6b4: 00000000 nop
0018d6b8: 30420020 andi r2,r2,0x0020
0018d6bc: 10400002 beq r2,r0,0x0018d6c8        ;   Branch if unit doesn't have Gained EXP UP
0018d6c0: 00041400 sll r2,r4,0x10              ;   exp << 0x10
0018d6c4: 000223c2 srl r4,r2,0x0f              ;   exp >> 0x0f
0018d6c8: 00041400 sll r2,r4,0x10
0018d6cc: 00021403 sra r2,r2,0x10
0018d6d0: 28420064 slti r2,r2,0x0064           ;   set if < 100
0018d6d4: 14400003 bne r2,r0,0x0018d6e4        ;   branch if so
0018d6d8: 00041c00 sll r3,r4,0x10
0018d6dc: 34040063 ori r4,r0,0x0063            ;   cap at 99
0018d6e0: 00041c00 sll r3,r4,0x10
0018d6e4: 3c058019 lui r5,0x8019
0018d6e8: 24a538e7 addiu r5,r5,0x38e7
0018d6ec: 90a20000 lbu r2,0x0000(r5)           ;   Load Earned Experience
0018d6f0: 00031c03 sra r3,r3,0x10
0018d6f4: 0043102a slt r2,r2,r3                ;   set if earned experience < result
0018d6f8: 10400002 beq r2,r0,0x0018d704        ;   branch if not
0018d6fc: 00000000 nop
0018d700: a0a40000 sb r4,0x0000(r5)            ;   Store Earned Experience
0018d704: 03e00008 jr r31
0018d708: 00000000 nop