Difference between revisions of "Check target type"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with "<font face='Courier New'> 00196adc: 27bdffd0 addiu r29,r29,0xffd0 00196ae0: afb10024 sw r17,0x0024(r29) 00196ae4: 00808821 addu r17,r4,r0 00196ae8: afb00020 sw r16,0x002...")
 
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
BATTLE.BIN : Check target type
 +
--------------------------------------------------------------------------------------------------
 +
Parameters : r4 is Focused Unit ID
 
   
 
   
  00196adc: 27bdffd0 addiu r29,r29,0xffd0
+
  Returns : r2 = 0x01 if Unit is Target is not targetable (from AI targeting flag)
00196ae0: afb10024 sw r17,0x0024(r29)
+
          r2 = 0x01 if Unit is Dead without reraise (dead for good)
00196ae4: 00808821 addu r17,r4,r0
+
          r2 = 0x01 if Unit is Petrified
00196ae8: afb00020 sw r16,0x0020(r29)
+
          r2 = 0x00 if none of above are true (worth to be considered ?)
00196aec: 00008021 addu r16,r0,r0
+
  --------------------------------------------------------------------------------------------------
00196af0: 3c05801a lui r5,0x801a
+
  00196c8c: 00041100 sll r2,r4,0x04          |{{f/std|Unit ID * 16}}
00196af4: 24a5f3c4 addiu r5,r5,0xf3c4
+
  00196c90: 3c01801a lui r1,0x801a            |
00196af8: 00003021 addu r6,r0,r0
+
  00196c94: 00220821 addu r1,r1,r2           |{{f/std|801a0000 + Unit offset}}
00196afc: afbf0028 sw r31,0x0028(r29)
+
  00196c98: 90230bf7 lbu r3,0x0bf7(r1)       |{{f/load|Load AI Targeting Flags/Settings}} {{f/std| 8019f3c4 + 0x182c + 0x07 + Unit Offset (Flags come from Unit Battle stats 0x16a)}}
00196b00: 90a30e2d lbu r3,0x0e2d(r5)
+
  00196c9c: 00000000 nop                     |
00196b04: 00062040 sll r4,r6,0x01
+
  00196ca0: 00031102 srl r2,r3,0x04          |{{f/std|Left nibble}}
