Difference between revisions of "Magic Defense Up routine"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
  0018631c: 3c028019 lui r2,0x8019
+
No Parameters - Returns nothing
  00186320: 8c422d98 lw r2,0x2d98(r2) Load Defender's Stats
+
  00186324: 00000000 nop
+
Decrease Ability XA (-33%) if Target uses Magic Defense Up
  00186328: 90420090 lbu r2,0x0090(r2) Defender's 2nd set of Supports
+
-------------------------------------------------------------------------------------------------
  0018632c: 00000000 nop
+
  0018631c: 3c028019 lui r2,0x8019          
  00186330: 30420002 andi r2,r2,0x0002
+
  00186320: 8c422d98 lw r2,0x2d98(r2)         |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
  00186334: 1040000b beq r2,r0,0x00186364 Branch if the Defender doesn't have Defense Up
+
  00186324: 00000000 nop                     |
  00186338: 3c025555 lui r2,0x5555
+
  00186328: 90420090 lbu r2,0x0090(r2)       |{{f/load|<nowiki>r2 = Target 2nd set of Support abilities</nowiki>}}
  0018633c: 3c048019 lui r4,0x8019
+
  0018632c: 00000000 nop                     |
  00186340: 248438ce addiu r4,r4,0x38ce Load XA
+
  00186330: 30420002 andi r2,r2,0x0002       |{{f/std|<nowiki>r2 = 0x02 if Target uses Magic Defense Up</nowiki>}}
  00186344: 84830000 lh r3,0x0000(r4)
+
  00186334: 1040000b beq r2,r0,0x00186364     {{f/Cond|If Target uses Magic Defense Up}}
  00186348: 34425556 ori r2,r2,0x5556 R2 = 55555556 or 1/3 when used in multiplication
+
  00186338: 3c025555 lui r2,0x5555               |
  0018634c: 00031840 sll r3,r3,0x01 XA * 2
+
  0018633c: 3c048019 lui r4,0x8019               |
  00186350: 00620018 mult r3,r2 XA * 2 / 3
+
  00186340: 248438ce addiu r4,r4,0x38ce           |{{f/adr|<nowiki>r4 = Current Ability XA pointer</nowiki>}}
  00186354: 00031fc3 sra r3,r3,0x1f
+
  00186344: 84830000 lh r3,0x0000(r4)             |{{f/load|<nowiki>r3 = Ability XA</nowiki>}}
  00186358: 00001010 mfhi r2 Move "Remainder" to r2
+
  00186348: 34425556 ori r2,r2,0x5556             |{{f/std|<nowiki>r2 = 0x55555556 (0,33 * 2^32)</nowiki>}}
  0018635c: 00431023 subu r2,r2,r3
+
  0018634c: 00031840 sll r3,r3,0x01               |{{f/std|XA*2}}
  00186360: a4820000 sh r2,0x0000(r4) Store new XA
+
  00186350: 00620018 mult r3,r2                   |{{f/std|XA * 2/3 * 2^32}}
  00186364: 03e00008 jr r31
+
  00186354: 00031fc3 sra r3,r3,0x1f               |{{f/std|<nowiki>r3 = Highest bit of r3 (should be 0x00)</nowiki>}}
  00186368: 00000000 nop
+
  00186358: 00001010 mfhi r2                     |{{f/std|<nowiki>r2 = XA * 2/3</nowiki>}}
 +
  0018635c: 00431023 subu r2,r2,r3               |{{f/std|XA *2/3 eventually down rounded}}
 +
  00186360: a4820000 sh r2,0x0000(r4)             |{{f/store|Store new XA (66% of initial XA)}}
 +
  00186364: 03e00008 jr r31                   END
 +
  00186368: 00000000 nop  
 +
 +
Warning : this routine don't save r31 (and don't set his stack pointer) do not jal from here without resolving it                 
 +
 
 +
=== Return Locations ===
 +
'''Battle.bin'''
 +
0018875c: [[Magical Support/Status/Compat]]
 +
00189010: [[0E_Dmg_(Y)%25_Hit_F(MA%2BX)%25_100%25_Status_Hide_Status|Formula 0E - Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status]]

Latest revision as of 06:21, 11 April 2022

No Parameters - Returns nothing

Decrease Ability XA (-33%) if Target uses Magic Defense Up
-------------------------------------------------------------------------------------------------
0018631c: 3c028019 lui r2,0x8019            
00186320: 8c422d98 lw r2,0x2d98(r2)         |r2 = Target data pointer
00186324: 00000000 nop                      |
00186328: 90420090 lbu r2,0x0090(r2)        |r2 = Target 2nd set of Support abilities
0018632c: 00000000 nop                      |
00186330: 30420002 andi r2,r2,0x0002        |r2 = 0x02 if Target uses Magic Defense Up
00186334: 1040000b beq r2,r0,0x00186364     #If Target uses Magic Defense Up
00186338: 3c025555 lui r2,0x5555                |
0018633c: 3c048019 lui r4,0x8019                |
00186340: 248438ce addiu r4,r4,0x38ce           |r4 = Current Ability XA pointer
00186344: 84830000 lh r3,0x0000(r4)             |r3 = Ability XA
00186348: 34425556 ori r2,r2,0x5556             |r2 = 0x55555556 (0,33 * 2^32)
0018634c: 00031840 sll r3,r3,0x01               |XA*2
00186350: 00620018 mult r3,r2                   |XA * 2/3 * 2^32
00186354: 00031fc3 sra r3,r3,0x1f               |r3 = Highest bit of r3 (should be 0x00)
00186358: 00001010 mfhi r2                      |r2 = XA * 2/3
0018635c: 00431023 subu r2,r2,r3                |XA *2/3 eventually down rounded
00186360: a4820000 sh r2,0x0000(r4)             |Store new XA (66% of initial XA)
00186364: 03e00008 jr r31                   END
00186368: 00000000 nop   

Warning : this routine don't save r31 (and don't set his stack pointer) do not jal from here without resolving it                   

Return Locations

Battle.bin
0018875c: Magical Support/Status/Compat
00189010: Formula 0E - Dmg (Y)% Hit F(MA+X)% 100% Status Hide Status