Formula 64 or Jump Base XA / YA

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
No Parameters - Returns Nothing

Set Ability XA and YA depending on Target weapon
 - Spear : XA = 150% of PA and YA = WP
 - Fists : XA = PA and YA = PA*Brave%
 - Else : XA = PA and YA = WP
--------------------------------------------------------------------------------
00185e94: 3c038019 lui r3,0x8019            |
00185e98: 906338d8 lbu r3,0x38d8(r3)        |r3 = Current Ability used Weapon ID
00185e9c: 00000000 nop                      |
00185ea0: 00031040 sll r2,r3,0x01           |ID * 2
00185ea4: 00431021 addu r2,r2,r3            |ID * 3
00185ea8: 00021080 sll r2,r2,0x02           |ID * 12
00185eac: 3c018006 lui r1,0x8006            |
00185eb0: 00220821 addu r1,r1,r2            |r1 = 0x80060000 + Weapon offset
00185eb4: 90242ebd lbu r4,0x2ebd(r1)        |r4 = Used Weapon Item type   0x800622b8 + 0x05 + Weapon offset
00185eb8: 3402000f ori r2,r0,0x000f         |r2 = 0x0f
00185ebc: 308300ff andi r3,r4,0x00ff        |r3 = Weapon Item Type (byte)
00185ec0: 1462000a bne r3,r2,0x00185eec     #If Weapon is a Spear
00185ec4: 00000000 nop                          |
00185ec8: 3c028019 lui r2,0x8019                |
00185ecc: 8c422d94 lw r2,0x2d94(r2)             |r2 = Attacker data pointer
00185ed0: 00000000 nop                          |
00185ed4: 90430036 lbu r3,0x0036(r2)            |r3 = Attacker's PA
00185ed8: 00000000 nop                          |
00185edc: 00031040 sll r2,r3,0x01               |PA * 2
00185ee0: 00431021 addu r2,r2,r3                |PA * 3
00185ee4: 080617bf j 0x00185efc                 >>Jump to store XA
00185ee8: 00021043 sra r2,r2,0x01               |r2 = Attacker's PA * 3 / 2
00185eec: 3c028019 lui r2,0x8019            #Else : Weapon is not a Spear
00185ef0: 8c422d94 lw r2,0x2d94(r2)             |r2 = Attacker data pointer
00185ef4: 00000000 nop                          |
00185ef8: 90420036 lbu r2,0x0036(r2)            |r3 = Attacker's PA
00185efc: 3c018019 lui r1,0x8019            |
00185f00: a42238ce sh r2,0x38ce(r1)         |Set Ability XA = PA or 150% of PA (if weapon is a spear)
00185f04: 14800018 bne r4,r0,0x00185f68     #If Weapon type is 0x00 (fists)
00185f08: 00000000 nop                          |
00185f0c: 3c028019 lui r2,0x8019                |
00185f10: 8c422d94 lw r2,0x2d94(r2)             |r2 = Attacker data pointer
00185f14: 3c038019 lui r3,0x8019                |
00185f18: 846338ce lh r3,0x38ce(r3)             |r3 = Ability XA
00185f1c: 90420024 lbu r2,0x0024(r2)            |r2 = Attacker's Current Brave
00185f20: 00000000 nop                          |
00185f24: 00620018 mult r3,r2                   |Brave * PA
00185f28: 00001812 mflo r3                      |r3 = Brave * PA
00185f2c: 3c0251eb lui r2,0x51eb                |
00185f30: 3442851f ori r2,r2,0x851f             |r2 = 0x51eb851f  = 0,32*2^32
00185f34: 00620018 mult r3,r2                   |PA * Brave * 0,32 * 2^32
00185f38: 3c048019 lui r4,0x8019                |
00185f3c: 248438d0 addiu r4,r4,0x38d0           |r4 = Current Ability YA data pointer
00185f40: 00031fc3 sra r3,r3,0x1f               |r3 = highest bit of r3 (used four rounding - should be 0)
00185f44: 00001010 mfhi r2                      |r2 = PA * Brave * 0,32
00185f48: 00021143 sra r2,r2,0x05               |r2 = PA * Brave /100         (r2/32)
00185f4c: 00431823 subu r3,r2,r3                |r3 = PA * Brave/100 rounded
00185f50: 00031400 sll r2,r3,0x10               |Move value in upper register part
00185f54: 14400008 bne r2,r0,0x00185f78         #If PA*Brave% = 0x00 /Else branch to END
00185f58: a4830000 sh r3,0x0000(r4)             |Set Current Ability YA = PA*Brave%
00185f5c: 24620001 addiu r2,r3,0x0001               |r2 = 0x01
00185f60: 080617de j 0x00185f78                     >>Jump to END
00185f64: a4820000 sh r2,0x0000(r4)                 |Set Current Ability YA = 0x01
00185f68: 3c028019 lui r2,0x8019            #Else : Weapon is not fists
00185f6c: 90423902 lbu r2,0x3902(r2)        |r2 = Current Ability used Weapon Power (WP)
00185f70: 3c018019 lui r1,0x8019            |
00185f74: a42238d0 sh r2,0x38d0(r1)         |Set Current Ability YA = WP
00185f78: 03e00008 jr r31
00185f7c: 00000000 nop

Return locations

Battle.bin
0018ac54:  64_Dmg_(PA_*_WP);_if_using_Spear_(PA_*_3/2_*_WP);_if_weaponless_(PA_*_Brave_/100_*_WP)