00196b08: 000310c0 sll r2,r3,0x03
+
  00196ca4: 30420001 andi r2,r2,0x0001        |{{f/std|Check [Can't be Targeted]}}
00196b0c: 00431021 addu r2,r2,r3
+
  00196ca8: 1440000d bne r2,r0,0x00196ce0    {{f/Cond|If Focused Unit is Targetable}} /Else : branch to {{f/loc|END}}
00196b10: 000210c0 sll r2,r2,0x03
+
  00196cac: 34020001 ori r2,r0,0x0001         |{{f/std|returns 0x01}}
00196b14: 00a21021 addu r2,r5,r2
+
  00196cb0: 00031142 srl r2,r3,0x05              |
00196b18: 00821021 addu r2,r4,r2
+
  00196cb4: 30420001 andi r2,r2,0x0001            |{{f/std|Check [Dead Unit without reraise]}}
00196b1c: a4400a74 sh r0,0x0a74(r2)
+
  00196cb8: 14400009 bne r2,r0,0x00196ce0        {{f/Cond|If Unit is not Dead (or dead with reraise)}} /Else : branch to {{f/loc|END}}
00196b20: 90a30e2d lbu r3,0x0e2d(r5)
+
  00196cbc: 34020001 ori r2,r0,0x0001             |{{f/std|Returns 0x01}}
  00196b24: 24c60001 addiu r6,r6,0x0001
+
  00196cc0: 000410c0 sll r2,r4,0x03                  |
  00196b28: 000310c0 sll r2,r3,0x03
+
  00196cc4: 00441023 subu r2,r2,r4                    |
  00196b2c: 00431021 addu r2,r2,r3
+
  00196cc8: 00021180 sll r2,r2,0x06                  |{{f/std|Unit ID * 0x1c0}}
00196b30: 000210c0 sll r2,r2,0x03
+
  00196ccc: 3c018019 lui r1,0x8019                    |
  00196b34: 00a21021 addu r2,r5,r2
+
  00196cd0: 00220821 addu r1,r1,r2                   |
  00196b38: 00822021 addu r4,r4,r2
+
  00196cd4: 90220925 lbu r2,0x0925(r1)               |{{f/load|Load Unit Current Status 2nd Set}} {{f/std|0x801908cc + 0x59 + Unit offset}}
00196b3c: 28c20012 slti r2,r6,0x0012
+
  00196cd8: 00000000 nop                              |
00196b40: 1440ffef bne r2,r0,0x00196b00
+
  00196cdc: 000211c2 srl r2,r2,0x07                  |{{f/std|<nowiki>r2 = 0x1 if Unit is petrified</nowiki>}}
00196b44: a4800a98 sh r0,0x0a98(r4)
+
  00196ce0: 03e00008 jr r31                  END
00196b48: 0000c821 addu r25,r0,r0
+
  00196ce4: 00000000 nop
00196b4c: 00a0c021 addu r24,r5,r0
+
===Return Locations===
00196b50: 00a07821 addu r15,r5,r0
+
  '''BATTLE.BIN'''
00196b54: 00007021 addu r14,r0,r0
+
  00194618: [[Some_targetability_setting]]
00196b58: 90a20e3b lbu r2,0x0e3b(r5)
+
  00194808: [[Set_AI_flags_for_target_consideration]]
00196b5c: 00000000 nop
+
  00194ec0: [[Set_AI_ability_considerations_for_all_units_and_self]]
00196b60: 18400032 blez r2,0x00196c2c
+
  0019736c: [[Set_chosen_ability/target_for_AI_status]]
00196b64: 00004021 addu r8,r0,r0
+
  00198078: [[Fight_for_Life_-_Auto_Battle_(00197ff4)]]
00196b68: 01c06821 addu r13,r14,r0
+
  00199754: [[Check_for_good_units_to_target_(based_on_distance,status,coordinate)]]
00196b6c: 00004821 addu r9,r0,r0
 
00196b70: 270b03b4 addiu r11,r24,0x03b4
 
00196b74: 25ea0a74 addiu r10,r15,0x0a74
 
00196b78: 95430000 lhu r3,0x0000(r10)
 
00196b7c: 00000000 nop
 
00196b80: 10600023 beq r3,r0,0x00196c10
 
00196b84: 00000000 nop
 
00196b88: 90a20e3a lbu r2,0x0e3a(r5)
 
  00196b8c: 00000000 nop
 
  00196b90: 1840001f blez r2,0x00196c10
 
00196b94: 00003021 addu r6,r0,r0
 
00196b98: 00606021 addu r12,r3,r0
 
  00196b9c: 01603821 addu r7,r11,r0
 
00196ba0: 00cc1004 sllv r2,r12,r6
 
00196ba4: 30428000 andi r2,r2,0x8000
 
00196ba8: 10400014 beq r2,r0,0x00196bfc
 
00196bac: 00000000 nop
 
00196bb0: 90e20000 lbu r2,0x0000(r7)
 
00196bb4: 00000000 nop
 
00196bb8: 0222102a slt r2,r17,r2
 
  00196bbc: 1440000f bne r2,r0,0x00196bfc
 
00196bc0: 00000000 nop
 
  00196bc4: 90a30e2d lbu r3,0x0e2d(r5)
 
00196bc8: 34100001 ori r16,r0,0x0001
 
  00196bcc: 000310c0 sll r2,r3,0x03
 
  00196bd0: 00431021 addu r2,r2,r3
 
  00196bd4: 000210c0 sll r2,r2,0x03
 
00196bd8: 00451021 addu r2,r2,r5
 
00196bdc: 24420a74 addiu r2,r2,0x0a74
 
00196be0: 01a21021 addu r2,r13,r2
 
00196be4: 01221021 addu r2,r9,r2
 
00196be8: 34038000 ori r3,r0,0x8000
 
00196bec: 94440000 lhu r4,0x0000(r2)
 
00196bf0: 00c31807 srav r3,r3,r6
 
00196bf4: 00832025 or r4,r4,r3
 
00196bf8: a4440000 sh r4,0x0000(r2)
 
00196bfc: 90a20e3a lbu r2,0x0e3a(r5) map max x
 
  00196c00: 24c60001 addiu r6,r6,0x0001
 
00196c04: 00c2102a slt r2,r6,r2
 
00196c08: 1440ffe5 bne r2,r0,0x00196ba0
 
00196c0c: 24e70001 addiu r7,r7,0x0001
 
  00196c10: 25290002 addiu r9,r9,0x0002
 
00196c14: 256b0010 addiu r11,r11,0x0010
 
00196c18: 90a20e3b lbu r2,0x0e3b(r5) map max y
 
00196c1c: 25080001 addiu r8,r8,0x0001
 
  00196c20: 0102102a slt r2,r8,r2
 
00196c24: 1440ffd4 bne r2,r0,0x00196b78
 
  00196c28: 254a0002 addiu r10,r10,0x0002
 
00196c2c: 27180120 addiu r24,r24,0x0120
 
00196c30: 25ef0024 addiu r15,r15,0x0024
 
00196c34: 27390001 addiu r25,r25,0x0001
 
00196c38: 2b220002 slti r2,r25,0x0002
 
00196c3c: 1440ffc6 bne r2,r0,0x00196b58
 
  00196c40: 25ce0024 addiu r14,r14,0x0024
 
  00196c44: 1600000b bne r16,r0,0x00196c74
 
00196c48: 34020001 ori r2,r0,0x0001
 
  00196c4c: 90a20e2d lbu r2,0x0e2d(r5)
 
  00196c50: 34060048 ori r6,r0,0x0048
 
  00196c54: 000220c0 sll r4,r2,0x03
 
  00196c58: 00822021 addu r4,r4,r2
 
  00196c5c: 000420c0 sll r4,r4,0x03
 
00196c60: 24840a74 addiu r4,r4,0x0a74
 
  00196c64: 00a42021 addu r4,r5,r4
 
  00196c68: 0c066ac2 jal 0x0019ab08
 
  00196c6c: 24a50a74 addiu r5,r5,0x0a74
 
  00196c70: 00001021 addu r2,r0,r0
 
  00196c74: 8fbf0028 lw r31,0x0028(r29)
 
  00196c78: 8fb10024 lw r17,0x0024(r29)
 
  00196c7c: 8fb00020 lw r16,0x0020(r29)
 
00196c80: 27bd0030 addiu r29,r29,0x0030
 
00196c84: 03e00008 jr r31
 
00196c88: 00000000 nop
 
</font>
 

Latest revision as of 19:16, 14 May 2023

BATTLE.BIN : Check target type
--------------------------------------------------------------------------------------------------
Parameters : r4 is Focused Unit ID

Returns : r2 = 0x01 if Unit is Target is not targetable (from AI targeting flag)
          r2 = 0x01 if Unit is Dead without reraise (dead for good)
          r2 = 0x01 if Unit is Petrified
          r2 = 0x00 if none of above are true (worth to be considered ?)
--------------------------------------------------------------------------------------------------
00196c8c: 00041100 sll r2,r4,0x04           |Unit ID * 16
00196c90: 3c01801a lui r1,0x801a            |
00196c94: 00220821 addu r1,r1,r2            |801a0000 + Unit offset
00196c98: 90230bf7 lbu r3,0x0bf7(r1)        |Load AI Targeting Flags/Settings  8019f3c4 + 0x182c + 0x07 + Unit Offset (Flags come from Unit Battle stats 0x16a)
00196c9c: 00000000 nop                      |
00196ca0: 00031102 srl r2,r3,0x04           |Left nibble
00196ca4: 30420001 andi r2,r2,0x0001        |Check [Can't be Targeted]
00196ca8: 1440000d bne r2,r0,0x00196ce0     #If Focused Unit is Targetable /Else : branch to END
00196cac: 34020001 ori r2,r0,0x0001         |returns 0x01
00196cb0: 00031142 srl r2,r3,0x05               |
00196cb4: 30420001 andi r2,r2,0x0001            |Check [Dead Unit without reraise]
00196cb8: 14400009 bne r2,r0,0x00196ce0         #If Unit is not Dead (or dead with reraise) /Else : branch to END
00196cbc: 34020001 ori r2,r0,0x0001             |Returns 0x01
00196cc0: 000410c0 sll r2,r4,0x03                   |
00196cc4: 00441023 subu r2,r2,r4                    |
00196cc8: 00021180 sll r2,r2,0x06                   |Unit ID * 0x1c0
00196ccc: 3c018019 lui r1,0x8019                    |
00196cd0: 00220821 addu r1,r1,r2                    |
00196cd4: 90220925 lbu r2,0x0925(r1)                |Load Unit Current Status 2nd Set 0x801908cc + 0x59 + Unit offset
00196cd8: 00000000 nop                              |
00196cdc: 000211c2 srl r2,r2,0x07                   |r2 = 0x1 if Unit is petrified
00196ce0: 03e00008 jr r31                   END
00196ce4: 00000000 nop

Return Locations

BATTLE.BIN
00194618: Some_targetability_setting
00194808: Set_AI_flags_for_target_consideration
00194ec0: Set_AI_ability_considerations_for_all_units_and_self
0019736c: Set_chosen_ability/target_for_AI_status
00198078: Fight_for_Life_-_Auto_Battle_(00197ff4)
00199754: Check_for_good_units_to_target_(based_on_distance,status,coordinate)