Calculate Actual Stats (Used for Stat Capping as well)

From Final Fantasy Hacktics Wiki
Revision as of 00:33, 1 March 2012 by Choto (talk | contribs)
Jump to navigation Jump to search
Calculate Actual Stats (Used for Stat Capping as well)
0005b880: 00804821 addu r9,r4,r0		r9 = Unit's Data Pointer
0005b884: 34180064 ori r24,r0,0x0064		HP/MP Divisor = 100 (Normal Units)
0005b888: 340e03e7 ori r14,r0,0x03e7		Stat Cap = 999
0005b88c: 91220006 lbu r2,0x0006(r9)		Load Unit's Gender Byte
0005b890: 00000000 nop
0005b894: 30420004 andi r2,r2,0x0004
0005b898: 10400003 beq r2,r0,0x 0005b8a8		Branch if not ??? stats
0005b89c: 30ad0001 andi r13,r5,0x0001		r13 = Level UP Check AND 1 (Check if storing base PA/MA/SP)
0005b8a0: 3418000a ori r24,r0,0x000a		HP/MP Divisor = 10 (??? Units)
0005b8a4: 340effff ori r14,r0,0xffff		Stat Cap = 65535
0005b8a8: 0 0005821 addu r11,r0,r0		Counter = 0
0005b8ac: 252c0081 addiu r12,r9,0x0081		r12 = Unit's Data Pointer (Stat Growth)
0005b8b0: 912f0022 lbu r15,0x0022(r9)		Load Unit's Level
0005b8b4: 252a0072 addiu r10,r9,0x0072		r10 = Unit's Data Pointer (Raw Stat)
0005b8b8: 29f90002 slti r25,r15,0x0002		(Could just lw, sll 0x08, srl 0x08)
0005b8bc: 91420001 lbu r2,0x0001(r10)		Load Unit's Raw Stat (byte 2)
0005b8c0: 91440000 lbu r4,0x0000(r10)		Load Unit's Raw Stat (byte 1)
0005b8c4: 91430002 lbu r3,0x0002(r10)		Load Unit's Raw Stat (byte 3)
0005b8c8: 00021200 sll r2,r2,0x08		Byte 2 * 100h
0005b8cc: 00822021 addu r4,r4,r2		Byte 1 + byte 2
0005b8d0: 00031c00 sll r3,r3,0x10		Byte 3 * 10000h
0005b8d4: 14a00017 bne r5,r0,0x 0005b934		Branch if Preset Value != 0 (Skip Level UP)
0005b8d8: 00832021 addu r4,r4,r3		r4 = Full Raw Stat
0005b8dc: 91230002 lbu r3,0x0002(r9)		Load Unit's Party ID
0005b8e0: 340200fe ori r2,r0,0x00fe
0005b8e4: 14620013 bne r3,r2,0x 0005b934		Branch if Party ID isn't 0xFE (ENTD Units not in party)
0005b8e8: 00000000 nop
0005b8ec: 91870000 lbu r7,0x0000(r12)		Load Unit's Stat Growth
0005b8f0: 00000000 nop
0005b8f4: 14e00002 bne r7,r0,0x 0005b900		Branch if Growth > 0
0005b8f8: 00e01021 addu r2,r7,r0		r2 = Stat Growth
0005b8fc: 34020001 ori r2,r0,0x0001		r2 = 1 (min growth)
0005b900: 00403821 addu r7,r2,r0		r7 = Stat Growth
0005b904: 34060002 ori r6,r0,0x0002		Level Counter = 2
0005b908: 1720000a bne r25,r0,0x 0005b934	Branch if Unit's Level < 2
0005b90c: 01e04021 addu r8,r15,r0		r8 = Unit's Level
0005b910: 00e61021 addu r2,r7,r6		r2 = Stat Growth + Level Counter
0005b914: 2442ffff addiu r2,r2,0xffff		r2 = Stat Growth + Level Counter - 1 (Previous Level)
0005b918: 0082001b divu r4,r2			Raw Stat / Stat Growth
0005b91c: 00001012 mflo r2			r2 = Raw Stat / Stat Growth (Raw Stat Bonus)
0005b920: 24c60001 addiu r6,r6,0x0001		Level Counter += 1
0005b924: 00822021 addu r4,r4,r2		Raw Stat += Raw Stat Bonus
0005b928: 0106102a slt r2,r8,r6
0005b92c: 1040fff9 beq r2,r0,0x 0005b914		Branch if Unit's Level > Level Counter
0005b930: 00e61021 addu r2,r7,r6		r2 = Stat Growth + Level Counter
0005b934: 3c0200ff lui r2,0x00ff
0005b938: 3442ffff ori r2,r2,0xffff		r2 = ffffff
0005b93c: 0044102b sltu r2,r2,r4
0005b940: 10400003 beq r2,r0,0x 0005b950		Branch if Raw Stat <= ffffff
0005b944: 34070064 ori r7,r0,0x0064		Raw Divisor = 100 (SP/PA/MA)
0005b948: 3c0400ff lui r4,0x00ff
0005b94c: 3484ffff ori r4,r4,0xffff		Raw Stat = ffffff
0005b950: 00041202 srl r2,r4,0x08		Raw Stat / 256
0005b954: a1420001 sb r2,0x0001(r10)		Store Raw Stat's 2nd Byte
0005b958: 00041402 srl r2,r4,0x10		Raw Stat / 65536
0005b95c: 29660002 slti r6,r11,0x0002		(Could sh, srl 0x10, sb)
0005b960: a1440000 sb r4,0x0000(r10)		Store Raw Stat's 1st byte
0005b964: a1420002 sb r2,0x0002(r10)		Store Raw Stat's 3rd byte
0005b968: 91820001 lbu r2,0x0001(r12)		Load Unit's Stat Multiplier
0005b96c: 10c00002 beq r6,r0,0x 0005b978		Branch if Counter >= 2 (Not HP/MP)
0005b970: 00820018 mult r4,r2			Raw Stat * Stat Multiplier
0005b974: 03003821 addu r7,r24,r0		Raw Divisor = HP/MP Divisor
0005b978: 00001012 mflo r2			r2 = Raw Stat * Stat Multiplier
0005b97c: 00000000 nop
0005b980: 00000000 nop
0005b984: 0047001b divu r2,r7			Raw Stat * Stat Multiplier / Raw Divisor
0005b988: 00001012 mflo r2			r2 = Raw Stat * Stat Multiplier / Raw Divisor
0005b98c: 00000000 nop
0005b990: 00022382 srl r4,r2,0x0e		Actual Stat = Raw * Multiplier / Raw Divisor / 16384
0005b994: 14800002 bne r4,r0,0x 0005b9a0		Branch if Actual Stat > 0
0005b998: 00000000 nop
0005b99c: 34040001 ori r4,r0,0x0001		Actual Stat = 1
0005b9a0: 10c00004 beq r6,r0,0x 0005b9b4		Branch if Counter >= 2 (Not HP/MP)
0005b9a4: 01c4102b sltu r2,r14,r4
0005b9a8: 10400003 beq r2,r0,0x 0005b9b8		Branch if Stat Cap > Actual Stat
0005b9ac: 34020002 ori r2,r0,0x0002		r2 = 2
0005b9b0: 01c02021 addu r4,r14,r0		Actual Stat = Stat Cap
0005b9b4: 34020002 ori r2,r0,0x0002		r2 = 2
0005b9b8: 1562 0005 bne r11,r2,0x 0005b9d0	Branch if Counter != 2 (Speed)
0005b9bc: 29620003 slti r2,r11,0x0003
0005b9c0: 2c820033 sltiu r2,r4,0x0033
0005b9c4: 14400002 bne r2,r0,0x 0005b9d0		Branch if Actual Stat < 51
0005b9c8: 29620003 slti r2,r11,0x0003
0005b9cc: 34040032 ori r4,r0,0x0032		Actual Stat = 50 (Speed Cap)
0005b9d0: 1440 0005 bne r2,r0,0x 0005b9e8		Branch if Counter < 3 (Not PA/MA)
0005b9d4: 2d62 0005 sltiu r2,r11,0x 0005
0005b9d8: 2c820064 sltiu r2,r4,0x0064
0005b9dc: 14400002 bne r2,r0,0x 0005b9e8		Branch if Actual Stat < 100
0005b9e0: 2d62 0005 sltiu r2,r11,0x 0005
0005b9e4: 34040063 ori r4,r0,0x0063		Actual Stat = 99 (PA/MA Cap)
0005b9e8: 1040001a beq r2,r0,0x 0005ba54		Branch if Counter < 5
0005b9ec: 000b1080 sll r2,r11,0x02		Counter * 4
0005b9f0: 3c018006 lui r1,0x8006
0005b9f4: 00220821 addu r1,r1,r2
0005b9f8: 8c229818 lw r2,-0x67e8(r1)		Load Level UP Stat Storing Code Pointer
0005b9fc: 00000000 nop
0005ba00: 00400008 jr r2
0005ba04: 00000000 nop
0005ba08: 14a00012 bne r5,r0,0x 0005ba54		Branch if Not Leveling UP (Initializing ENTD units)
0005ba0c: a524002a sh r4,0x002a(r9)		Store New Max HP
0005ba10: 08016e95 j 0x 0005ba54			(Max HP/MP are always set)
0005ba14: a5240028 sh r4,0x0028(r9)		Store New Current HP
0005ba18: 14a0000e bne r5,r0,0x 0005ba54		Branch if Not Leveling UP
0005ba1c: a524002e sh r4,0x002e(r9)		Store New Max MP
0005ba20: 08016e95 j 0x 0005ba54
0005ba24: a524002c sh r4,0x002c(r9)		Store New Current MP
0005ba28: 15a0000a bne r13,r0,0x 0005ba54	Branch if Not storing base PA/MA/SP
0005ba2c: 00000000 nop				(Leveling UP sets these as well)
0005ba30: 08016e95 j 0x 0005ba54
0005ba34: a1240032 sb r4,0x0032(r9)		Store New Original SP
0005ba38: 15a00006 bne r13,r0,0x 0005ba54	Branch if Not storing base PA/MA/SP
0005ba3c: 00000000 nop
0005ba40: 08016e95 j 0x 0005ba54
0005ba44: a1240030 sb r4,0x0030(r9)		Store New Original PA
0005ba48: 15a00002 bne r13,r0,0x 0005ba54	Branch if Not storing base PA/MA/SP
0005ba4c: 00000000 nop
0005ba50: a1240031 sb r4,0x0031(r9)		Store New Original MA
0005ba54: 258c0002 addiu r12,r12,0x0002		Stat Growth Pointer += 2
0005ba58: 256b0001 addiu r11,r11,0x0001		Counter ++
0005ba5c: 2962 0005 slti r2,r11,0x 0005
0005ba60: 1440ff96 bne r2,r0,0x 0005b8bc		Branch if Counter < 5
0005ba64: 254a0003 addiu r10,r10,0x0003		Raw Stat Pointer += 3
0005ba68: 03e00008 jr r31
0005ba6c: 00000000 nop


Return Locations

0005b48c: Calculate ENTD Unit Jobs