Difference between revisions of "Check if unit can react?"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
  r5 = set to check
+
  Parameters : r4 = unit data pointer
r4 = target data pointer  
+
  Returns r2 = 0x01 if target has one of the checked statuses, else 0x00
+
  Returns r2 = 0x00 if unit can react, if not r2 = 0x01
  ---------------------------------------------------------------------------------------------------
+
   
  0005e1b0: 00003021 addu r6,r0,r0            |{{f/std|<nowiki>r6 = 0x00 (loop counter)</nowiki>}}
+
  0018c968: 3c028019 lui r2,0x8019            |
0005e1b4: 3c038006 lui r3,0x8006            |
+
0018c96c: 8c42f5f0 lw r2,-0x0a10(r2)        |{{f/load|<nowiki>r2 = type of action ( 0x8018F5F0 )</nowiki>}} {{f/std|<nowiki>8018F5F0</nowiki>}}
0005e1b8: 246362d0 addiu r3,r3,0x62d0      |{{f/std|<nowiki>r3 = 800662d0</nowiki>}}
+
  0018c970: 27bdffe8 addiu r29,r29,0xffe8    |
  0005e1bc: 00051080 sll r2,r5,0x02          |{{f/std|<nowiki>Preset Value * 4</nowiki>}}
+
  0018c974: 14400005 bne r2,r0,0x0018c98c    {{f/Cond|<nowiki>If not a reaction (r2 = 0x00)</nowiki>}} /If already reacting branch near end setting r2 to 0x01 (skip check by jal below)
  0005e1c0: 00451021 addu r2,r2,r5            |{{f/std|<nowiki>Preset Value * 5</nowiki>}}
+
  0018c978: afbf0010 sw r31,0x0010(r29)           |
  0005e1c4: 00432821 addu r5,r2,r3           |{{f/std|<nowiki>r5 = 800662d0 + preset value *5</nowiki>}}
+
  0018c97c: 0c01786c jal 0x0005e1b0                |-->[[Status Checks (r5 = set to check)|<span style="color:blue">Status Checks (r5 = set to check)</span>]] - returns r2= 0 (no status found) or r2=1 (status preventing reaction has been found)
  0005e1c8: 00861021 addu r2,r4,r6            {{f/bloop|<nowiki> LOOP</nowiki>}} {{f/std|<nowiki>r2 = target data pointer + loop counter</nowiki>}}
+
  0018c980: 34050004 ori r5,r0,0x0004              |{{f/std|<nowiki>r5 = 0x04</nowiki>}} {{f/jal|Status_Check_table_-_0x800662d0|<nowiki>Status_Check_table_-_0x800662d0</nowiki>}}
  0005e1cc: 90420058 lbu r2,0x0058(r2)             |{{f/load|<nowiki>r2 = target current status set X (X = loop counter)</nowiki>}}
+
  0018c984: 08063264 j 0x0018c990                 {{f/jump|<nowiki>jump to end</nowiki>}}
  0005e1d0: 90a30000 lbu r3,0x0000(r5)            |{{f/load|<nowiki>r3 = statuses to check</nowiki>}} {{f/jal|Status_Check_table_-_0x800662d0|<nowiki>Status_Check_table_-_0x800662d0</nowiki>}}
+
  0018c988: 00000000 nop                          |
  0005e1d4: 00000000 nop                          |
+
  0018c98c: 34020001 ori r2,r0,0x0001         |r2 = 0x01
0005e1d8: 00431024 and r2,r2,r3                 |{{f/std|<nowiki>r2 <> 0x00 if target as one of the checked statuses</nowiki>}}
+
0018c990: 8fbf0010 lw r31,0x0010(r29)       |
  0005e1dc: 14400006 bne r2,r0,0x0005e1f8          {{f/Cond|<nowiki>If none of the checked status is found </nowiki>}} /If target has one of the statuses {{f/loc|<nowiki>branch to end (with r2 = 0x01)</nowiki>}}
+
  0018c994: 27bd0018 addiu r29,r29,0x0018   
  0005e1e0: 34020001 ori r2,r0,0x0001             |{{f/std|<nowiki>r2 = 1 (statuses found)</nowiki>}}
+
0018c998: 03e00008 jr r31                 
  0005e1e4: 24c60001 addiu r6,r6,0x0001                |{{f/std|<nowiki>Loop counter + 1 </nowiki>}}
+
  0018c99c: 00000000 nop
  0005e1e8: 28c20005 slti r2,r6,0x0005                |{{f/std|<nowiki>r2 = 0x01 if counter < 0x05 - else 0x00</nowiki>}}
+
  0005e1ec: 1440fff6 bne r2,r0,0x0005e1c8    {{f/eloop|<nowiki>Loop while counter < 0x05 </nowiki>}} /Else goto r2 = 0x00 then exit the routine
+
==Return locations ==
  0005e1f0: 24a50001 addiu r5,r5,0x0001            |{{f/std|<nowiki>Checking status pointer +1</nowiki>}}
+
  0017e094: [[Big..._Contains_Hamedo_check]]
  0005e1f4: 00001021 addu r2,r0,r0            |{{f/std|<nowiki>r2 = 0 (statuses not found)</nowiki>}}
+
0017e214: [[Main_reaction_routine%3F]]
  0005e1f8: 03e00008 jr r31                 
+
  0018c934: [[Check_if_unit_can_react_1]]
  0005e1fc: 00000000 nop
+
  0018ca90: [[%27Reflect%27,_Blade_Grasp,_and_Arrow_Guard]]
 +
  001825c8: [[Monster_Skill_check]]
 +
  0018f060: [[Mimic_ability_setting]]

Latest revision as of 20:02, 24 May 2024

Parameters : r4 = unit data pointer

Returns r2 = 0x00 if unit can react, if not r2 = 0x01

0018c968: 3c028019 lui r2,0x8019            |
0018c96c: 8c42f5f0 lw r2,-0x0a10(r2)        |r2 = type of action ( 0x8018F5F0 ) 8018F5F0
0018c970: 27bdffe8 addiu r29,r29,0xffe8     |
0018c974: 14400005 bne r2,r0,0x0018c98c     #If not a reaction (r2 = 0x00) /If already reacting branch near end setting r2 to 0x01 (skip check by jal below)
0018c978: afbf0010 sw r31,0x0010(r29)            |
0018c97c: 0c01786c jal 0x0005e1b0                |-->Status Checks (r5 = set to check)  - returns r2= 0 (no status found) or r2=1 (status preventing reaction has been found)
0018c980: 34050004 ori r5,r0,0x0004              |r5 = 0x04 -->Status_Check_table_-_0x800662d0
0018c984: 08063264 j 0x0018c990                  >>jump to end
0018c988: 00000000 nop                           |
0018c98c: 34020001 ori r2,r0,0x0001         |r2 = 0x01 
0018c990: 8fbf0010 lw r31,0x0010(r29)       |
0018c994: 27bd0018 addiu r29,r29,0x0018     
0018c998: 03e00008 jr r31                   
0018c99c: 00000000 nop

Return locations

0017e094: Big..._Contains_Hamedo_check
0017e214: Main_reaction_routine?
0018c934: Check_if_unit_can_react_1
0018ca90: 'Reflect',_Blade_Grasp,_and_Arrow_Guard
001825c8: Monster_Skill_check
0018f060: Mimic_ability_setting