Difference between revisions of "Base XA Calculation"
Jump to navigation
Jump to search
m |
|||
Line 1: | Line 1: | ||
− | + | No parameters - Returns Nothing | |
− | + | ||
− | + | Sets Current Ability YA ( 0x801938d0 ) | |
− | + | - YA = Brave*PA if Weapon ID = 0x00 (fists) - Min value is 0x01 | |
− | + | - YA = Weapon Power (every others cases) | |
− | + | ||
− | + | Sets Current Ability XA (0x801938ce ) based on Weapon's Item Type (Weapon data 0x05) [[#Notes|See Notes]] | |
− | + | ------------------------------------------------------------------------------------------------ | |
− | + | 00185a9c: 3c028019 lui r2,0x8019 | | |
− | + | 00185aa0: 904238d8 lbu r2,0x38d8(r2) |{{f/load|<nowiki>r2 = Current Ability Used Weapon ID </nowiki>}} {{f/std| 0x801938d8}} | |
− | + | 00185aa4: 27bdffe8 addiu r29,r29,-0x0018 | | |
− | + | 00185aa8: afbf0014 sw r31,0x0014(r29) | | |
− | + | 00185aac: afb00010 sw r16,0x0010(r29) | | |
− | + | 00185ab0: 00021840 sll r3,r2,0x01 |{{f/std|Weapon ID * 2}} | |
− | + | 00185ab4: 00621821 addu r3,r3,r2 |{{f/std|Weapon ID * 3}} | |
− | + | 00185ab8: 00031880 sll r3,r3,0x02 |{{f/std|<nowiki>Weapon ID * 12 (0x0c = Size of Weapons data in Weapon Table)</nowiki>}} | |
− | + | 00185abc: 3c018006 lui r1,0x8006 | | |
− | + | 00185ac0: 00230821 addu r1,r1,r3 |{{f/std|<nowiki>r1 = 0x80060000 + Weapon offset</nowiki>}} | |
− | + | 00185ac4: 90242ebd lbu r4,0x2ebd(r1) |{{f/load|<nowiki>r4 = Used Weapon Type</nowiki>}} {{f/std| 0x80062eb8 + 0x05 + Weapon offset}} | |
− | + | 00185ac8: 3c028019 lui r2,0x8019 | | |
− | + | 00185acc: 8c422d94 lw r2,0x2d94(r2) |{{f/adr|<nowiki>r2 = Attacker data pointer</nowiki>}} | |
− | + | 00185ad0: 308300ff andi r3,r4,0x00ff |{{f/std|<nowiki>r3 = Use Weapon Type (byte)</nowiki>}} | |
− | + | 00185ad4: 90500036 lbu r16,0x0036(r2) |{{f/load|<nowiki>r16 = Attacker's PA</nowiki>}} | |
− | + | 00185ad8: 90460037 lbu r6,0x0037(r2) |{{f/load|<nowiki>r6 = Attacker's MA</nowiki>}} | |
− | + | 00185adc: 90450024 lbu r5,0x0024(r2) |{{f/load|<nowiki>r5 = Attacker's Brave</nowiki>}} | |
− | + | ||
− | + | {{f/loc| --- FISTS - YA Section --- }} | |
− | + | 00185ae0: 14600014 bne r3,r0,0x00185b34 {{f/Cond|<nowiki>If used Weapon ID = 0x00 (fists)</nowiki>}} | |
− | + | 00185ae4: 00b00018 mult r5,r16 |{{f/std|Brave * PA}} | |
− | + | 00185ae8: 00001812 mflo r3 |{{f/std|<nowiki>r3 = Attacker Brave * PA</nowiki>}} | |
− | + | 00185aec: 3c0251eb lui r2,0x51eb | | |
− | + | 00185af0: 3442851f ori r2,r2,0x851f |{{f/std|<nowiki>r2 = 0x51eb851f (0,32 * 2^32)</nowiki>}} | |
− | + | 00185af4: 00620018 mult r3,r2 |{{f/std|Brave * PA * 0.32 * 2^32}} | |
− | + | 00185af8: 3c018019 lui r1,0x8019 | | |
− | + | 00185afc: a43038ce sh r16,0x38ce(r1) |{{f/store|<nowiki>Store XA = PA</nowiki>}} | |
− | + | 00185b00: 00031fc3 sra r3,r3,0x1f |{{f/std|<nowiki>r3 = Higher bit of r3 (should be 0x00)</nowiki>}} | |
− | + | 00185b04: 00001010 mfhi r2 |{{f/std|<nowiki>r2 = Attacker Brave * PA * 32 / 100</nowiki>}} | |
− | + | 00185b08: 00021143 sra r2,r2,0x05 |{{f/std|<nowiki>r2 = Attacker Brave * PA / 100</nowiki>}} | |
− | + | 00185b0c: 00431823 subu r3,r2,r3 |{{f/std|<nowiki>r3 = Attacker Brave * PA / 100 (-0x00 or - 0x01)</nowiki>}} | |
− | + | 00185b10: 00031400 sll r2,r3,0x10 |{{f/std|Brave * PA / 100 * 65536}} | |
− | + | 00185b14: 3c018019 lui r1,0x8019 | | |
− | + | 00185b18: a42338d0 sh r3,0x38d0(r1) |{{f/store|Store Attacker's Brave*PA/100 in Current Ability YA}} {{f/std| 0x801938d0}} | |
− | + | 00185b1c: 14400058 bne r2,r0,0x00185c80 {{f/Cond|<nowiki>If YA = 0x00</nowiki>}} /Else branch to {{f/loc|END}} | |
− | + | 00185b20: 24620001 addiu r2,r3,0x0001 |{{f/std|<nowiki>r2 = YA + 1 (minimum of 1 YA)</nowiki>}} | |
− | + | 00185b24: 3c018019 lui r1,0x8019 | | |
− | + | 00185b28: a42238d0 sh r2,0x38d0(r1) |{{f/store|Store 0x01 in Ability YA (minimum value)}} | |
− | + | 00185b2c: 08061720 j 0x00185c80 {{f/jump|Jump to }} {{f/loc|END}} | |
− | + | 00185b30: 00000000 nop | | |
− | + | ||
− | + | {{f/loc| --- All Weapons - YA Section --- }} | |
− | + | 00185b34: 3c028019 lui r2,0x8019 |{{f/std|}} | |
− | + | 00185b38: 90423902 lbu r2,0x3902(r2) |{{f/load|<nowiki>r2 = Current Ability WP</nowiki>}} {{f/std| 0x80193902}} | |
− | + | 00185b3c: 3c018019 lui r1,0x8019 | | |
− | + | 00185b40: a42238d0 sh r2,0x38d0(r1) |{{f/store|Store WP in current Ability YA}} | |
− | + | ||
− | + | {{f/loc| --- SWORD - CROSSBOW - ROD - POLEARM - XA Section --- }} | |
− | + | 00185b44: 34020003 ori r2,r0,0x0003 |{{f/std|<nowiki>r2 = 0x03 (Sword Type flag)</nowiki>}} | |
− | + | 00185b48: 10620007 beq r3,r2,0x00185b68 {{f/Cond|If Weapon Type is not a Sword}} /Else Branch to Sword XA setting | |
− | + | 00185b4c: 3402000b ori r2,r0,0x000b |{{f/std|<nowiki>r2 = 0x0b (Crossbow type)</nowiki>}} | |
− | + | 00185b50: 10620005 beq r3,r2,0x00185b68 {{f/Cond|If Used Weapon is not a crossbow}} /Else Branch to Crossbow XA setting | |
− | + | 00185b54: 34020007 ori r2,r0,0x0007 |{{f/std|<nowiki>r2 = 0x07 (Rod Type)</nowiki>}} | |
− | + | 00185b58: 10620003 beq r3,r2,0x00185b68 {{f/Cond|If Used Weapon is not a Rod}} /Else Branch to Crossbow XA setting | |
− | + | 00185b5c: 3402000f ori r2,r0,0x000f |{{f/std|<nowiki>r2 = f</nowiki>}} {{f/std|<nowiki>r2 = 0x0f (Polearm type)</nowiki>}} | |
− | + | 00185b60: 14620005 bne r3,r2,0x00185b78 {{f/Cond|If Weapon is a Polearm}} /Else Avoid the [Sword - Crossbow - Rod - Polearm] Section | |
− | + | 00185b64: 2482ffff addiu r2,r4,-0x0001 |{{f/std|<nowiki>r2 = Used weapon Type - 0x01</nowiki>}} | |
− | + | 00185b68: 3c018019 lui r1,0x8019 {{f/Cond|E }} {{f/Cond|E }} {{f/Cond|E }} | | |
− | + | 00185b6c: a43038ce sh r16,0x38ce(r1) |{{f/store|Store Attacker PA as XA}} {{f/std| 0x801938ce}} | |
− | + | 00185b70: 08061720 j 0x00185c80 {{f/jump|Jump to}} {{f/loc|END}} | |
− | + | 00185b74: 00000000 nop | | |
− | + | ||
− | + | {{f/loc| --- KNIFE - NINJA BLADE - BOW - THROWN - XA Section --- }} | |
− | + | 00185b78: 2c420002 sltiu r2,r2,0x0002 |{{f/std|<nowiki>r2 = 0x01 if Weapon Type is Knife or Ninja blade</nowiki>}} | |
− | + | 00185b7c: 14400005 bne r2,r0,0x00185b94 {{f/Cond|If Used Weapon is not a Knife/Ninja Blade}} /Else Branch to Knives - Ninja Blade XA setting | |
− | + | 00185b80: 3402000c ori r2,r0,0x000c |{{f/std|<nowiki>r2 = 0x0c (Bow Type flag)</nowiki>}} | |
− | + | 00185b84: 10620003 beq r3,r2,0x00185b94 {{f/Cond|If Used Weapon is not a Bow}} /Else Branch to Bow XA setting | |
− | + | 00185b88: 34020020 ori r2,r0,0x0020 |{{f/std|<nowiki>r2 = 0x20 (Thrown xeapon Type)</nowiki>}} | |
− | + | 00185b8c: 14620007 bne r3,r2,0x00185bac {{f/Cond|If Used Weapon is a Thrown Weapon (Stay)}} /Else Avoid the [Knife - Ninja blade - Bow - Thrown] Section | |
− | + | 00185b90: 2482fffc addiu r2,r4,-0x0004 |{{f/std|<nowiki>r2 = Used weapon Type - 0x04</nowiki>}} | |
− | + | 00185b94: 3c028019 lui r2,0x8019 {{f/Cond|E }} {{f/Cond|E }} | | |
− | + | 00185b98: 8c422d94 lw r2,0x2d94(r2) |{{f/adr|<nowiki>r2 = Attacker's Data Pointer</nowiki>}} | |
− | + | 00185b9c: 00000000 nop | | |
− | + | 00185ba0: 90420038 lbu r2,0x0038(r2) |{{f/load|Load Target's SP}} {{f/load|<nowiki>r2 = Attacker's speed</nowiki>}} | |
− | + | 00185ba4: 0806171d j 0x00185c74 {{f/jump|jumps to }} {{f/loc|nearly END}} Will Store (PA+Sp)/2 as XA | |
− | + | 00185ba8: 02021021 addu r2,r16,r2 |{{f/std|<nowiki>r2 = Attackers PA + Speed</nowiki>}} | |
− | + | ||
− | + | {{f/loc| --- KNIGHT SWORD - KATANA - XA Section --- }} | |
− | + | 00185bac: 2c420002 sltiu r2,r2,0x0002 |{{f/std|<nowiki>r2 = 0x01 If Used Weapon Type is Knight's sword or Katana</nowiki>}} | |
− | + | 00185bb0: 10400010 beq r2,r0,0x00185bf4 {{f/Cond|Branch if Used Weapon is a Knight Sword/Katana}} /Else go to next section | |
− | + | 00185bb4: 00b00018 mult r5,r16 |{{f/std|Attacker Brave * PA}} | |
− | + | 00185bb8: 00001812 mflo r3 |{{f/std|<nowiki>r3 = Attacker Brave * PA</nowiki>}} | |
− | + | 00185bbc: 3c0251eb lui r2,0x51eb | | |
− | + | 00185bc0: 3442851f ori r2,r2,0x851f |{{f/std|<nowiki>r2 = 0,32*2^32</nowiki>}} | |
− | + | 00185bc4: 00620018 mult r3,r2 |{{f/std|Brave * PA * 0.32 * 2^32}} | |
− | + | 00185bc8: 00031fc3 sra r3,r3,0x1f |{{f/std|<nowiki>r3 = Higher bit of r3 (should be 0x00)</nowiki>}} | |
− | + | 00185bcc: 00001010 mfhi r2 |{{f/std|<nowiki>r2 = Brave * PA * 0.32</nowiki>}} | |
− | + | 00185bd0: 00021143 sra r2,r2,0x05 |{{f/std|<nowiki>r2 = Attacker Brave * PA / 100</nowiki>}} | |
− | + | 00185bd4: 00431823 subu r3,r2,r3 | | |
− | + | 00185bd8: 3c018019 lui r1,0x8019 | | |
− | + | 00185bdc: a42338ce sh r3,0x38ce(r1) |{{f/store|<nowiki>Store Current Ability XA = Brave * PA / 100</nowiki>}} {{f/std| 0x801938ce}} | |
− | + | 00185be0: 00031400 sll r2,r3,0x10 |{{f/std|<nowiki>r2 = XA * 2^16 (clear upper register keeping the halfword only ?)</nowiki>}} | |
− | + | 00185be4: 14400026 bne r2,r0,0x00185c80 {{f/Cond|<nowiki>If XA = 0x00</nowiki>}} /Else branch to {{f/loc|END}} | |
− | + | 00185be8: 24620001 addiu r2,r3,0x0001 |{{f/std|<nowiki>r2 = XA + 1 (min XA of 1)</nowiki>}} | |
− | + | 00185bec: 0806171e j 0x00185c78 {{f/jump|Jump to Store XA (near END)}} | |
− | + | 00185bf0: 00000000 nop | | |
− | + | ||
− | + | {{f/loc| --- STAFF - POLE - XA Section --- }} | |
− | + | 00185bf4: 34020008 ori r2,r0,0x0008 |{{f/std|<nowiki>r2 = 0x08 (Staff type flag)</nowiki>}} | |
− | + | 00185bf8: 10620003 beq r3,r2,0x00185c08 {{f/Cond|If Used Weapon is not a Staff}} /Else Branch to Staff section | |
− | + | 00185bfc: 34020010 ori r2,r0,0x0010 |{{f/std|<nowiki>r2 = 0x10 (Pole Type flag)</nowiki>}} | |
− | + | 00185c00: 14620005 bne r3,r2,0x00185c18 {{f/Cond|If Used Weapon is a Pole}} /Else Avoid next section | |
− | + | 00185c04: 34020006 ori r2,r0,0x0006 |{{f/std|<nowiki>r2 = 0x06 (Axe type flag)</nowiki>}} | |
− | + | 00185c08: 3c018019 lui r1,0x8019 {{f/Cond|E }} | | |
− | + | 00185c0c: a42638ce sh r6,0x38ce(r1) |{{f/store|Store Attacker's MA as Ability XA}} {{f/std| 0x801938ce}} | |
− | + | 00185c10: 08061720 j 0x00185c80 {{f/jump|Jump to }} {{f/loc|END}} | |
− | + | 00185c14: 00000000 nop | | |
− | + | ||
− | + | {{f/loc| --- AXE - FLAIL - BAG - XA Section --- }} | |
− | + | 00185c18: 10620005 beq r3,r2,0x00185c30 {{f/Cond|If Used Weapon is not an Axe}} /Else branch to Axe section | |
− | + | 00185c1c: 34020009 ori r2,r0,0x0009 |{{f/std|<nowiki>r2 = 0x09 (Flail Type flag)</nowiki>}} | |
− | + | 00185c20: 10620003 beq r3,r2,0x00185c30 {{f/Cond|If Used Weapon is not a Flail}} /Else branch to Flail section | |
− | + | 00185c24: 34020011 ori r2,r0,0x0011 |{{f/std|<nowiki>r2 = 0x11 (Bag Type flag)</nowiki>}} | |
− | + | 00185c28: 1462000b bne r3,r2,0x00185c58 {{f/Cond|If Used Weapon is a Bag}} /Else Avoid next section | |
− | + | 00185c2c: 2482fff3 addiu r2,r4,-0x000d |{{f/std|<nowiki>r2 = Used Weapon Type - 0x0d</nowiki>}} | |
− | + | 00185c30: 0c063ba8 jal 0x0018eea0 {{f/Cond|E }} {{f/Cond|E }} | {{f/jal|Random_Process,_gives_a_number_between_0-7fff|Random_Process,_gives_a_number_between_0-7fff}} Returns r2 between 0x00 and 0x7fff | |
− | + | 00185c34: 00000000 nop | | |
− | + | 00185c38: 02020018 mult r16,r2 |{{f/std|Attacker's PA * Random}} | |
− | 00185c80: 8fbf0014 lw r31,0x0014(r29) | + | 00185c3c: 00001012 mflo r2 |{{f/std|<nowiki>r2 = PA * Random</nowiki>}} |
− | 00185c84: 8fb00010 lw r16,0x0010(r29) | + | 00185c40: 04410002 bgez r2,0x00185c4c {{f/Cond|If PA * Random < 0x00}} |
− | 00185c88: 27bd0018 addiu r29,r29,0x0018 | + | 00185c44: 00000000 nop | |
− | 00185c8c: 03e00008 jr r31 | + | 00185c48: 24427fff addiu r2,r2,0x7fff |{{f/std|Make result positive}} |
+ | 00185c4c: 000213c3 sra r2,r2,0x0f |{{f/std|<nowiki>r2 = Random between 0x00 and PA ( = PA * Random/[Max Possible Random+1] )</nowiki>}} | ||
+ | 00185c50: 0806171e j 0x00185c78 {{f/jump|Jump to Store XA (Random between 0x01 and PA)}} | ||
+ | 00185c54: 24420001 addiu r2,r2,0x0001 |{{f/std|<nowiki>r2 = Random Between 0x01 and PA</nowiki>}} | ||
+ | |||
+ | {{f/loc| --- INSTRUMENT - BOOK - CLOTH - XA Section --- }} | ||
+ | 00185c58: 2c420002 sltiu r2,r2,0x0002 |{{f/std|<nowiki>r2 = 0x01 if used weapon Type is instrument or book</nowiki>}} | ||
+ | 00185c5c: 14400004 bne r2,r0,0x00185c70 {{f/Cond|If Used Weapon is not an Instrument/Book}} /Else Branch to MA+PA | ||
+ | 00185c60: 30c200ff andi r2,r6,0x00ff |{{f/std|<nowiki>r2 = Attacker's MA (byte)</nowiki>}} | ||
+ | 00185c64: 34020012 ori r2,r0,0x0012 |{{f/std|<nowiki>r2 = 0x12 (Cloth Type flag)</nowiki>}} | ||
+ | 00185c68: 14620005 bne r3,r2,0x00185c80 {{f/Cond|If Used Weapon is a Cloth}} /Else Branch to END (no XA here for Guns) | ||
+ | 00185c6c: 30c200ff andi r2,r6,0x00ff |{{f/std|<nowiki>r2 = Attacker's MA (byte)</nowiki>}} | ||
+ | 00185c70: 02021021 addu r2,r16,r2 {{f/Cond|E }} |{{f/std|<nowiki>r2 = Attacker's MA + PA</nowiki>}} | ||
+ | 00185c74: 00021043 sra r2,r2,0x01 >j | {{f/std|<nowiki>r2 = Pre-Xa/2 (MA+PA or PA+Speed)</nowiki>}} | ||
+ | 00185c78: 3c018019 lui r1,0x8019 >j | | ||
+ | 00185c7c: a42238ce sh r2,0x38ce(r1) |{{f/store|Store r2 as Ability XA}} {{f/std| 0x801938ce}} | ||
+ | 00185c80: 8fbf0014 lw r31,0x0014(r29) END | ||
+ | 00185c84: 8fb00010 lw r16,0x0010(r29) | ||
+ | 00185c88: 27bd0018 addiu r29,r29,0x0018 | ||
+ | 00185c8c: 03e00008 jr r31 | ||
00185c90: 00000000 nop | 00185c90: 00000000 nop | ||
− | + | === Notes === | |
− | + | ''' XA values''' | |
+ | 0x01 - Knife : XA = (PA+Speed)/2 | ||
+ | 0x02 - Ninja Blade : XA = (PA+Speed)/2 | ||
+ | 0x03 - Sword : XA = PA | ||
+ | 0x04 - Knight Sword : XA = (Brave*PA)/100 | ||
+ | 0x05 - Katana : XA = (Brave*PA)/100 | ||
+ | 0x06 - Axe : XA = random (from 0x01 to PA) | ||
+ | 0x07 - Rod : XA = PA | ||
+ | 0x08 - Staff : XA = MA | ||
+ | 0x09 - Flail : XA = random (from 0x01 to PA) | ||
+ | 0x0a - Gun --- | ||
+ | 0x0b - Crossbow : XA = PA | ||
+ | 0x0c - Bow : XA = (PA+Speed)/2 | ||
+ | 0x0d - Instrument : XA = (MA + PA)/2 | ||
+ | 0x0e - Book : XA = (MA + PA)/2 | ||
+ | 0x0f - Polearm : XA = PA | ||
+ | 0x10 - Pole : XA = MA | ||
+ | 0x11 - Bag : XA = random (from 0x01 to PA) | ||
+ | 0x12 - Cloth : XA = (MA + PA)/2 | ||
+ | ... | ||
+ | 0x20 - Thrown weapon : XA = (PA+Speed)/2 | ||
=== Return Locations === | === Return Locations === | ||
'''Battle.bin''' | '''Battle.bin''' |
Revision as of 14:15, 26 March 2022
No parameters - Returns Nothing Sets Current Ability YA ( 0x801938d0 ) - YA = Brave*PA if Weapon ID = 0x00 (fists) - Min value is 0x01 - YA = Weapon Power (every others cases) Sets Current Ability XA (0x801938ce ) based on Weapon's Item Type (Weapon data 0x05) See Notes ------------------------------------------------------------------------------------------------ 00185a9c: 3c028019 lui r2,0x8019 | 00185aa0: 904238d8 lbu r2,0x38d8(r2) |r2 = Current Ability Used Weapon ID 0x801938d8 00185aa4: 27bdffe8 addiu r29,r29,-0x0018 | 00185aa8: afbf0014 sw r31,0x0014(r29) | 00185aac: afb00010 sw r16,0x0010(r29) | 00185ab0: 00021840 sll r3,r2,0x01 |Weapon ID * 2 00185ab4: 00621821 addu r3,r3,r2 |Weapon ID * 3 00185ab8: 00031880 sll r3,r3,0x02 |Weapon ID * 12 (0x0c = Size of Weapons data in Weapon Table) 00185abc: 3c018006 lui r1,0x8006 | 00185ac0: 00230821 addu r1,r1,r3 |r1 = 0x80060000 + Weapon offset 00185ac4: 90242ebd lbu r4,0x2ebd(r1) |r4 = Used Weapon Type 0x80062eb8 + 0x05 + Weapon offset 00185ac8: 3c028019 lui r2,0x8019 | 00185acc: 8c422d94 lw r2,0x2d94(r2) |r2 = Attacker data pointer 00185ad0: 308300ff andi r3,r4,0x00ff |r3 = Use Weapon Type (byte) 00185ad4: 90500036 lbu r16,0x0036(r2) |r16 = Attacker's PA 00185ad8: 90460037 lbu r6,0x0037(r2) |r6 = Attacker's MA 00185adc: 90450024 lbu r5,0x0024(r2) |r5 = Attacker's Brave --- FISTS - YA Section --- 00185ae0: 14600014 bne r3,r0,0x00185b34 #If used Weapon ID = 0x00 (fists) 00185ae4: 00b00018 mult r5,r16 |Brave * PA 00185ae8: 00001812 mflo r3 |r3 = Attacker Brave * PA 00185aec: 3c0251eb lui r2,0x51eb | 00185af0: 3442851f ori r2,r2,0x851f |r2 = 0x51eb851f (0,32 * 2^32) 00185af4: 00620018 mult r3,r2 |Brave * PA * 0.32 * 2^32 00185af8: 3c018019 lui r1,0x8019 | 00185afc: a43038ce sh r16,0x38ce(r1) |Store XA = PA 00185b00: 00031fc3 sra r3,r3,0x1f |r3 = Higher bit of r3 (should be 0x00) 00185b04: 00001010 mfhi r2 |r2 = Attacker Brave * PA * 32 / 100 00185b08: 00021143 sra r2,r2,0x05 |r2 = Attacker Brave * PA / 100 00185b0c: 00431823 subu r3,r2,r3 |r3 = Attacker Brave * PA / 100 (-0x00 or - 0x01) 00185b10: 00031400 sll r2,r3,0x10 |Brave * PA / 100 * 65536 00185b14: 3c018019 lui r1,0x8019 | 00185b18: a42338d0 sh r3,0x38d0(r1) |Store Attacker's Brave*PA/100 in Current Ability YA 0x801938d0 00185b1c: 14400058 bne r2,r0,0x00185c80 #If YA = 0x00 /Else branch to END 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 0x01 in Ability YA (minimum value) 00185b2c: 08061720 j 0x00185c80 >>Jump to END 00185b30: 00000000 nop | --- All Weapons - YA Section --- 00185b34: 3c028019 lui r2,0x8019 | 00185b38: 90423902 lbu r2,0x3902(r2) |r2 = Current Ability WP 0x80193902 00185b3c: 3c018019 lui r1,0x8019 | 00185b40: a42238d0 sh r2,0x38d0(r1) |Store WP in current Ability YA --- SWORD - CROSSBOW - ROD - POLEARM - XA Section --- 00185b44: 34020003 ori r2,r0,0x0003 |r2 = 0x03 (Sword Type flag) 00185b48: 10620007 beq r3,r2,0x00185b68 #If Weapon Type is not a Sword /Else Branch to Sword XA setting 00185b4c: 3402000b ori r2,r0,0x000b |r2 = 0x0b (Crossbow type) 00185b50: 10620005 beq r3,r2,0x00185b68 #If Used Weapon is not a crossbow /Else Branch to Crossbow XA setting 00185b54: 34020007 ori r2,r0,0x0007 |r2 = 0x07 (Rod Type) 00185b58: 10620003 beq r3,r2,0x00185b68 #If Used Weapon is not a Rod /Else Branch to Crossbow XA setting 00185b5c: 3402000f ori r2,r0,0x000f |r2 = f r2 = 0x0f (Polearm type) 00185b60: 14620005 bne r3,r2,0x00185b78 #If Weapon is a Polearm /Else Avoid the [Sword - Crossbow - Rod - Polearm] Section 00185b64: 2482ffff addiu r2,r4,-0x0001 |r2 = Used weapon Type - 0x01 00185b68: 3c018019 lui r1,0x8019 #E #E #E | 00185b6c: a43038ce sh r16,0x38ce(r1) |Store Attacker PA as XA 0x801938ce 00185b70: 08061720 j 0x00185c80 >>Jump to END 00185b74: 00000000 nop | --- KNIFE - NINJA BLADE - BOW - THROWN - XA Section --- 00185b78: 2c420002 sltiu r2,r2,0x0002 |r2 = 0x01 if Weapon Type is Knife or Ninja blade 00185b7c: 14400005 bne r2,r0,0x00185b94 #If Used Weapon is not a Knife/Ninja Blade /Else Branch to Knives - Ninja Blade XA setting 00185b80: 3402000c ori r2,r0,0x000c |r2 = 0x0c (Bow Type flag) 00185b84: 10620003 beq r3,r2,0x00185b94 #If Used Weapon is not a Bow /Else Branch to Bow XA setting 00185b88: 34020020 ori r2,r0,0x0020 |r2 = 0x20 (Thrown xeapon Type) 00185b8c: 14620007 bne r3,r2,0x00185bac #If Used Weapon is a Thrown Weapon (Stay) /Else Avoid the [Knife - Ninja blade - Bow - Thrown] Section 00185b90: 2482fffc addiu r2,r4,-0x0004 |r2 = Used weapon Type - 0x04 00185b94: 3c028019 lui r2,0x8019 #E #E | 00185b98: 8c422d94 lw r2,0x2d94(r2) |r2 = Attacker's Data Pointer 00185b9c: 00000000 nop | 00185ba0: 90420038 lbu r2,0x0038(r2) |Load Target's SP r2 = Attacker's speed 00185ba4: 0806171d j 0x00185c74 >>jumps to nearly END Will Store (PA+Sp)/2 as XA 00185ba8: 02021021 addu r2,r16,r2 |r2 = Attackers PA + Speed --- KNIGHT SWORD - KATANA - XA Section --- 00185bac: 2c420002 sltiu r2,r2,0x0002 |r2 = 0x01 If Used Weapon Type is Knight's sword or Katana 00185bb0: 10400010 beq r2,r0,0x00185bf4 #Branch if Used Weapon is a Knight Sword/Katana /Else go to next section 00185bb4: 00b00018 mult r5,r16 |Attacker Brave * PA 00185bb8: 00001812 mflo r3 |r3 = Attacker Brave * PA 00185bbc: 3c0251eb lui r2,0x51eb | 00185bc0: 3442851f ori r2,r2,0x851f |r2 = 0,32*2^32 00185bc4: 00620018 mult r3,r2 |Brave * PA * 0.32 * 2^32 00185bc8: 00031fc3 sra r3,r3,0x1f |r3 = Higher bit of r3 (should be 0x00) 00185bcc: 00001010 mfhi r2 |r2 = Brave * PA * 0.32 00185bd0: 00021143 sra r2,r2,0x05 |r2 = Attacker Brave * PA / 100 00185bd4: 00431823 subu r3,r2,r3 | 00185bd8: 3c018019 lui r1,0x8019 | 00185bdc: a42338ce sh r3,0x38ce(r1) |Store Current Ability XA = Brave * PA / 100 0x801938ce 00185be0: 00031400 sll r2,r3,0x10 |r2 = XA * 2^16 (clear upper register keeping the halfword only ?) 00185be4: 14400026 bne r2,r0,0x00185c80 #If XA = 0x00 /Else branch to END 00185be8: 24620001 addiu r2,r3,0x0001 |r2 = XA + 1 (min XA of 1) 00185bec: 0806171e j 0x00185c78 >>Jump to Store XA (near END) 00185bf0: 00000000 nop | --- STAFF - POLE - XA Section --- 00185bf4: 34020008 ori r2,r0,0x0008 |r2 = 0x08 (Staff type flag) 00185bf8: 10620003 beq r3,r2,0x00185c08 #If Used Weapon is not a Staff /Else Branch to Staff section 00185bfc: 34020010 ori r2,r0,0x0010 |r2 = 0x10 (Pole Type flag) 00185c00: 14620005 bne r3,r2,0x00185c18 #If Used Weapon is a Pole /Else Avoid next section 00185c04: 34020006 ori r2,r0,0x0006 |r2 = 0x06 (Axe type flag) 00185c08: 3c018019 lui r1,0x8019 #E | 00185c0c: a42638ce sh r6,0x38ce(r1) |Store Attacker's MA as Ability XA 0x801938ce 00185c10: 08061720 j 0x00185c80 >>Jump to END 00185c14: 00000000 nop | --- AXE - FLAIL - BAG - XA Section --- 00185c18: 10620005 beq r3,r2,0x00185c30 #If Used Weapon is not an Axe /Else branch to Axe section 00185c1c: 34020009 ori r2,r0,0x0009 |r2 = 0x09 (Flail Type flag) 00185c20: 10620003 beq r3,r2,0x00185c30 #If Used Weapon is not a Flail /Else branch to Flail section 00185c24: 34020011 ori r2,r0,0x0011 |r2 = 0x11 (Bag Type flag) 00185c28: 1462000b bne r3,r2,0x00185c58 #If Used Weapon is a Bag /Else Avoid next section 00185c2c: 2482fff3 addiu r2,r4,-0x000d |r2 = Used Weapon Type - 0x0d 00185c30: 0c063ba8 jal 0x0018eea0 #E #E | -->Random_Process,_gives_a_number_between_0-7fff Returns r2 between 0x00 and 0x7fff 00185c34: 00000000 nop | 00185c38: 02020018 mult r16,r2 |Attacker's PA * Random 00185c3c: 00001012 mflo r2 |r2 = PA * Random 00185c40: 04410002 bgez r2,0x00185c4c #If PA * Random < 0x00 00185c44: 00000000 nop | 00185c48: 24427fff addiu r2,r2,0x7fff |Make result positive 00185c4c: 000213c3 sra r2,r2,0x0f |r2 = Random between 0x00 and PA ( = PA * Random/[Max Possible Random+1] ) 00185c50: 0806171e j 0x00185c78 >>Jump to Store XA (Random between 0x01 and PA) 00185c54: 24420001 addiu r2,r2,0x0001 |r2 = Random Between 0x01 and PA --- INSTRUMENT - BOOK - CLOTH - XA Section --- 00185c58: 2c420002 sltiu r2,r2,0x0002 |r2 = 0x01 if used weapon Type is instrument or book 00185c5c: 14400004 bne r2,r0,0x00185c70 #If Used Weapon is not an Instrument/Book /Else Branch to MA+PA 00185c60: 30c200ff andi r2,r6,0x00ff |r2 = Attacker's MA (byte) 00185c64: 34020012 ori r2,r0,0x0012 |r2 = 0x12 (Cloth Type flag) 00185c68: 14620005 bne r3,r2,0x00185c80 #If Used Weapon is a Cloth /Else Branch to END (no XA here for Guns) 00185c6c: 30c200ff andi r2,r6,0x00ff |r2 = Attacker's MA (byte) 00185c70: 02021021 addu r2,r16,r2 #E |r2 = Attacker's MA + PA 00185c74: 00021043 sra r2,r2,0x01 >j | r2 = Pre-Xa/2 (MA+PA or PA+Speed) 00185c78: 3c018019 lui r1,0x8019 >j | 00185c7c: a42238ce sh r2,0x38ce(r1) |Store r2 as Ability XA 0x801938ce 00185c80: 8fbf0014 lw r31,0x0014(r29) END 00185c84: 8fb00010 lw r16,0x0010(r29) 00185c88: 27bd0018 addiu r29,r29,0x0018 00185c8c: 03e00008 jr r31 00185c90: 00000000 nop
Notes
XA values 0x01 - Knife : XA = (PA+Speed)/2 0x02 - Ninja Blade : XA = (PA+Speed)/2 0x03 - Sword : XA = PA 0x04 - Knight Sword : XA = (Brave*PA)/100 0x05 - Katana : XA = (Brave*PA)/100 0x06 - Axe : XA = random (from 0x01 to PA) 0x07 - Rod : XA = PA 0x08 - Staff : XA = MA 0x09 - Flail : XA = random (from 0x01 to PA) 0x0a - Gun --- 0x0b - Crossbow : XA = PA 0x0c - Bow : XA = (PA+Speed)/2 0x0d - Instrument : XA = (MA + PA)/2 0x0e - Book : XA = (MA + PA)/2 0x0f - Polearm : XA = PA 0x10 - Pole : XA = MA 0x11 - Bag : XA = random (from 0x01 to PA) 0x12 - Cloth : XA = (MA + PA)/2 ... 0x20 - Thrown weapon : XA = (PA+Speed)/2
Return Locations
Battle.bin 00188648: Weapon Damage Calculation 00188cbc: 05 Dmg_(Weapon) 00188d14: 06 AbsHP_(Weapon) 00188d4c: 07 Heal_(Weapon) 0018941c: 1D Hit_(X)%