Difference between revisions of "Check if Status Should/Can be Added"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
 +
BATTLE.BIN : Check if Status Should/Can be Added
 +
------------------------------------------------------------------------------------------
 +
Parameters - r4 : Clockticks left before Acting Unit next turn
 +
              r5 : Considered Unit data pointer (potential target)
 +
              r6 : Status ID
 +
 +
Returns r2 : 0x00 if status not inflicted yet
 +
              0x00 if status is inflicted but will fade before next turn
 +
              0x00 if considered unit is jumping and will land before next turn
 +
              0x01 if Unit is Jumping and will land later
 +
              0x01 if considered status is innate
 +
              0x01 if considered status is inflicted do not have a CT
 +
              0x01 if considered status is inflicted but won't fade before next turn
 +
  --> r2 = 0x00 if worth to be inflicted
 +
-----------------------------------------------------------------------------------------
 +
0019ef24: 00804021 addu r8,r4,r0            |{{f/std|<nowiki>r8 = Clockticks left before unit next turn</nowiki>}}
 +
0019ef28: 04c10002 bgez r6,0x0019ef34      {{f/Cond|If Status Index < 0 }}
 +
0019ef2c: 00c01021 addu r2,r6,r0            |{{f/std|<nowiki>r2 = Status ID</nowiki>}}
 +
0019ef30: 24c20007 addiu r2,r6,0x0007          |{{f/std|Status ID + 7}}
 +
0019ef34: 000210c3 sra r2,r2,0x03          |{{f/std|Considered status set (Status ID/8)}}
 +
0019ef38: 00a23821 addu r7,r5,r2            |{{f/adr|Unit Data Pointer + Status set offset}}
 +
