Difference between revisions of "Calculate Final Hit %"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
  Calculate Final Hit %
+
  No Parameters - Returns nothing
  00185814: 3c028019 lui r2,0x8019
+
   
  00185818: 944238d6 lhu r2,0x38d6(r2) Load Used Ability ID
+
  '''If Ability flag [Evadeable] is Off : skip the whole routine'''
  0018581c: 27bdffe0 addiu r29,r29,0xffe0
+
  This routine Will set the value of the displayed Hit%
  00185820: afbf0018 sw r31,0x0018(r29)
+
  - Forced to 0x00 if Any Current Ability Evade data is greater than base hit value
  00185824: afb10014 sw r17,0x0014(r29)
+
  - If Attack might succeed : Hit% is calculated in the central math section
00185828: 10400007 beq r2,r0,0x00185848 Branch if Attack
+
  Last part of the routine Roll Each Evade type against Current Ability Base Hit (That's why halving base Hit = doubling all evasion type (cf Defend mechanics))
0018582c: afb00010 sw r16,0x0010(r29)
+
  '''Update Target current action 0x2a (Hit%) and if Evaded then update Target current action 0x00 (Hit flag) 0x02 (Evade Type) and 0x03 (Used Item for evasion)'''
  00185830: 3c028019 lui r2,0x8019
+
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------
00185834: 904238f6 lbu r2,0x38f6(r2) Load 4th set of Ability Flags
+
  00185814: 3c028019 lui r2,0x8019           |
00185838: 00000000 nop
+
  00185818: 944238d6 lhu r2,0x38d6(r2)       |{{f/load|<nowiki>r2 = Current Ability : used Ability ID</nowiki>}} {{f/std| 0x801938d6}}
0018583c: 30420002 andi r2,r2,0x0002
+
  0018581c: 27bdffe0 addiu r29,r29,-0x020    |
00185840: 10400090 beq r2,r0,0x00185a84 Branch if Not Evadeable
+
  00185820: afbf0018 sw r31,0x0018(r29)      |
00185844: 00000000 nop
+
  00185824: afb10014 sw r17,0x0014(r29)      |
00185848: 3c088019 lui r8,0x8019
+
  00185828: 10400007 beq r2,r0,0x00185848    {{f/Cond|If used Ability is not a standard Attack}}
0018584c: 910838dc lbu r8,0x38dc(r8) Load Hit %
+
  0018582c: afb00010 sw r16,0x0010(r29)           |
00185850: 3c038019 lui r3,0x8019
+
  00185830: 3c028019 lui r2,0x8019                |
00185854: 906338de lbu r3,0x38de(r3) Load Accessory Evade
+
  00185834: 904238f6 lbu r2,0x38f6(r2)            |{{f/load|<nowiki>r2 = Current Ability flags 4</nowiki>}} {{f/std| 0x801938f6}}
00185858: 310500ff andi r5,r8,0x00ff
+
00185838: 00000000 nop                         |
0018585c: 0065102b sltu r2,r3,r5
+
  0018583c: 30420002 andi r2,r2,0x0002            |{{f/std|<nowiki>r2 = 0x02 if Ability is Evadable</nowiki>}}
00185860: 10400013 beq r2,r0,0x001858b0 Branch if Accessory Evade >= Hit %
+
  00185840: 10400090 beq r2,r0,0x00185a84        {{f/Cond|Branch to }} {{f/loc|END}} '''if Ability is not Evadable'''
  00185864: 01008021 addu r16,r8,r0
+
  00185844: 00000000 nop                            
00185868: 3c048019 lui r4,0x8019
+
  00185848: 3c088019 lui r8,0x8019            |{{f/std|}}
  0018586c: 908438df lbu r4,0x38df(r4) Load RH Evade
+
  0018584c: 910838dc lbu r8,0x38dc(r8)        |{{f/load|<nowiki>r8 = Current ability base Hit</nowiki>}} {{f/std| 0x801938dc}}
00185870: 00000000 nop
+
  00185850: 3c038019 lui r3,0x8019           |
  00185874: 0085102b sltu r2,r4,r5
+
  00185854: 906338de lbu r3,0x38de(r3)       |{{f/load|<nowiki>r3 = Current Ability Accessory Evade</nowiki>}} {{f/std| 0x801938de}}
  00185878: 1040000d beq r2,r0,0x001858b0 Branch if RH Evade >= Hit %
+
  00185858: 310500ff andi r5,r8,0x00ff        |{{f/std|<nowiki>r5 = Base Hit (byte)</nowiki>}}
  0018587c: 00000000 nop
+
  0018585c: 0065102b sltu r2,r3,r5            |{{f/std|<nowiki>r2 = 0x01 if Accessory Evade < Base Hit</nowiki>}}
  00185880: 3c068019 lui r6,0x8019
+
  00185860: 10400013 beq r2,r0,0x001858b0    {{f/Cond|If Base Hit > Accessory Evade}} /Else branch (Attack Evaded without maths)
  00185884: 90c638e0 lbu r6,0x38e0(r6) Load LH Evade
+
  00185864: 01008021 addu r16,r8,r0          |{{f/std|<nowiki>r16 = Base Hit % (Keep original value)</nowiki>}}
  00185888: 00000000 nop
+
  00185868: 3c048019 lui r4,0x8019                |{{f/std|}}
  0018588c: 00c5102b sltu r2,r6,r5
+
  0018586c: 908438df lbu r4,0x38df(r4)            |{{f/load|<nowiki>r4 = Current Ability Right Hand Evade</nowiki>}} {{f/std| 0x801938df}}
00185890: 10400007 beq r2,r0,0x001858b0 Branch if LH Evade >= Hit %
+
  00185870: 00000000 nop                          |
  00185894: 00000000 nop
+
  00185874: 0085102b sltu r2,r4,r5               |{{f/std|<nowiki>r2 = 0x01 if Right Hand Evade < Base Hit</nowiki>}}
  00185898: 3c078019 lui r7,0x8019
+
  00185878: 1040000d beq r2,r0,0x001858b0        {{f/Cond|If Base Hit > Right Hand Evade}} /Else branch (Attack Evaded without maths)
  0018589c: 90e738e1 lbu r7,0x38e1(r7) Load Class Evade
+
  0018587c: 00000000 nop                              |{{f/std|}}
  001858a0: 00000000 nop
+
  00185880: 3c068019 lui r6,0x8019                    |{{f/std|}}
  001858a4: 00e5102b sltu r2,r7,r5
+
  00185884: 90c638e0 lbu r6,0x38e0(r6)                |{{f/load|<nowiki>r6 = Current Ability Left Hand Evade</nowiki>}} {{f/std| 0x801938e0}}
  001858a8: 14400009 bne r2,r0,0x001858d0 Branch if Class Evade < Hit %
+
  00185888: 00000000 nop                              |
001858ac: 00a31023 subu r2,r5,r3 Base Hit - Accessory Evade
+
0018588c: 00c5102b sltu r2,r6,r5                    |{{f/std|<nowiki>r2 = 0x01 if Left Hand Evade < Base Hit</nowiki>}}
  001858b0: 3c028019 lui r2,0x8019
+
  00185890: 10400007 beq r2,r0,0x001858b0            {{f/Cond|If Base Hit > Left Hand Evade}} /Else branch (Attack Evaded without maths)
  001858b4: 8c422d90 lw r2,0x2d90(r2) Load Current Action Data Pointer
+
  00185894: 00000000 nop                                  |{{f/std|}}
  001858b8: 00000000 nop
+
  00185898: 3c078019 lui r7,0x8019                        |{{f/std|}}
001858bc: a0400000 sb r0,0x0000(r2) Attack Evaded
+
  0018589c: 90e738e1 lbu r7,0x38e1(r7)                    |{{f/load|<nowiki>r7 = Current Ability Class Evade</nowiki>}} {{f/std| 0x801938e1}}
  001858c0: 3c028019 lui r2,0x8019
+
  001858a0: 00000000 nop                                  |
001858c4: 8c422d90 lw r2,0x2d90(r2) Load Current Action Data Pointer
+
001858a4: 00e5102b sltu r2,r7,r5                        |{{f/std|<nowiki>r2 = 0x01 If Class Evade < Base Hit</nowiki>}}
  001858c8: 08061675 j 0x001859d4
+
  001858a8: 14400009 bne r2,r0,0x001858d0                {{f/Cond|If Class Evade > Base Hit}} /Else Avoid is Evaded section
001858cc: a440002a sh r0,0x002a(r2) Store Hit % = 0
+
  001858ac: 00a31023 subu r2,r5,r3                        |{{f/std|<nowiki>r2 = Base Hit - Accessory Evade</nowiki>}}
  *This section sets hit% for display
+
  001858b0: 3c028019 lui r2,0x8019            {{f/Cond|E }} {{f/Cond|E }} {{f/Cond|E    }}  |
001858d0: 00021840 sll r3,r2,0x01 Hit * 2
+
  001858b4: 8c422d90 lw r2,0x2d90(r2)                        |{{f/adr|<nowiki>r2 = Target Current action data pointer</nowiki>}}
  001858d4: 00621821 addu r3,r3,r2 Hit * 3
+
  001858b8: 00000000 nop                                      |
  001858d8: 000318c0 sll r3,r3,0x03 Hit * 24
+
  001858bc: a0400000 sb r0,0x0000(r2)                        |{{f/store|Store 0x00 in Target Current action hit flag (miss)}}
  001858dc: 00621821 addu r3,r3,r2 Hit * 25
+
  001858c0: 3c028019 lui r2,0x8019                            |
  001858e0: 00031880 sll r3,r3,0x02 Hit * 100
+
  001858c4: 8c422d90 lw r2,0x2d90(r2)                        |{{f/adr|<nowiki>r2 = Target Current action data pointer</nowiki>}}
001858e4: 0065001a div r3,r5 Modified Hit % / Original Hit %
+
  001858c8: 08061675 j 0x001859d4                            {{f/jump|jump After display section}}
  001858e8: 00001812 mflo r3 Accessory Hit %
+
  001858cc: a440002a sh r0,0x002a(r2)                        |{{f/store|<nowiki>Store Target Current action  Hit% = 0</nowiki>}}
001858ec: 00a42023 subu r4,r5,r4 Original Hit % - RH Evade
+
                                            {{f/Cond|Else (Attacks might succeed) - keep going}}
  001858f0: 00041040 sll r2,r4,0x01 Hit * 2
+
   
  001858f4: 00441021 addu r2,r2,r4 Hit * 3
+
  {{f/loc| --- Display Hit% Section ---}}
  001858f8: 000210c0 sll r2,r2,0x03 Hit * 24
+
  001858d0: 00021840 sll r3,r2,0x01          |{{f/std|<nowiki>r2 = Reduced Hit *2 (Base Hit - Accessory Evade)</nowiki>}} {{f/std|<nowiki>Base Hit = 80</nowiki>}}
  001858fc: 00441021 addu r2,r2,r4 Hit * 25
+
  001858d4: 00621821 addu r3,r3,r2            |{{f/std|Reduced Hit *3}} {{f/std|<nowiki>Acc Evade = 20</nowiki>}}
  00185900: 00021080 sll r2,r2,0x02 Hit * 100
+
  001858d8: 000318c0 sll r3,r3,0x03          |{{f/std|Reduced Hit * 24}}
  00185904: 0045001a div r2,r5 Modified Hit % / Original Hit %
+
  001858dc: 00621821 addu r3,r3,r2           |{{f/std|Reduced Hit * 25}}
  00185908: 00001012 mflo r2 RH Hit %
+
  001858e0: 00031880 sll r3,r3,0x02          |{{f/std|<nowiki>r3 = Reduced Hit *100</nowiki>}}
  0018590c: 00000000 nop
+
  001858e4: 0065001a div r3,r5                |{{f/std|(Accessory Reduced Hit *100)/Base Hit ( % of remaining Hit after Accessory Evade)}}
00185910: 00000000 nop
+
  001858e8: 00001812 mflo r3                  |{{f/std|<nowiki>r3 = % Of base Hit remaining</nowiki>}}
00185914: 00620018 mult r3,r2 Accessory Hit % * RH Hit %
+
  001858ec: 00a42023 subu r4,r5,r4            |{{f/std|<nowiki>r4 = Base Hit - Right Hand Evade</nowiki>}}
  00185918: 00a61823 subu r3,r5,r6 Original Hit - LH Evade
+
  001858f0: 00041040 sll r2,r4,0x01          |{{f/std|Reduced Hit *2}}
0018591c: 00031040 sll r2,r3,0x01 Hit * 2
+
  001858f4: 00441021 addu r2,r2,r4            |{{f/std|Reduced Hit *3}}
  00185920: 00431021 addu r2,r2,r3 Hit * 3
+
  001858f8: 000210c0 sll r2,r2,0x03          |{{f/std|Reduced Hit * 24}}
  00185924: 000210c0 sll r2,r2,0x03 Hit * 24
+
  001858fc: 00441021 addu r2,r2,r4            |{{f/std|Reduced Hit * 25}}
00185928: 00002012 mflo r4 r4 = New Hit %
+
  00185900: 00021080 sll r2,r2,0x02          |{{f/std|<nowiki>r2 = Reduced Hit *100</nowiki>}}
  0018592c: 00431021 addu r2,r2,r3 Hit * 25
+
  00185904: 0045001a div r2,r5                |{{f/std|(Right Hand Reduced Hit *100)/Base Hit ( % of remaining Hit after Right Hand Evade)}}
  00185930: 00021080 sll r2,r2,0x02 Hit * 100
+
  00185908: 00001012 mflo r2                 |{{f/std|<nowiki>r2 = Right Hand % of Remaining Base Hit</nowiki>}}
  00185934: 0045001a div r2,r5 Modified Hit % / Original Hit %
+
0018590c: 00000000 nop                      |
  00185938: 00001012 mflo r2 LH Hit %
+
00185910: 00000000 nop                      |
  0018593c: 00000000 nop
+
00185914: 00620018 mult r3,r2               |{{f/std|Accessory Remaing Hit% * Right Hand Remaining Hit%}}
  00185940: 00000000 nop
+
  00185918: 00a61823 subu r3,r5,r6            |{{f/std|<nowiki>r3 = Base Hit - Left Hand Evade</nowiki>}}
  00185944: 00820018 mult r4,r2 New Hit % * LH Hit %
+
  0018591c: 00031040 sll r2,r3,0x01          |{{f/std|Reduced Hit *2}}
  00185948: 00a71823 subu r3,r5,r7 Original Hit % - Class Evade
+
00185920: 00431021 addu r2,r2,r3            |{{f/std|Reduced Hit *3}}
  0018594c: 00031040 sll r2,r3,0x01 Hit * 2
+
  00185924: 000210c0 sll r2,r2,0x03          |{{f/std|Reduced Hit * 24}}
  00185950: 00431021 addu r2,r2,r3 Hit * 3
+
00185928: 00002012 mflo r4                  |r4 = Current Remaining % of Base (After Accessory and Right Hand Evade) * 100
  00185954: 000210c0 sll r2,r2,0x03 Hit * 24
+
  0018592c: 00431021 addu r2,r2,r3           |{{f/std|Reduced Hit * 25}}
00185958: 00002012 mflo r4 r4 = Newer Hit %
+
  00185930: 00021080 sll r2,r2,0x02          |{{f/std|<nowiki>r2 = Reduced Hit *100</nowiki>}}
  0018595c: 00431021 addu r2,r2,r3 Hit * 25
+
  00185934: 0045001a div r2,r5                |{{f/std|(Left Hand Reduced Hit *100)/Base Hit ( % of remaining Hit after Left Hand Evade)}}
  00185960: 00021080 sll r2,r2,0x02 Hit * 100
+
  00185938: 00001012 mflo r2                 |{{f/std|<nowiki>r2 = Left Hand % Of base Hit remaining</nowiki>}}
  00185964: 0045001a div r2,r5 Modified Hit % / Original Hit %
+
  0018593c: 00000000 nop                      |
  00185968: 00001012 mflo r2 Class Hit %
+
00185940: 00000000 nop                      |
0018596c: 00000000 nop
+
  00185944: 00820018 mult r4,r2              |{{f/std|Current Remaing Hit% *100 * Left Hand Remaining Hit%}}
00185970: 00000000 nop
+
  00185948: 00a71823 subu r3,r5,r7            |{{f/std|<nowiki>r3 = Base Hit % - Class Evade</nowiki>}}
00185974: 00820018 mult r4,r2 Newer Hit % * Class Hit %
+
  0018594c: 00031040 sll r2,r3,0x01          |{{f/std|Reduced Hit *2}}
  00185978: 00001812 mflo r3 r3 = Almost Final Hit %
+
  00185950: 00431021 addu r2,r2,r3            |{{f/std|Reduced Hit *3}}
  0018597c: 3c02431b lui r2,0x431b
+
  00185954: 000210c0 sll r2,r2,0x03          |{{f/std|Reduced Hit * 24}}
  00185980: 3442de83 ori r2,r2,0xde83
+
  00185958: 00002012 mflo r4                  |r4 = Current Remaining % of Base (After Accessory, Right Hand and Left Hand Evade) * 10000
00185984: 00620018 mult r3,r2 Almost Final Hit % * .262144
+
  0018595c: 00431021 addu r2,r2,r3            |{{f/std|Reduced Hit * 25}}
  00185988: 3c058019 lui r5,0x8019
+
  00185960: 00021080 sll r2,r2,0x02          |{{f/std|<nowiki>r2 = Reduced Hit *100</nowiki>}}
  0018598c: 8ca52d90 lw r5,0x2d90(r5) Load Current Action Data Pointer
+
  00185964: 0045001a div r2,r5                |{{f/std|(Classe Evade Reduced Hit *100)/Base Hit ( % of remaining Hit after Class Evade)}}
  00185990: 00000000 nop
+
  00185968: 00001012 mflo r2                  |{{f/std|<nowiki>r2 = Class Evade % Of base Hit remaining</nowiki>}}
00185994: 84a4002a lh r4,0x002a(r5) Load Original Hit %
+
  0018596c: 00000000 nop                      |
  00185998: 00031fc3 sra r3,r3,0x1f
+
  00185970: 00000000 nop                      |
  0018599c: 00001010 mfhi r2 r2 = Hit(1)%
+
00185974: 00820018 mult r4,r2              |{{f/std|Current Remaing Hit% * Class Evade Remaining Hit% * 1000000}}
  001859a0: 00021483 sra r2,r2,0x12 Hit(1) % / 262144 (Hit % /  100000000)
+
  00185978: 00001812 mflo r3                  |r3 = Current Remaining % of Base (After Accessory, Right Hand, Left Hand and Class Evade) *1000000
  001859a4: 00431023 subu r2,r2,r3
+
  0018597c: 3c02431b lui r2,0x431b            |
001859a8: 00440018 mult r2,r4 Hit(1) % * Origina Hit %
+
  00185980: 3442de83 ori r2,r2,0xde83        |{{f/std|<nowiki>r2 = 0x431bde83 (0,262144 * 2^32)</nowiki>}}
  001859ac: 00001812 mflo r3 r3 = Hit(2)%
+
  00185984: 00620018 mult r3,r2               |{{f/std|Current Remaining %of base Hit * 2^32*0,262144*1000000}}
  001859b0: 3c0251eb lui r2,0x51eb
+
  00185988: 3c058019 lui r5,0x8019            |
001859b4: 3442851f ori r2,r2,0x851f
+
  0018598c: 8ca52d90 lw r5,0x2d90(r5)         |{{f/adr|<nowiki>r5 = Target Current action data pointer</nowiki>}}
  001859b8: 00620018 mult r3,r2 Hit(2) % * 0.32
+
  00185990: 00000000 nop                      |
  001859bc: 00031fc3 sra r3,r3,0x1f
+
  00185994: 84a4002a lh r4,0x002a(r5)        |{{f/load|<nowiki>r4 = Target Current action Hit% (Set to 100 during PreFormla Set Up)</nowiki>}}
  001859c0: 00001010 mfhi r2 r2 = Final Hit%
+
  00185998: 00031fc3 sra r3,r3,0x1f          |{{f/std|<nowiki>r3 = 1st bit of Current Remaining % of base hit (should be 0x00)</nowiki>}}
  001859c4: 00021143 sra r2,r2,0x05 Final Hit % / 32 (Final Hit % =  Hit(2) % / 100)
+
  0018599c: 00001010 mfhi r2                  |{{f/std|<nowiki>r2 = [Remaining % of Base Hit] *262144</nowiki>}}
  001859c8: 00431023 subu r2,r2,r3
+
  001859a0: 00021483 sra r2,r2,0x12          |{{f/std|<nowiki>r2 = [Remaining % of Base Hit]  (2^18 = 262144)</nowiki>}}
  001859cc: a4a2002a sh r2,0x002a(r5) Store Final Hit%
+
  001859a4: 00431023 subu r2,r2,r3            |{{f/std|<nowiki>r2 = [Remaining % of Base Hit] -0x00</nowiki>}}
*This section actually calculates the evasion (1st Probability*2nd Probability*3rd Probability) - Choto
+
  001859a8: 00440018 mult r2,r4              |{{f/std|[Remaining % of Base Hit] * [Base Hit]}}
  001859d0: 01008021 addu r16,r8,r0 r16 = Original Hit %
+
  001859ac: 00001812 mflo r3                  |{{f/std|<nowiki>r3 = [Remaining % of Base Hit] * [Base Hit]</nowiki>}}
  001859d4: 02002821 addu r5,r16,r0 r5 = Original Hit %
+
  001859b0: 3c0251eb lui r2,0x51eb            |
  001859d8: 3c028019 lui r2,0x8019
+
  001859b4: 3442851f ori r2,r2,0x851f        |{{f/std|<nowiki>r2 = 0x51eb851f * 0,32*2^32</nowiki>}}
  001859dc: 8c422d98 lw r2,0x2d98(r2) Load Target Data Pointer
+
  001859b8: 00620018 mult r3,r2              |{{f/std|[Remaining % of Base Hit] * [Base Hit] * 0,32 * 2^32}}
  001859e0: 3c048019 lui r4,0x8019
+
  001859bc: 00031fc3 sra r3,r3,0x1f          |{{f/std|<nowiki>r3 = 1st bit of [Remaining % of Base Hit] * [Base Hit]</nowiki>}}
  001859e4: 908438de lbu r4,0x38de(r4) Load Accessory Evade
+
  001859c0: 00001010 mfhi r2                  |{{f/std|<nowiki>r2 = [Remaining % of Base Hit] * [Base Hit] * 32/100</nowiki>}}
  001859e8: 9047001c lbu r7,0x001c(r2) Load Target's Accessory ID
+
  001859c4: 00021143 sra r2,r2,0x05          |{{f/std|<nowiki>r2 = [Remaining % of Base Hit] * [Base Hit] /100 = Final Hit</nowiki>}}
  001859ec: 0c061236 jal 0x001848d8 [[Attack_Evaded_Calculations|Attack Evaded Calculation]]
+
  001859c8: 00431023 subu r2,r2,r3            |
001859f0: 34060001 ori r6,r0,0x0001 Type = Accessory?
+
  001859cc: a4a2002a sh r2,0x002a(r5)        |{{f/store|Store Final Hit% in Target Current Action 0x2a (Hit%)}}
  001859f4: 14400023 bne r2,r0,0x00185a84 Branch if Attack was evaded
+
  001859d0: 01008021 addu r16,r8,r0           |{{f/std|<nowiki>r16 = Original Hit %</nowiki>}}
  001859f8: 341100ff ori r17,r0,0x00ff r17 = 255
+
  001859fc: 3c038019 lui r3,0x8019
+
  {{f/loc| ---Roll  Evasion Section  ---}}
  00185a00: 8c632d98 lw r3,0x2d98(r3) Load Target Data Pointer
+
001859d4: 02002821 addu r5,r16,r0          |r5 = Current Ability Base Hit
00185a04: 00000000 nop
+
001859d8: 3c028019 lui r2,0x8019            |
  00185a08: 9067001d lbu r7,0x001d(r3) Load Target's RH Weapon ID
+
001859dc: 8c422d98 lw r2,0x2d98(r2)        |{{f/adr|<nowiki>r2 = Target Current action data pointer</nowiki>}}
  00185a0c: 00000000 nop
+
001859e0: 3c048019 lui r4,0x8019            |
  00185a10: 30e200ff andi r2,r7,0x00ff
+
001859e4: 908438de lbu r4,0x38de(r4)        |{{f/load|<nowiki>r4 = Accessory Evade</nowiki>}}
  00185a14: 14510002 bne r2,r17,0x00185a20 Branch if RH has a weapon
+
001859e8: 9047001c lbu r7,0x001c(r2)        |{{f/load|<nowiki>r7 = Target Accessory ID</nowiki>}}
  00185a18: 02002821 addu r5,r16,r0 r5 = Original Hit %
+
001859ec: 0c061236 jal 0x001848d8          |{{f/jal|Attack_Evaded_Calculations|Attack_Evaded_Calculations}} If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
  00185a1c: 9067001e lbu r7,0x001e(r3) Load Target's RH Shield ID
+
001859f0: 34060001 ori r6,r0,0x0001        |{{f/std|<nowiki>r6 = 0x01 (Accessory Evade Flag)</nowiki>}}
  00185a20: 3c048019 lui r4,0x8019
+
001859f4: 14400023 bne r2,r0,0x00185a84    {{f/Cond|If Attack Hits}} /Else if Attack is Evaded, branch to  {{f/loc|END}}
  00185a24: 908438df lbu r4,0x38df(r4) Load RH Evade
+
001859f8: 341100ff ori r17,r0,0x00ff        |{{f/std|<nowiki>r17 = 0x0ff</nowiki>}}
  00185a28: 0c061236 jal 0x001848d8 [[Attack_Evaded_Calculations|Attack Evaded Calculation]]
+
001859fc: 3c038019 lui r3,0x8019                |{{f/std|}}
  00185a2c: 34060002 ori r6,r0,0x0002 Type = RH Equip?
+
00185a00: 8c632d98 lw r3,0x2d98(r3)            |{{f/adr|<nowiki>r3 = Target Data pointer</nowiki>}}
  00185a30: 14400014 bne r2,r0,0x00185a84 Branch if Attack was evaded
+
00185a04: 00000000 nop                          |
  00185a34: 00000000 nop
+
00185a08: 9067001d lbu r7,0x001d(r3)            |{{f/load|<nowiki>r7 = Target Right Hand Weapon ID</nowiki>}}
00185a38: 3c028019 lui r2,0x8019
+
00185a0c: 00000000 nop                          |
00185a3c: 8c422d98 lw r2,0x2d98(r2) Load Target Data Pointer
+
00185a10: 30e200ff andi r2,r7,0x00ff            |{{f/std|<nowiki>r2 = Right Hand Weapon ID (byte)</nowiki>}}
  00185a40: 00000000 nop
+
00185a14: 14510002 bne r2,r17,0x00185a20        {{f/Cond|<nowiki>If Right Hand Weapon  ID = 0x0ff (don't exist)</nowiki>}}
00185a44: 9047001f lbu r7,0x001f(r2) Load Target's LH Weapon ID
+
00185a18: 02002821 addu r5,r16,r0              |{{f/std|<nowiki>r5 = Current Ability Base Hit</nowiki>}}
  00185a48: 00000000 nop
+
00185a1c: 9067001e lbu r7,0x001e(r3)                |{{f/load|<nowiki>r7 = Target Right Hand Shield</nowiki>}}
  00185a4c: 14f10002 bne r7,r17,0x00185a58 Branch if LH has a weapon
+
00185a20: 3c048019 lui r4,0x8019                |{{f/std|}}
  00185a50: 02002821 addu r5,r16,r0 r5 = Original Hit %
+
00185a24: 908438df lbu r4,0x38df(r4)            |{{f/load|<nowiki>r4 = Current Ability Right Hand Evade</nowiki>}} {{f/std| 0x801938df }}
00185a54: 90470020 lbu r7,0x0020(r2) Load Target's LH Shield
+
00185a28: 0c061236 jal 0x001848d8              |{{f/jal|Attack_Evaded_Calculations|Attack_Evaded_Calculations}} If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
  00185a58: 3c048019 lui r4,0x8019
+
00185a2c: 34060002 ori r6,r0,0x0002            |{{f/std|<nowiki>r6 = 0x02 (Right Hand Evade flag)</nowiki>}}
00185a5c: 908438e0 lbu r4,0x38e0(r4) Load LH Evade
+
00185a30: 14400014 bne r2,r0,0x00185a84        {{f/Cond|If Attack Hits}} /Else if Attack is Evaded, branch to  {{f/loc|END}}
  00185a60: 0c061236 jal 0x001848d8 [[Attack_Evaded_Calculations|Attack Evaded Calculation]]
+
00185a34: 00000000 nop                              |{{f/std|}}
  00185a64: 34060003 ori r6,r0,0x0003 Type = LH Equip?
+
00185a38: 3c028019 lui r2,0x8019                    |{{f/std|}}
  00185a68: 14400006 bne r2,r0,0x00185a84 Branch if Attack was evaded
+
00185a3c: 8c422d98 lw r2,0x2d98(r2)                |{{f/adr|<nowiki>r2 = Target Data pointer</nowiki>}}
00185a6c: 02002821 addu r5,r16,r0 r5 = Original Hit %
+
00185a40: 00000000 nop                              |
  00185a70: 3c048019 lui r4,0x8019
+
00185a44: 9047001f lbu r7,0x001f(r2)                |{{f/load|<nowiki>r7 = Target Left Hand Weapon</nowiki>}}
  00185a74: 908438e1 lbu r4,0x38e1(r4) Load Class Evade
+
00185a48: 00000000 nop                              |
  00185a78: 34060004 ori r6,r0,0x0004 Type = Class Evade
+
00185a4c: 14f10002 bne r7,r17,0x00185a58            {{f/Cond|<nowiki>If Left Hand Weapon  ID = 0x0ff (don't exist)</nowiki>}}
  00185a7c: 0c061236 jal 0x001848d8 [[Attack_Evaded_Calculations|Attack Evaded Calculation]]
+
00185a50: 02002821 addu r5,r16,r0                  |{{f/std|<nowiki>r5 = Current Ability Base Hit</nowiki>}}
00185a80: 340700ff ori r7,r0,0x00ff r7 = 255 (no equipment possible here)
+
00185a54: 90470020 lbu r7,0x0020(r2)                    |{{f/load|<nowiki>r7 = Target Left Hand Shield</nowiki>}}
00185a84: 8fbf0018 lw r31,0x0018(r29)
+
00185a58: 3c048019 lui r4,0x8019                    |{{f/std|}}
00185a88: 8fb10014 lw r17,0x0014(r29)
+
00185a5c: 908438e0 lbu r4,0x38e0(r4)                |{{f/load|<nowiki>r4 = Current Ability Left Hand Evade</nowiki>}} {{f/std| 0x801938e0}}
  00185a8c: 8fb00010 lw r16,0x0010(r29)
+
00185a60: 0c061236 jal 0x001848d8                  |{{f/jal|Attack_Evaded_Calculations|Attack_Evaded_Calculations}} If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
  00185a90: 27bd0020 addiu r29,r29,0x0020
+
00185a64: 34060003 ori r6,r0,0x0003                |{{f/std|<nowiki>r6 = 0x03  (Left Hand Evade flag)</nowiki>}}
  00185a94: 03e00008 jr r31
+
00185a68: 14400006 bne r2,r0,0x00185a84            {{f/Cond|If Attack Hits}} /Else if Attack is Evaded, branch to  {{f/loc|END}}
  00185a98: 00000000 nop
+
00185a6c: 02002821 addu r5,r16,r0                      |{{f/std|<nowiki>r5 = Current Ability Base Hit</nowiki>}}
 
+
00185a70: 3c048019 lui r4,0x8019                        |
 
+
00185a74: 908438e1 lbu r4,0x38e1(r4)                    |{{f/load|<nowiki>r4 = Current Ability Class Evade</nowiki>}} {{f/std|0x801938e1}}
== Return Locations ==
+
00185a78: 34060004 ori r6,r0,0x0004                    |{{f/std|<nowiki>r6 = 0x04 (Classe Evade flag)</nowiki>}}
 
+
00185a7c: 0c061236 jal 0x001848d8                      |{{f/jal|Attack_Evaded_Calculations|Attack_Evaded_Calculations}} If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
*Battle.bin
+
00185a80: 340700ff ori r7,r0,0x00ff                    |{{f/std|<nowiki>r7 = 0x0ff( No Item ID)</nowiki>}}
 
+
00185a84: 8fbf0018 lw r31,0x0018(r29)      END
  00188490: [[Calculate Hit %]]
+
00185a88: 8fb10014 lw r17,0x0014(r29)     
 +
  00185a8c: 8fb00010 lw r16,0x0010(r29)      
 +
  00185a90: 27bd0020 addiu r29,r29,0x0020    
 +
  00185a94: 03e00008 jr r31                  
 +
  00185a98: 00000000 nop                    
 +
=== Return Locations ===
 +
'''Battle.bin'''
 +
  00188498: [[Calculate Hit %]]

Latest revision as of 12:24, 14 April 2022

No Parameters - Returns nothing

If Ability flag [Evadeable] is Off : skip the whole routine
This routine Will set the value of the displayed Hit% 
  - Forced to 0x00 if Any Current Ability Evade data is greater than base hit value
  - If Attack might succeed : Hit% is calculated in the central math section
Last part of the routine Roll Each Evade type against Current Ability Base Hit (That's why halving base Hit = doubling all evasion type (cf Defend mechanics))
Update Target current action 0x2a (Hit%) and if Evaded then update Target current action 0x00 (Hit flag) 0x02 (Evade Type) and 0x03 (Used Item for evasion)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
00185814: 3c028019 lui r2,0x8019            |
00185818: 944238d6 lhu r2,0x38d6(r2)        |r2 = Current Ability : used Ability ID  0x801938d6
0018581c: 27bdffe0 addiu r29,r29,-0x020     |
00185820: afbf0018 sw r31,0x0018(r29)       |
00185824: afb10014 sw r17,0x0014(r29)       |
00185828: 10400007 beq r2,r0,0x00185848     #If used Ability is not a standard Attack
0018582c: afb00010 sw r16,0x0010(r29)           |
00185830: 3c028019 lui r2,0x8019                |
00185834: 904238f6 lbu r2,0x38f6(r2)            |r2 = Current Ability  flags 4  0x801938f6
00185838: 00000000 nop                          |
0018583c: 30420002 andi r2,r2,0x0002            |r2 = 0x02 if Ability is Evadable
00185840: 10400090 beq r2,r0,0x00185a84         #Branch to  END if Ability is not Evadable
00185844: 00000000 nop                              
00185848: 3c088019 lui r8,0x8019            |
0018584c: 910838dc lbu r8,0x38dc(r8)        |r8 = Current ability base Hit  0x801938dc
00185850: 3c038019 lui r3,0x8019            |
00185854: 906338de lbu r3,0x38de(r3)        |r3 = Current Ability Accessory Evade  0x801938de
00185858: 310500ff andi r5,r8,0x00ff        |r5 = Base Hit (byte)
0018585c: 0065102b sltu r2,r3,r5            |r2 = 0x01 if Accessory Evade < Base Hit
00185860: 10400013 beq r2,r0,0x001858b0     #If Base Hit > Accessory Evade /Else branch (Attack Evaded without maths)
00185864: 01008021 addu r16,r8,r0           |r16 = Base Hit % (Keep original value)
00185868: 3c048019 lui r4,0x8019                |
0018586c: 908438df lbu r4,0x38df(r4)            |r4 = Current Ability Right Hand Evade  0x801938df
00185870: 00000000 nop                          |
00185874: 0085102b sltu r2,r4,r5                |r2 = 0x01 if Right Hand Evade < Base Hit
00185878: 1040000d beq r2,r0,0x001858b0         #If Base Hit > Right Hand Evade /Else branch (Attack Evaded without maths)
0018587c: 00000000 nop                              |
00185880: 3c068019 lui r6,0x8019                    |
00185884: 90c638e0 lbu r6,0x38e0(r6)                |r6 = Current Ability Left Hand Evade  0x801938e0
00185888: 00000000 nop                              |
0018588c: 00c5102b sltu r2,r6,r5                    |r2 = 0x01 if Left Hand Evade < Base Hit
00185890: 10400007 beq r2,r0,0x001858b0             #If Base Hit > Left Hand Evade /Else branch (Attack Evaded without maths)
00185894: 00000000 nop                                  |
00185898: 3c078019 lui r7,0x8019                        |
0018589c: 90e738e1 lbu r7,0x38e1(r7)                    |r7 = Current Ability Class Evade  0x801938e1
001858a0: 00000000 nop                                  |
001858a4: 00e5102b sltu r2,r7,r5                        |r2 = 0x01 If Class Evade < Base Hit
001858a8: 14400009 bne r2,r0,0x001858d0                 #If Class Evade > Base Hit /Else Avoid is Evaded section
001858ac: 00a31023 subu r2,r5,r3                        |r2 = Base Hit - Accessory Evade
001858b0: 3c028019 lui r2,0x8019            #E  #E  #E      |
001858b4: 8c422d90 lw r2,0x2d90(r2)                         |r2 = Target Current action data pointer
001858b8: 00000000 nop                                      |
001858bc: a0400000 sb r0,0x0000(r2)                         |Store 0x00 in Target Current action hit flag (miss)
001858c0: 3c028019 lui r2,0x8019                            |
001858c4: 8c422d90 lw r2,0x2d90(r2)                         |r2 = Target Current action data pointer
001858c8: 08061675 j 0x001859d4                             >>jump After display section
001858cc: a440002a sh r0,0x002a(r2)                         |Store Target Current action  Hit% = 0
                                            #Else (Attacks might succeed) - keep going

 --- Display Hit% Section ---
001858d0: 00021840 sll r3,r2,0x01           |r2 = Reduced Hit *2 (Base Hit - Accessory Evade) Base Hit = 80
001858d4: 00621821 addu r3,r3,r2            |Reduced Hit *3 Acc Evade = 20
001858d8: 000318c0 sll r3,r3,0x03           |Reduced Hit * 24
001858dc: 00621821 addu r3,r3,r2            |Reduced Hit * 25
001858e0: 00031880 sll r3,r3,0x02           |r3 = Reduced Hit *100
001858e4: 0065001a div r3,r5                |(Accessory Reduced Hit *100)/Base Hit ( % of remaining Hit after Accessory Evade)
001858e8: 00001812 mflo r3                  |r3 = % Of base Hit remaining
001858ec: 00a42023 subu r4,r5,r4            |r4 = Base Hit - Right Hand Evade
001858f0: 00041040 sll r2,r4,0x01           |Reduced Hit *2
001858f4: 00441021 addu r2,r2,r4            |Reduced Hit *3
001858f8: 000210c0 sll r2,r2,0x03           |Reduced Hit * 24
001858fc: 00441021 addu r2,r2,r4            |Reduced Hit * 25
00185900: 00021080 sll r2,r2,0x02           |r2 = Reduced Hit *100
00185904: 0045001a div r2,r5                |(Right Hand Reduced Hit *100)/Base Hit ( % of remaining Hit after Right Hand Evade)
00185908: 00001012 mflo r2                  |r2 = Right Hand % of Remaining Base Hit
0018590c: 00000000 nop                      |
00185910: 00000000 nop                      |
00185914: 00620018 mult r3,r2               |Accessory Remaing Hit% * Right Hand Remaining Hit%
00185918: 00a61823 subu r3,r5,r6            |r3 = Base Hit - Left Hand Evade
0018591c: 00031040 sll r2,r3,0x01           |Reduced Hit *2
00185920: 00431021 addu r2,r2,r3            |Reduced Hit *3
00185924: 000210c0 sll r2,r2,0x03           |Reduced Hit * 24
00185928: 00002012 mflo r4                  |r4 = Current Remaining % of Base (After Accessory and Right Hand Evade) * 100
0018592c: 00431021 addu r2,r2,r3            |Reduced Hit * 25
00185930: 00021080 sll r2,r2,0x02           |r2 = Reduced Hit *100
00185934: 0045001a div r2,r5                |(Left Hand Reduced Hit *100)/Base Hit ( % of remaining Hit after Left Hand Evade)
00185938: 00001012 mflo r2                  |r2 = Left Hand % Of base Hit remaining
0018593c: 00000000 nop                      |
00185940: 00000000 nop                      |
00185944: 00820018 mult r4,r2               |Current Remaing Hit% *100 * Left Hand Remaining Hit%
00185948: 00a71823 subu r3,r5,r7            |r3 = Base Hit % - Class Evade
0018594c: 00031040 sll r2,r3,0x01           |Reduced Hit *2
00185950: 00431021 addu r2,r2,r3            |Reduced Hit *3
00185954: 000210c0 sll r2,r2,0x03           |Reduced Hit * 24
00185958: 00002012 mflo r4                  |r4 = Current Remaining % of Base (After Accessory, Right Hand and Left Hand Evade) * 10000
0018595c: 00431021 addu r2,r2,r3            |Reduced Hit * 25
00185960: 00021080 sll r2,r2,0x02           |r2 = Reduced Hit *100
00185964: 0045001a div r2,r5                |(Classe Evade Reduced Hit *100)/Base Hit ( % of remaining Hit after Class Evade)
00185968: 00001012 mflo r2                  |r2 = Class Evade % Of base Hit remaining
0018596c: 00000000 nop                      |
00185970: 00000000 nop                      |
00185974: 00820018 mult r4,r2               |Current Remaing Hit% * Class Evade Remaining Hit% * 1000000
00185978: 00001812 mflo r3                  |r3 = Current Remaining % of Base (After Accessory, Right Hand, Left Hand and Class Evade) *1000000
0018597c: 3c02431b lui r2,0x431b            |
00185980: 3442de83 ori r2,r2,0xde83         |r2 = 0x431bde83 (0,262144 * 2^32)
00185984: 00620018 mult r3,r2               |Current Remaining %of base Hit * 2^32*0,262144*1000000
00185988: 3c058019 lui r5,0x8019            |
0018598c: 8ca52d90 lw r5,0x2d90(r5)         |r5 = Target Current action data pointer
00185990: 00000000 nop                      |
00185994: 84a4002a lh r4,0x002a(r5)         |r4 = Target Current action Hit% (Set to 100 during PreFormla Set Up)
00185998: 00031fc3 sra r3,r3,0x1f           |r3 = 1st bit of Current Remaining % of base hit (should be 0x00)
0018599c: 00001010 mfhi r2                  |r2 = [Remaining % of Base Hit] *262144
001859a0: 00021483 sra r2,r2,0x12           |r2 = [Remaining % of Base Hit]   (2^18 = 262144)
001859a4: 00431023 subu r2,r2,r3            |r2 = [Remaining % of Base Hit] -0x00
001859a8: 00440018 mult r2,r4               |[Remaining % of Base Hit] * [Base Hit]
001859ac: 00001812 mflo r3                  |r3 = [Remaining % of Base Hit] * [Base Hit]
001859b0: 3c0251eb lui r2,0x51eb            |
001859b4: 3442851f ori r2,r2,0x851f         |r2 = 0x51eb851f * 0,32*2^32
001859b8: 00620018 mult r3,r2               |[Remaining % of Base Hit] * [Base Hit] * 0,32 * 2^32
001859bc: 00031fc3 sra r3,r3,0x1f           |r3 = 1st bit of [Remaining % of Base Hit] * [Base Hit]
001859c0: 00001010 mfhi r2                  |r2 = [Remaining % of Base Hit] * [Base Hit] * 32/100
001859c4: 00021143 sra r2,r2,0x05           |r2 = [Remaining % of Base Hit] * [Base Hit] /100 = Final Hit
001859c8: 00431023 subu r2,r2,r3            |
001859cc: a4a2002a sh r2,0x002a(r5)         |Store Final Hit% in Target Current Action 0x2a (Hit%)
001859d0: 01008021 addu r16,r8,r0           |r16 = Original Hit %

 ---Roll  Evasion Section  ---
001859d4: 02002821 addu r5,r16,r0           |r5 = Current Ability Base Hit
001859d8: 3c028019 lui r2,0x8019            |
001859dc: 8c422d98 lw r2,0x2d98(r2)         |r2 = Target Current action data pointer
001859e0: 3c048019 lui r4,0x8019            |
001859e4: 908438de lbu r4,0x38de(r4)        |r4 = Accessory Evade
001859e8: 9047001c lbu r7,0x001c(r2)        |r7 = Target Accessory ID
001859ec: 0c061236 jal 0x001848d8           |-->Attack_Evaded_Calculations If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
001859f0: 34060001 ori r6,r0,0x0001         |r6 = 0x01 (Accessory Evade Flag)
001859f4: 14400023 bne r2,r0,0x00185a84     #If Attack Hits /Else if Attack is Evaded, branch to  END
001859f8: 341100ff ori r17,r0,0x00ff        |r17 = 0x0ff
001859fc: 3c038019 lui r3,0x8019                |
00185a00: 8c632d98 lw r3,0x2d98(r3)             |r3 = Target Data pointer
00185a04: 00000000 nop                          |
00185a08: 9067001d lbu r7,0x001d(r3)            |r7 = Target Right Hand Weapon ID
00185a0c: 00000000 nop                          |
00185a10: 30e200ff andi r2,r7,0x00ff            |r2 = Right Hand Weapon ID (byte)
00185a14: 14510002 bne r2,r17,0x00185a20        #If Right Hand Weapon  ID = 0x0ff (don't exist)
00185a18: 02002821 addu r5,r16,r0               |r5 = Current Ability Base Hit
00185a1c: 9067001e lbu r7,0x001e(r3)                |r7 = Target Right Hand Shield
00185a20: 3c048019 lui r4,0x8019                |
00185a24: 908438df lbu r4,0x38df(r4)            |r4 = Current Ability Right Hand Evade  0x801938df 
00185a28: 0c061236 jal 0x001848d8               |-->Attack_Evaded_Calculations If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
00185a2c: 34060002 ori r6,r0,0x0002             |r6 = 0x02 (Right Hand Evade flag)
00185a30: 14400014 bne r2,r0,0x00185a84         #If Attack Hits /Else if Attack is Evaded, branch to  END
00185a34: 00000000 nop                              |
00185a38: 3c028019 lui r2,0x8019                    |
00185a3c: 8c422d98 lw r2,0x2d98(r2)                 |r2 = Target Data pointer
00185a40: 00000000 nop                              |
00185a44: 9047001f lbu r7,0x001f(r2)                |r7 = Target Left Hand Weapon
00185a48: 00000000 nop                              |
00185a4c: 14f10002 bne r7,r17,0x00185a58            #If Left Hand Weapon  ID = 0x0ff (don't exist)
00185a50: 02002821 addu r5,r16,r0                   |r5 = Current Ability Base Hit
00185a54: 90470020 lbu r7,0x0020(r2)                    |r7 = Target Left Hand Shield
00185a58: 3c048019 lui r4,0x8019                    |
00185a5c: 908438e0 lbu r4,0x38e0(r4)                |r4 = Current Ability Left Hand Evade  0x801938e0
00185a60: 0c061236 jal 0x001848d8                   |-->Attack_Evaded_Calculations If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
00185a64: 34060003 ori r6,r0,0x0003                 |r6 = 0x03  (Left Hand Evade flag)
00185a68: 14400006 bne r2,r0,0x00185a84             #If Attack Hits /Else if Attack is Evaded, branch to  END
00185a6c: 02002821 addu r5,r16,r0                       |r5 = Current Ability Base Hit
00185a70: 3c048019 lui r4,0x8019                        |
00185a74: 908438e1 lbu r4,0x38e1(r4)                    |r4 = Current Ability Class Evade 0x801938e1
00185a78: 34060004 ori r6,r0,0x0004                     |r6 = 0x04 (Classe Evade flag)
00185a7c: 0c061236 jal 0x001848d8                       |-->Attack_Evaded_Calculations If Attack is Evaded r2 = 0x01 (Hit flag is set to 0x00)
00185a80: 340700ff ori r7,r0,0x00ff                     |r7 = 0x0ff( No Item ID)
00185a84: 8fbf0018 lw r31,0x0018(r29)       END
00185a88: 8fb10014 lw r17,0x0014(r29)       
00185a8c: 8fb00010 lw r16,0x0010(r29)       
00185a90: 27bd0020 addiu r29,r29,0x0020     
00185a94: 03e00008 jr r31                   
00185a98: 00000000 nop                      

Return Locations

Battle.bin
00188498: Calculate Hit %