Base XA Calculation

From Final Fantasy Hacktics Wiki
Revision as of 12:41, 13 September 2015 by Raijinili (talk | contribs) (linking to call)
Jump to navigation Jump to search

Calculates and sets two values:

  • 0x801938ce: XA. The attacker's attack stat (before modification). PA for swords, (PA+MA)/2 for dictionaries, PA*Br/100 for Knightswords, etc. (This is the stat modified by support, status, Zodiac, etc.)
  • 0x801938d0: YA. The other stat. PA*Br/100 for fists, and WP otherwise.
Base XA Calculation (Weapons)
00185a9c: 3c028019 lui r2,0x8019
00185aa0: 904238d8 lbu r2,0x38d8(r2)           Load Used Weapon ID
00185aa4: 27bdffe8 addiu r29,r29,0xffe8
00185aa8: afbf0014 sw r31,0x0014(r29)
00185aac: afb00010 sw r16,0x0010(r29)
00185ab0: 00021840 sll r3,r2,0x01              ID * 2
00185ab4: 00621821 addu r3,r3,r2               ID * 3
00185ab8: 00031880 sll r3,r3,0x02              ID * 12
00185abc: 3c018006 lui r1,0x8006
00185ac0: 00230821 addu r1,r1,r3               80060000 + ID * 12
00185ac4: 90242ebd lbu r4,0x2ebd(r1)           Load Used Weapon Item Type
00185ac8: 3c028019 lui r2,0x8019
00185acc: 8c422d94 lw r2,0x2d94(r2)            Load Attacker's Data Pointer
00185ad0: 308300ff andi r3,r4,0x00ff           r3 = Used Weapon Item Type
00185ad4: 90500036 lbu r16,0x0036(r2)          Load Attacker's PA
00185ad8: 90460037 lbu r6,0x0037(r2)           Load Attacker's MA
00185adc: 90450024 lbu r5,0x0024(r2)           Load Attacker's Brave
00185ae0: 14600014 bne r3,r0,0x00185b34        Branch if a weapon is equipped
00185ae4: 00b00018 mult r5,r16                 Brave * PA
00185ae8: 00001812 mflo r3                     r3 = Brave * PA
00185aec: 3c0251eb lui r2,0x51eb
00185af0: 3442851f ori r2,r2,0x851f
00185af4: 00620018 mult r3,r2                  Brave * PA * 0.32
00185af8: 3c018019 lui r1,0x8019
00185afc: a43038ce sh r16,0x38ce(r1)           Store XA = PA
00185b00: 00031fc3 sra r3,r3,0x1f
00185b04: 00001010 mfhi r2                     r2 = Brave * PA * 0.32
00185b08: 00021143 sra r2,r2,0x05              Brave * PA * 0.32 / 32 (or Brave *  PA / 100)
00185b0c: 00431823 subu r3,r2,r3
00185b10: 00031400 sll r2,r3,0x10              Brave * PA / 100 * 65536
00185b14: 3c018019 lui r1,0x8019
00185b18: a42338d0 sh r3,0x38d0(r1)            Store YA = Brave * PA / 100
00185b1c: 14400058 bne r2,r0,0x00185c80        Branch if YA > 0
00185b20: 24620001 addiu r2,r3,0x0001          r2 = YA + 1 (minimum of 1 YA)
00185b24: 3c018019 lui r1,0x8019
00185b28: a42238d0 sh r2,0x38d0(r1)            Store YA = 1
00185b2c: 08061720 j 0x00185c80                Jump to end
00185b30: 00000000 nop
00185b34: 3c028019 lui r2,0x8019
00185b38: 90423902 lbu r2,0x3902(r2)           Load WP
00185b3c: 3c018019 lui r1,0x8019
00185b40: a42238d0 sh r2,0x38d0(r1)            YA = WP
00185b44: 34020003 ori r2,r0,0x0003            r2 = 3
00185b48: 10620007 beq r3,r2,0x00185b68        Branch if Used Weapon is a Sword
00185b4c: 3402000b ori r2,r0,0x000b            r2 = b
00185b50: 10620005 beq r3,r2,0x00185b68        Branch if Used Weapon is a Crossbow
00185b54: 34020007 ori r2,r0,0x0007            r2 = 7
00185b58: 10620003 beq r3,r2,0x00185b68        Branch if Used Weapon is a Rod
00185b5c: 3402000f ori r2,r0,0x000f            r2 = f
00185b60: 14620005 bne r3,r2,0x00185b78        Branch if Used Weapon is not a Polearm
00185b64: 2482ffff addiu r2,r4,0xffff          Used Weapon Type - 1
00185b68: 3c018019 lui r1,0x8019
00185b6c: a43038ce sh r16,0x38ce(r1)           Store XA = PA
00185b70: 08061720 j 0x00185c80                Jump to End
00185b74: 00000000 nop
00185b78: 2c420002 sltiu r2,r2,0x0002
00185b7c: 14400005 bne r2,r0,0x00185b94        Branch if Used Weapon is a  Knife/Ninja Blade
00185b80: 3402000c ori r2,r0,0x000c            r2 = c
00185b84: 10620003 beq r3,r2,0x00185b94        Branch if Used Weapon is a Bow
00185b88: 34020020 ori r2,r0,0x0020            r2 = 20
00185b8c: 14620007 bne r3,r2,0x00185bac        Branch if Used Weapon is not a  Thrown Weapon
00185b90: 2482fffc addiu r2,r4,0xfffc          Used Weapon Type - 4
00185b94: 3c028019 lui r2,0x8019
00185b98: 8c422d94 lw r2,0x2d94(r2)            Load Attacker's Data Pointer
00185b9c: 00000000 nop
00185ba0: 90420038 lbu r2,0x0038(r2)           Load Target's SP
00185ba4: 0806171d j 0x00185c74
00185ba8: 02021021 addu r2,r16,r2              PA + SP
00185bac: 2c420002 sltiu r2,r2,0x000 2
00185bb0: 10400010 beq r2,r0,0x00185bf4        Branch if Used Weapon is a Knight  Sword/Katana
00185bb4: 00b00018 mult r5,r16                 Brave * PA
00185bb8: 00001812 mflo r3                     r3 = Brave * PA
00185bbc: 3c0251eb lui r2,0x51eb
00185bc0: 3442851f ori r2,r2,0x851f
00185bc4: 00620018 mult r3,r2                  Brave * PA * 0.32
00185bc8: 00031fc3 sra r3,r3,0x1f
00185bcc: 00001010 mfhi r2                     r2 = Brave * PA * 0.32
00185bd0: 00021143 sra r2,r2,0x05              Brave * PA * 0.32 / 32 (or Brave *  PA / 100)
00185bd4: 00431823 subu r3,r2,r3
00185bd8: 3c018019 lui r1,0x8019
00185bdc: a42338ce sh r3,0x38ce(r1)            Store XA = Brave * PA / 100
00185be0: 00031400 sll r2,r3,0x10              Brave * PA / 100 * 65536
00185be4: 14400026 bne r2,r0,0x00185c80        Branch if XA > 0
00185be8: 24620001 addiu r2,r3,0x0001          r2 = XA + 1 (min XA of 1)
00185bec: 0806171e j 0x00185c78
00185bf0: 00000000 nop
00185bf4: 34020008 ori r2,r0,0x0008            r2 = 8
00185bf8: 10620003 beq r3,r2,0x00185c08        Branch if Used Weapon is a Staff
00185bfc: 34020010 ori r2,r0,0x0010            r2 = 10
00185c00: 14620005 bne r3,r2,0x00185c18        Branch if Used Weapon is not a Pole
00185c04: 34020006 ori r2,r0,0x0006            r2 = 6
00185c08: 3c018019 lui r1,0x8019
00185c0c: a42638ce sh r6,0x38ce(r1)            Store XA = MA
00185c10: 08061720 j 0x00185c80
00185c14: 00000000 nop
00185c18: 10620005 beq r3,r2,0x00185c30        Branch if Used Weapon is an Axe
00185c1c: 34020009 ori r2,r0,0x0009            r2 = 9
00185c20: 10620003 beq r3,r2,0x00185c30        Branch if Used Weapon is a Flail
00185c24: 34020011 ori r2,r0,0x0011            r2 = 11
00185c28: 1462000b bne r3,r2,0x00185c58        Branch if Used Weapon is not a Bag
00185c2c: 2482fff3 addiu r2,r4,0xfff3          r2 = Used Weapon Type - 13 (d)
00185c30: 0c063ba8 jal 0x0018eea0              r2 = -0x8000..+0x7fff
00185c34: 00000000 nop
00185c38: 02020018 mult r16,r2                 PA * 0->7fff
00185c3c: 00001012 mflo r2                     r2 = PA * Random
00185c40: 04410002 bgez r2,0x00185c4c          Branch if PA * Random >= 0
00185c44: 00000000 nop
00185c48: 24427fff addiu r2,r2,0x7fff          Make result positive
00185c4c: 000213c3 sra r2,r2,0x0f              PA * 0->7fff / 8000h (0->PA - 1)
00185c50: 0806171e j 0x00185c78
00185c54: 24420001 addiu r2,r2,0x0001          r2 += 1 (1->PA)
00185c58: 2c420002 sltiu r2,r2,0x0002
00185c5c: 14400004 bne r2,r0,0x00185c70        Branch if Used Weapon is not an Instrument/Book
00185c60: 30c200ff andi r2,r6,0x00ff           r2 = MA
00185c64: 34020012 ori r2,r0,0x0012            r2 = 12
00185c68: 14620005 bne r3,r2,0x00185c80        Branch if Used Weapon is not a Cloth
00185c6c: 30c200ff andi r2,r6,0x00ff           r2 = MA
00185c70: 02021021 addu r2,r16,r2              PA * MA
00185c74: 00021043 sra r2,r2,0x01              PA * ?? / 2 (MA or SP, depending on Weapon)
00185c78: 3c018019 lui r1,0x8019
00185c7c: a42238ce sh r2,0x38ce(r1)            Store XA = PA * ?? / 2
00185c80: 8fbf0014 lw r31,0x0014(r29)
00185c84: 8fb00010 lw r16,0x0010(r29)
00185c88: 27bd0018 addiu r29,r29,0x0018
00185c8c: 03e00008 jr r31
00185c90: 00000000 nop


Return Locations

  • Battle.bin
00188cb4: 05 Dmg_(Weapon)
00188d0c: 06 AbsHP_(Weapon)
00188d44: 07 Heal_(Weapon)
00189414: 1D Hit_(X)%
00188640: Weapon Damage Calculation
00188cb4: 
00188d0c:
00188d44:
00189414: