Difference between revisions of "Stat Increment/Decrement"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " Stats increment/decrement r5 = unit data + 32 0018d570: 90a80000 lbu r8,0x0000(r5) load original stat 0018d574: 30c300ff andi r3,r6,0x00ff r3 = stat cap 0018d578: 340200...")
 
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  Stats increment/decrement r5 = unit data + 32
+
  '''Parameters''' : r4 = Stat Change (0x7f = holds value - 0x80 if it's a bonus)
  0018d570: 90a80000 lbu r8,0x0000(r5) load original stat
+
              r5 = Unit Stat data pointer (details in return location)
  0018d574: 30c300ff andi r3,r6,0x00ff r3 = stat cap
+
              r6 = Stat maximum cap
  0018d578: 340200ff ori r2,r0,0x00ff
+
              r7 = Stat minimum cap
  0018d57c: 14620005 bne r3,r2,0x 0018d594 jump if stat cap != ff?
+
             
  0018d580: 3089007f andi r9,r4,0x007f r4 = + stat change
+
'''Returns''' : r2 = 0x00 if no stat change
  0018d584: 3402007f ori r2,r0,0x007f
+
          r2 = 0x01 if stat changes
  0018d588: 15220003 bne r9,r2,0x 0018d598 jump if stat change !=
+
------------------------------------------------------------------------------------------------------------------------
  +127?
+
  0018d570: 90a80000 lbu r8,0x0000(r5)       |{{f/load|<nowiki>r8 = Unit Stat</nowiki>}}
  0018d58c: 30820080 andi r2,r4,0x0080 r4 = - stat change
+
  0018d574: 30c300ff andi r3,r6,0x00ff       |{{f/std|<nowiki>r3 = Stat Cap</nowiki>}}
  0018d590: 340900ff ori r9,r0,0x00ff
+
  0018d578: 340200ff ori r2,r0,0x00ff         |{{f/std|<nowiki>r2 = 0x0ff</nowiki>}}
  0018d594: 30820080 andi r2,r4,0x0080
+
  0018d57c: 14620005 bne r3,r2,0x0018d594    {{f/Cond|<nowiki>If Stat Cap = 0x0ff</nowiki>}} {{f/std|Quick effect ?}}
  0018d598: 10400003 beq r2,r0,0x 0018d5a8 jump if stat change not
+
  0018d580: 3089007f andi r9,r4,0x007f       |{{f/std|<nowiki>r9 = Stat change value (flag 0x80 = + or -)</nowiki>}}
negative
+
  0018d584: 3402007f ori r2,r0,0x007f             |{{f/std|<nowiki>r2 = 0x7f</nowiki>}}
  0018d59c: 00000000 nop
+
  0018d588: 15220003 bne r9,r2,0x0018d598        {{f/Cond|<nowiki>If Stat Change = 0x7f (maximum change value)</nowiki>}}
  0018d5a0: 0806356b j 0x 0018d5ac
+
   
  0018d5a4: 01094021 addu r8,r8,r9 stat - stat change?
+
  0018d58c: 30820080 andi r2,r4,0x0080               |{{f/std|<nowiki>r2 = stat change bonus or malus flag</nowiki>}}
  0018d5a8: 01094023 subu r8,r8,r9 stat + stat change?
+
  0018d590: 340900ff ori r9,r0,0x00ff                 |{{f/std|<nowiki>r9 = 0x0ff (forces CT value at 0x0ff)</nowiki>}}
  0018d5ac: 30e700ff andi r7,r7,0x00ff r7 = 01?
+
  0018d594: 30820080 andi r2,r4,0x0080       |{{f/std|<nowiki>r2 = stat change bonus or malus flag</nowiki>}}
  0018d5b0: 0107102a slt r2,r8,r7 set if changed stat < 1
+
  0018d598: 10400003 beq r2,r0,0x0018d5a8    {{f/Cond|If TCA add a bonus to desired stat}}
  0018d5b4: 10400002 beq r2,r0,0x 0018d5c0 else branch
+
  0018d59c: 00000000 nop                         |
  0018d5b8: 30c600ff andi r6,r6,0x00ff r6 = stat cap this is done earlier
+
  0018d5a0: 0806356b j 0x0018d5ac                {{f/jump|Jump (add stat)}}
  0018d5bc: 00e04021 addu r8,r7,r0 r8 = 1
+
  0018d5a4: 01094021 addu r8,r8,r9               |{{f/std|<nowiki>r8 = Unit stat + Bonus value</nowiki>}}
  0018d5c0: 00c8102a slt r2,r6,r8 set if cap < 1
+
                                            '''Else (Malus)'''
  0018d5c4: 10400002 beq r2,r0,0x 0018d5d0 branch if not
+
  0018d5a8: 01094023 subu r8,r8,r9               |{{f/std|<nowiki>r8 = Unit stat - Malus value</nowiki>}}
  0018d5c8: 00000000 nop
+
  0018d5ac: 30e700ff andi r7,r7,0x00ff       |{{f/std|<nowiki>r7 = Stat minimum value</nowiki>}}
  0018d5cc: 00c04021 addu r8,r6,r0 r8 = stat cap?
+
  0018d5b0: 0107102a slt r2,r8,r7             |{{f/std|<nowiki>r2 = 0x01 if Unit's new stat < Minimum value</nowiki>}}
  0018d5d0: 90a20000 lbu r2,0x0000(r5) load stat?
+
  0018d5b4: 10400002 beq r2,r0,0x0018d5c0    {{f/Cond|If Unit's new stats < Minimum value}}
  0018d5d4: 00000000 nop
+
  0018d5b8: 30c600ff andi r6,r6,0x00ff       |{{f/std|<nowiki>r6 = Stat's Maximum value</nowiki>}}
  0018d5d8: 15020003 bne r8,r2,0x 0018d5e8 continue if current stat
+
  0018d5bc: 00e04021 addu r8,r7,r0               |{{f/std|<nowiki>r8 = Minimum stat value</nowiki>}}
!= stat cap?
+
  0018d5c0: 00c8102a slt r2,r6,r8             |{{f/std|<nowiki>r2 = 0x01 if Maximum value < New value</nowiki>}}
  0018d5dc: 34020001 ori r2,r0,0x0001 r2 = 1
+
  0018d5c4: 10400002 beq r2,r0,0x0018d5d0    {{f/Cond|If Unit's New Stats value > Maximum value}}
  0018d5e0: 08063586 j 0x 0018d618 jump to end (no storing)
+
  0018d5c8: 00000000 nop                         |
  0018d5e4: 00001021 addu r2,r0,r0 r2 = 0
+
  0018d5cc: 00c04021 addu r8,r6,r0               |{{f/std|<nowiki>r8 = Maximum stat value</nowiki>}}
  0018d5e8: 14e2000a bne r7,r2,0x 0018d614 jump to end if r2 = 1
+
  0018d5d0: 90a20000 lbu r2,0x0000(r5)       |{{f/load|<nowiki>r2 = Unit stat</nowiki>}}
  0018d5ec: a0a80000 sb r8,0x0000(r5) store ?? as new stat
+
  0018d5d4: 00000000 nop                     |
  0018d5f0: 90a20000 lbu r2,0x0000(r5) load original stat
+
  0018d5d8: 15020003 bne r8,r2,0x0018d5e8    {{f/Cond|If There's no stat modification }} {{f/std| already at min or max value}}
  0018d5f4: 90a30003 lbu r3,0x0003(r5) load bonus stat
+
  0018d5dc: 34020001 ori r2,r0,0x0001         |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
  0018d5f8: 00000000 nop
+
  0018d5e0: 08063586 j 0x0018d618                {{f/jump|<nowiki>jump to end (r2 = 0x00)</nowiki>}}
  0018d5fc: 00434021 addu r8,r2,r3 add stats?
+
  0018d5e4: 00001021 addu r2,r0,r0               |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
  0018d600: 00c8102a slt r2,r6,r8 set if r6 < first stat +
+
                                            '''Else (There is a modification)'''
second stat?
+
  0018d5e8: 14e2000a bne r7,r2,0x0018d614    {{f/Cond|If Minimum stat value is 0x01 (MA - PA - Speed)}}
  0018d604: 10400002 beq r2,r0,0x 0018d610 branch if not
+
  0018d5ec: a0a80000 sb r8,0x0000(r5)         |{{f/store|Store new Unit stat value}}
  0018d608: 00000000 nop
+
  0018d5f0: 90a20000 lbu r2,0x0000(r5)           |{{f/load|<nowiki>r2 = New stat value</nowiki>}}
  0018d60c: 00c04021 addu r8,r6,r0 r8 = r6
+
  0018d5f4: 90a30003 lbu r3,0x0003(r5)           |{{f/load|<nowiki>r3 = Unit Stats from equipment</nowiki>}}
  0018d610: a0a80006 sb r8,0x0006(r5) store r6 as new stat
+
  0018d5f8: 00000000 nop                         |
  0018d614: 34020001 ori r2,r0,0x0001 r2 = 1
+
  0018d5fc: 00434021 addu r8,r2,r3               |{{f/std|<nowiki>r8 = New Value + Bonus from equipment</nowiki>}}
  0018d618: 03e00008 jr r31
+
  0018d600: 00c8102a slt r2,r6,r8                 |{{f/std|<nowiki>r2 = 0x01 if Max stats value < Total value</nowiki>}}
 +
  0018d604: 10400002 beq r2,r0,0x0018d610        {{f/Cond|If Total Stat value > Max Value}}
 +
  0018d608: 00000000 nop                             |
 +
  0018d60c: 00c04021 addu r8,r6,r0                   |{{f/std|<nowiki>r8 = Max value</nowiki>}}
 +
  0018d610: a0a80006 sb r8,0x0006(r5)             |{{f/store|Store New Total value (raw + equipement)}}
 +
  0018d614: 34020001 ori r2,r0,0x0001         |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
 +
  0018d618: 03e00008 jr r31                   '''END'''
 
  0018d61c: 00000000 nop
 
  0018d61c: 00000000 nop
 +
=== Return location ===
 +
'''Battle.bin'''
 +
0018c094: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x32 (raw speed)
 +
0018c0bc: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x39 (CT)
 +
0018c0e4: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x30 (raw PA)
 +
0018c10c: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x31 (raw MA)
 +
0018c140: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x24 (Brave)
 +
0018c168: [[Attack_Finalisation_%26_Reaction_Flagging]] r5 = 0x26 (Faith)

Latest revision as of 13:02, 25 November 2022

Parameters : r4 = Stat Change (0x7f = holds value - 0x80 if it's a bonus)
             r5 = Unit Stat data pointer (details in return location)
             r6 = Stat maximum cap
             r7 = Stat minimum cap
             
Returns : r2 = 0x00 if no stat change
          r2 = 0x01 if stat changes 
------------------------------------------------------------------------------------------------------------------------
0018d570: 90a80000 lbu r8,0x0000(r5)        |r8 = Unit Stat
0018d574: 30c300ff andi r3,r6,0x00ff        |r3 = Stat Cap
0018d578: 340200ff ori r2,r0,0x00ff         |r2 = 0x0ff
0018d57c: 14620005 bne r3,r2,0x0018d594     #If Stat Cap = 0x0ff Quick effect ?
0018d580: 3089007f andi r9,r4,0x007f        |r9 = Stat change value (flag 0x80 = + or -)
0018d584: 3402007f ori r2,r0,0x007f             |r2 = 0x7f
0018d588: 15220003 bne r9,r2,0x0018d598         #If Stat Change = 0x7f (maximum change value)

0018d58c: 30820080 andi r2,r4,0x0080                |r2 = stat change bonus or malus flag
0018d590: 340900ff ori r9,r0,0x00ff                 |r9 = 0x0ff (forces CT value at 0x0ff)
0018d594: 30820080 andi r2,r4,0x0080        |r2 = stat change bonus or malus flag
0018d598: 10400003 beq r2,r0,0x0018d5a8     #If TCA add a bonus to desired stat
0018d59c: 00000000 nop                          |
0018d5a0: 0806356b j 0x0018d5ac                 >>Jump (add stat)
0018d5a4: 01094021 addu r8,r8,r9                |r8 = Unit stat + Bonus value
                                            Else (Malus)
0018d5a8: 01094023 subu r8,r8,r9                |r8 = Unit stat - Malus value
0018d5ac: 30e700ff andi r7,r7,0x00ff        |r7 = Stat minimum value
0018d5b0: 0107102a slt r2,r8,r7             |r2 = 0x01 if Unit's new stat < Minimum value
0018d5b4: 10400002 beq r2,r0,0x0018d5c0     #If Unit's new stats < Minimum value
0018d5b8: 30c600ff andi r6,r6,0x00ff        |r6 = Stat's Maximum value
0018d5bc: 00e04021 addu r8,r7,r0                |r8 = Minimum stat value
0018d5c0: 00c8102a slt r2,r6,r8             |r2 = 0x01 if Maximum value < New value
0018d5c4: 10400002 beq r2,r0,0x0018d5d0     #If Unit's New Stats value > Maximum value
0018d5c8: 00000000 nop                          |
0018d5cc: 00c04021 addu r8,r6,r0                |r8 = Maximum stat value
0018d5d0: 90a20000 lbu r2,0x0000(r5)        |r2 = Unit stat
0018d5d4: 00000000 nop                      |
0018d5d8: 15020003 bne r8,r2,0x0018d5e8     #If There's no stat modification   already at min or max value
0018d5dc: 34020001 ori r2,r0,0x0001         |r2 = 0x01
0018d5e0: 08063586 j 0x0018d618                 >>jump to end (r2 = 0x00)
0018d5e4: 00001021 addu r2,r0,r0                |r2 = 0x00
                                            Else (There is a modification)
0018d5e8: 14e2000a bne r7,r2,0x0018d614     #If Minimum stat value is 0x01 (MA - PA - Speed)
0018d5ec: a0a80000 sb r8,0x0000(r5)         |Store new Unit stat value
0018d5f0: 90a20000 lbu r2,0x0000(r5)            |r2 = New stat value
0018d5f4: 90a30003 lbu r3,0x0003(r5)            |r3 = Unit Stats from equipment
0018d5f8: 00000000 nop                          |
0018d5fc: 00434021 addu r8,r2,r3                |r8 = New Value + Bonus from equipment
0018d600: 00c8102a slt r2,r6,r8                 |r2 = 0x01 if Max stats value < Total value
0018d604: 10400002 beq r2,r0,0x0018d610         #If Total Stat value > Max Value
0018d608: 00000000 nop                              |
0018d60c: 00c04021 addu r8,r6,r0                    |r8 = Max value
0018d610: a0a80006 sb r8,0x0006(r5)             |Store New Total value (raw + equipement)
0018d614: 34020001 ori r2,r0,0x0001         |r2 = 0x01
0018d618: 03e00008 jr r31                   END
0018d61c: 00000000 nop

Return location

Battle.bin
0018c094: Attack_Finalisation_&_Reaction_Flagging r5 = 0x32 (raw speed)
0018c0bc: Attack_Finalisation_&_Reaction_Flagging r5 = 0x39 (CT)
0018c0e4: Attack_Finalisation_&_Reaction_Flagging r5 = 0x30 (raw PA)
0018c10c: Attack_Finalisation_&_Reaction_Flagging r5 = 0x31 (raw MA)
0018c140: Attack_Finalisation_&_Reaction_Flagging r5 = 0x24 (Brave)
0018c168: Attack_Finalisation_&_Reaction_Flagging r5 = 0x26 (Faith)