0019ef3c: 90e40058 lbu r4,0x0058(r7)        |{{f/load|Load Appropriate Unit's Current status set}}
 +
0019ef40: 000210c0 sll r2,r2,0x03          |{{f/std|Status Set * 8}}
 +
0019ef44: 00c21023 subu r2,r6,r2            |{{f/std|Status position in status set (0 to 7)}}
 +
0019ef48: 34030080 ori r3,r0,0x0080        |{{f/std|0x80 (will be used as bitmask)}}
 +
0019ef4c: 00431807 srav r3,r3,r2            |{{f/std|Set consired Status bitmask}}
 +
0019ef50: 00832024 and r4,r4,r3            |{{f/std|Check considered status}}
 +
0019ef54: 10800013 beq r4,r0,0x0019efa4    {{f/Cond|If Unit has considered status}} /'''Else ''' : {{f/loc|<nowiki>returns r2 = 0x00</nowiki>}}
 +
0019ef58: 34020005 ori r2,r0,0x0005            |{{f/std|Death ID}}
 +
0019ef5c: 14c20004 bne r6,r2,0x0019ef70        {{f/Cond|If Checked status is Jump}}
 +
0019ef60: 28c20018 slti r2,r6,0x0018            |{{f/std|<nowiki>r2 = 0x1 if Status ID < 0x18 (All statuses without CT)</nowiki>}}
 +
0019ef64: 90a2015d lbu r2,0x015d(r5)                |{{f/load|Load Unit's Current Ability CT}}
 +
0019ef68: 08067be7 j 0x0019ef9c                    {{f/jump|Jump to end}}
 +
0019ef6c: 0048102a slt r2,r2,r8                    |{{f/std|Check if considered unit will land before next turn}}
 +
                                                '''Else : Unit has considered status (and it is not Jump)'''
 +
0019ef70: 1440000d bne r2,r0,0x0019efa8        {{f/Cond|Branch if considered Status doesn't have a CT :}} {{f/loc|<nowiki>returns r2 = 0x01</nowiki>}}
 +
0019ef74: 34020001 ori r2,r0,0x0001                |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
 +
0019ef78: 90e2004e lbu r2,0x004e(r7)            |{{f/load|Load Appropriate Unit Innate Status set}}
 +
0019ef7c: 00000000 nop                          |
 +
0019ef80: 00431024 and r2,r2,r3                |{{f/std|Check considered status}}
 +
0019ef84: 14400008 bne r2,r0,0x0019efa8        {{f/Cond|Branch if considered Status is Innate}} {{f/loc|<nowiki>returns r2 = 0x01</nowiki>}}
 +
0019ef88: 34020001 ori r2,r0,0x0001                |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
 +
0019ef8c: 00a61021 addu r2,r5,r6                |{{f/adr|Unit Data Pointer + Status ID offset}}
 +
0019ef90: 90420045 lbu r2,0x0045(r2)            |{{f/load|Load Considered Status' CT}}
 +
0019ef94: 00000000 nop                          |
 +
0019ef98: 0048102a slt r2,r2,r8                |{{f/std|Check if Status wil fade before unit next turn}}
 +
0019ef9c: 10400002 beq r2,r0,0x0019efa8        {{f/Cond|Branch if Status will not fade before next unit turn}} {{f/loc|<nowiki>returns r2 = 0x01</nowiki>}}
 +
0019efa0: 34020001 ori r2,r0,0x0001                |{{f/std|<nowiki>r2 = 0x01</nowiki>}}
 +
0019efa4: 00001021 addu r2,r0,r0                |{{f/std|<nowiki>r2 = 0x00</nowiki>}}
 +
0019efa8: 03e00008 jr r31                  END
 +
0019efac: 00000000 nop
 +
=== Notes ===
 +
''' Hardcoded '''
 +
  Jump CT check
 +
  Status ID < 0x18 won't have their CT considered (if hacked)
  
Check if Status Should/Can be Added
+
===Return Locations===
r4 = clockticks till unit acts
+
  '''BATTLE.BIN'''
  0xX0 - set to use * 8
+
  00194fd4: [[Set_AI_ability_considerations_for_all_units_and_self]] 0x25 (Don't Act)
  0x0X - status to check for (0x80 srav 0x0X)
+
  00194ffc: [[Set_AI_ability_considerations_for_all_units_and_self]] 0x0c (Silence)
  0019ef24: 00804021 addu r8,r4,r0 r8 = Clockticks Required (CT till unit acts)
+
  00195024: [[Set_AI_ability_considerations_for_all_units_and_self]] 0x21 (Innocent)
  0019ef28: 04c10002 bgez r6,0x0019ef34 Branch if Status Mod >= 0
+
  00199938: [[Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted]] 0x1e (Stop)
  0019ef2c: 00c01021 addu r2,r6,r0 r2 = Status Mod
+
  00199954: [[Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted]] 0x25 (Don't Act)
0019ef30: 24c20007 addiu r2,r6,0x0007
+
  00199970: [[Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted]] 0x23 (Sleep)
0019ef34: 000210c3 sra r2,r2,0x03 Status Mod / 8
+
  0019998c: [[Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted]] 0x15 (Chicken)
0019ef38: 00a23821 addu r7,r5,r2
+
  001999ac: [[Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted]] 0x22 (Charm)
0019ef3c: 90e40058 lbu r4,0x0058(r7) Load Unit's Statuses
+
  0019b864: [[AI_Targeting_Matrix_Analysis_(0019b7b8)]] 0x26 (Reflect)
  0019ef40: 000210c0 sll r2,r2,0x03 Status Mod / 8 * 8
+
  0019e6f4: [[AI_Ability_Use_Decisions]] 0x26 (Reflect)
0019ef44: 00c21023 subu r2,r6,r2 Status Mod MOD 8
+
  0019e71c: [[AI_Ability_Use_Decisions]] 0x21 (Innocent)
0019ef48: 34030080 ori r3,r0,0x0080 Current Status = 0x80
+
  0019e734: [[AI_Ability_Use_Decisions]] 0x05 (Jump)
0019ef4c: 00431807 srav r3,r3,r2 (get chosen status)
+
  0019e810: [[AI_Ability_Use_Decisions]] 0x1f (Wall)
0019ef50: 00832024 and r4,r4,r3
+
  0019e918: [[AI_Ability_Use_Decisions]] 0x22 (Charm)
0019ef54: 10800013 beq r4,r0,0x0019efa4 Branch if Chosen Status isn't present
+
  0019e988: [[AI_Ability_Use_Decisions]] 0x23 (Sleep)
  0019ef58: 34020005 ori r2,r0,0x0005 r2 = 5
+
  0019edd8: [[AI_Ability_Use_Decisions]] loop (Set 4 and Set 5 ?)
  0019ef5c: 14c20004 bne r6,r2,0x0019ef70 Branch if not checking for Dead
+
  0019f1c8: [[Status/CT_based_decision]] 0x1e (Stop)
  0019ef60: 28c20018 slti r2,r6,0x0018
+
  0019f1e0: [[Status/CT_based_decision]] 0x24 (don't move)
  0019ef64: 90a2015d lbu r2,0x015d(r5) Load Unit's Current Ability CT
+
  0019f1f8: [[Status/CT_based_decision]] 0x23 (sleep)
  0019ef68: 08067be7 j 0x0019ef9c
 
  0019ef6c: 0048102a slt r2,r2,r8 (Check for CT < Clockticks Required)
 
 
 
  0019ef70: 1440000d bne r2,r0,0x0019efa8 Branch if Status doesn't have a CT
 
  0019ef74: 34020001 ori r2,r0,0x0001 r2 = 1 (Fail)
 
  0019ef78: 90e2004e lbu r2,0x004e(r7) Load Innate Statuses
 
  0019ef7c: 00000000 nop
 
  0019ef80: 00431024 and r2,r2,r3
 
  0019ef84: 14400008 bne r2,r0,0x0019efa8 Branch if Chosen Status is Innate
 
0019ef88: 34020001 ori r2,r0,0x0001 r2 = 1 (Fail)
 
  0019ef8c: 00a61021 addu r2,r5,r6
 
0019ef90: 90420045 lbu r2,0x0045(r2) Load Status' CT
 
0019ef94: 00000000 nop
 
0019ef98: 0048102a slt r2,r2,r8
 
0019ef9c: 10400002 beq r2,r0,0x0019efa8 Branch if CT >= Clockticks Required
 
0019efa0: 34020001 ori r2,r0,0x0001 r2 = 1 (Fail)
 
  0019efa4: 00001021 addu r2,r0,r0 r2 = 0 (Success)
 
0019efa8: 03e00008 jr r31
 
0019efac: 00000000 nop
 
return r2 = 1 if
 

Latest revision as of 13:39, 4 May 2023

BATTLE.BIN : Check if Status Should/Can be Added
------------------------------------------------------------------------------------------
Parameters - r4 : Clockticks left before Acting Unit next turn
             r5 : Considered Unit data pointer (potential target)
             r6 : Status ID

Returns r2 : 0x00 if status not inflicted yet
             0x00 if status is inflicted but will fade before next turn
             0x00 if considered unit is jumping and will land before next turn
             0x01 if Unit is Jumping and will land later
             0x01 if considered status is innate
             0x01 if considered status is inflicted do not have a CT
             0x01 if considered status is inflicted but won't fade before next turn
 --> r2 = 0x00 if worth to be inflicted
-----------------------------------------------------------------------------------------
0019ef24: 00804021 addu r8,r4,r0            |r8 = Clockticks left before unit next turn
0019ef28: 04c10002 bgez r6,0x0019ef34       #If Status Index < 0 
0019ef2c: 00c01021 addu r2,r6,r0            |r2 = Status ID
0019ef30: 24c20007 addiu r2,r6,0x0007           |Status ID + 7
0019ef34: 000210c3 sra r2,r2,0x03           |Considered status set (Status ID/8)
0019ef38: 00a23821 addu r7,r5,r2            |Unit Data Pointer + Status set offset
0019ef3c: 90e40058 lbu r4,0x0058(r7)        |Load Appropriate Unit's Current status set
0019ef40: 000210c0 sll r2,r2,0x03           |Status Set * 8
0019ef44: 00c21023 subu r2,r6,r2            |Status position in status set (0 to 7)
0019ef48: 34030080 ori r3,r0,0x0080         |0x80 (will be used as bitmask)
0019ef4c: 00431807 srav r3,r3,r2            |Set consired Status bitmask
0019ef50: 00832024 and r4,r4,r3             |Check considered status
0019ef54: 10800013 beq r4,r0,0x0019efa4     #If Unit has considered status /Else  : returns r2 = 0x00
0019ef58: 34020005 ori r2,r0,0x0005             |Death ID
0019ef5c: 14c20004 bne r6,r2,0x0019ef70         #If Checked status is Jump
0019ef60: 28c20018 slti r2,r6,0x0018            |r2 = 0x1 if Status ID < 0x18 (All statuses without CT)
0019ef64: 90a2015d lbu r2,0x015d(r5)                |Load Unit's Current Ability CT
0019ef68: 08067be7 j 0x0019ef9c                     >>Jump to end
0019ef6c: 0048102a slt r2,r2,r8                     |Check if considered unit will land before next turn
                                                Else : Unit has considered status (and it is not Jump)
0019ef70: 1440000d bne r2,r0,0x0019efa8         #Branch if considered Status doesn't have a CT : returns r2 = 0x01
0019ef74: 34020001 ori r2,r0,0x0001                 |r2 = 0x01
0019ef78: 90e2004e lbu r2,0x004e(r7)            |Load Appropriate Unit Innate Status set
0019ef7c: 00000000 nop                          |
0019ef80: 00431024 and r2,r2,r3                 |Check considered status
0019ef84: 14400008 bne r2,r0,0x0019efa8         #Branch if considered Status is Innate returns r2 = 0x01
0019ef88: 34020001 ori r2,r0,0x0001                 |r2 = 0x01
0019ef8c: 00a61021 addu r2,r5,r6                |Unit Data Pointer + Status ID offset
0019ef90: 90420045 lbu r2,0x0045(r2)            |Load Considered Status' CT
0019ef94: 00000000 nop                          |
0019ef98: 0048102a slt r2,r2,r8                 |Check if Status wil fade before unit next turn
0019ef9c: 10400002 beq r2,r0,0x0019efa8         #Branch if Status will not fade before next unit turn returns r2 = 0x01
0019efa0: 34020001 ori r2,r0,0x0001                 |r2 = 0x01
0019efa4: 00001021 addu r2,r0,r0                |r2 = 0x00
0019efa8: 03e00008 jr r31                   END
0019efac: 00000000 nop

Notes

 Hardcoded 
 Jump CT check
 Status ID < 0x18 won't have their CT considered (if hacked)

Return Locations

BATTLE.BIN
00194fd4: Set_AI_ability_considerations_for_all_units_and_self 0x25 (Don't Act)
00194ffc: Set_AI_ability_considerations_for_all_units_and_self 0x0c (Silence)
00195024: Set_AI_ability_considerations_for_all_units_and_self 0x21 (Innocent)
00199938: Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted 0x1e (Stop)
00199954: Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted 0x25 (Don't Act)
00199970: Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted 0x23 (Sleep)
0019998c: Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted 0x15 (Chicken)
001999ac: Check_if_Regen/Charm/DM/Reraise/DA_Can_be_Inflicted 0x22 (Charm)
0019b864: AI_Targeting_Matrix_Analysis_(0019b7b8) 0x26 (Reflect)
0019e6f4: AI_Ability_Use_Decisions 0x26 (Reflect)
0019e71c: AI_Ability_Use_Decisions 0x21 (Innocent)
0019e734: AI_Ability_Use_Decisions 0x05 (Jump)
0019e810: AI_Ability_Use_Decisions 0x1f (Wall)
0019e918: AI_Ability_Use_Decisions 0x22 (Charm)
0019e988: AI_Ability_Use_Decisions 0x23 (Sleep)
0019edd8: AI_Ability_Use_Decisions loop (Set 4 and Set 5 ?)
0019f1c8: Status/CT_based_decision 0x1e (Stop)
0019f1e0: Status/CT_based_decision 0x24 (don't move)
0019f1f8: Status/CT_based_decision 0x23 (sleep)