Calculate Move EXP/JP UP To earn

From Final Fantasy Hacktics Wiki
(Redirected from Move Cap?)
Jump to navigation Jump to search
0017f0ec: 27bdffe8 addiu r29,r29,0xffe8
0017f0f0: afb00010 sw r16,0x0010(r29)
0017f0f4: 00808021 addu r16,r4,r0			Unit data pointer
0017f0f8: 3c048019 lui r4,0x8019
0017f0fc: 9084f7f0 lbu r4,-0x0810(r4)			load number of tiles moved
0017f100: 340200fe ori r2,r0,0x00fe
0017f104: 308300ff andi r3,r4,0x00ff
0017f108: 1462000d bne r3,r2,0x0017f140			branch if No. Tiles Moved != 0xfe
0017f10c: afbf0014 sw r31,0x0014(r29)
0017f110: 0c0088c3 jal 0x0002230c				rng
0017f114: 00000000 nop
0017f118: 9203003a lbu r3,0x003a(r16)			load move
0017f11c: 00000000 nop
0017f120: 00430018 mult r2,r3					move*RND(0x8000 - 0x7fff) (Signed)
0017f124: 00001012 mflo r2
0017f128: 04410002 bgez r2,0x0017f134			
0017f12c: 00000000 nop
0017f130: 24427fff addiu r2,r2,0x7fff			Move*RND(0x0 - 0x7fff)
0017f134: 000213c3 sra r2,r2,0x0f			Move*RND(0x0 - 0x1)
0017f138: 24440001 addiu r4,r2,0x0001			Ceil(Move*RND(0x0 - 0x1)
0017f13c: 308300ff andi r3,r4,0x00ff
0017f140: 340200ff ori r2,r0,0x00ff
0017f144: 14620003 bne r3,r2,0x0017f154			branch if math above (exp/jp to earn) != 0xff
0017f148: 308200ff andi r2,r4,0x00ff
0017f14c: 34040001 ori r4,r0,0x0001			if exp/jp to earn is 255, set to 1 (I don't know what that logic is supposed to imply, it's not like this value is signed, and move is capped at 254 anyway)
0017f150: 308200ff andi r2,r4,0x00ff
0017f154: 2c420064 sltiu r2,r2,0x0064			set if Exp/jp to earn < 100
0017f158: 14400003 bne r2,r0,0x0017f168			cap exp/jp earned to 99
0017f15c: 308200ff andi r2,r4,0x00ff
0017f160: 34040063 ori r4,r0,0x0063
0017f164: 308200ff andi r2,r4,0x00ff			exp/jp to earn capped at 99
0017f168: 8fbf0014 lw r31,0x0014(r29)
0017f16c: 8fb00010 lw r16,0x0010(r29)
0017f170: 27bd0018 addiu r29,r29,0x0018
0017f174: 03e00008 jr r31				return exp/jp to earn as Move*(RND(0 - 1)) + 1 (I really thought it was the No. tiles moved that determined it, but I have been wrong before.)
0017f178: 00000000 nop