Check if Unit can be Targeted (Cryst/Trea/Mount/Trans)
Jump to navigation
Jump to search
BATTLE.BIN : Check if Unit can be Targeted (Cryst/Trea/Mount/Trans) ------------------------------------------------------------------------------------------ Parameters - r4 : Unit ID Returns r2 = 0x00 if Unit can be hitted/targeted r2 = 0x01 if Unit can't be targeted (Crystal, Treasure, Ridden, Enemy Transparent) Note : There is a weird control of transparent unit riding a transparent unit. ----------------------------------------------------------------------------------------- 00196ce8: 3c06801a lui r6,0x801a | 00196cec: 24c6f3c4 addiu r6,r6,0xf3c4 |r6 = AI Data Pointer 00196cf0: 000410c0 sll r2,r4,0x03 |ID * 8 00196cf4: 00441023 subu r2,r2,r4 |ID * 7 00196cf8: 00021180 sll r2,r2,0x06 |Unit ID * 0x1c0 00196cfc: 3c038019 lui r3,0x8019 | 00196d00: 246308cc addiu r3,r3,0x08cc | 00196d04: 00432821 addu r5,r2,r3 |r5 = Unit's Data Pointer 00196d08: 90a30001 lbu r3,0x0001(r5) |Load Unit's ID 00196d0c: 340200ff ori r2,r0,0x00ff | 00196d10: 10620025 beq r3,r2,0x00196da8 #If Unit doesn't exists : Returns r2 = 0x01 00196d14: 34020001 ori r2,r0,0x0001 | 00196d18: 94a20058 lhu r2,0x0058(r5) |Load Current Statuses 1+2 00196d1c: 00000000 nop | 00196d20: 30420140 andi r2,r2,0x0140 |Check [Crystal] and [Treasure] 00196d24: 14400020 bne r2,r0,0x00196da8 #If Unit is Crystal or Treasure: Returns r2 = 0x01 00196d28: 34020001 ori r2,r0,0x0001 | 00196d2c: 90a30182 lbu r3,0x0182(r5) |Load Unit's Mount Info 00196d30: 00000000 nop | 00196d34: 30620040 andi r2,r3,0x0040 |Check [Being Ridden] 00196d38: 1440001b bne r2,r0,0x00196da8 #If Unit is a mount : Returns r2 = 0x01 00196d3c: 34020001 ori r2,r0,0x0001 | 00196d40: 00041100 sll r2,r4,0x04 |Unit ID * 16 00196d44: 00461021 addu r2,r2,r6 |8019f3c4 + Unit Offset 00196d48: 90421834 lbu r2,0x1834(r2) |Load Enemy flag 8019f3c4 + 0x182c + 0x08 + Unit offset 00196d4c: 00000000 nop | 00196d50: 10400015 beq r2,r0,0x00196da8 #If This Unit has the enemy flag /Else : Returns r2 = 0x00 00196d54: 00001021 addu r2,r0,r0 | 00196d58: 90a2005a lbu r2,0x005a(r5) |Load Current Statuses 3 00196d5c: 00000000 nop | 00196d60: 30420010 andi r2,r2,0x0010 |Check [Transparent] 00196d64: 1040000f beq r2,r0,0x00196da4 #If Unit is transparent : /Else : Returns r2 = 0x00 00196d68: 30620080 andi r2,r3,0x0080 |Check [Is riding] 00196d6c: 1040000b beq r2,r0,0x00196d9c #If Unit is riding /Else : Returns r2 = 0x01 00196d70: 3062000f andi r2,r3,0x000f |r2 = Mount ID 00196d74: 000218c0 sll r3,r2,0x03 | 00196d78: 00621823 subu r3,r3,r2 | 00196d7c: 00031980 sll r3,r3,0x06 |Mount ID * 0x1c0 00196d80: 3c018019 lui r1,0x8019 | 00196d84: 00230821 addu r1,r1,r3 |Part of mount data pointer 00196d88: 90220926 lbu r2,0x0926(r1) |Load Mount's Current Statuses 3 00196d8c: 00000000 nop | 00196d90: 30420010 andi r2,r2,0x0010 |Check [Transparent] 00196d94: 14400004 bne r2,r0,0x00196da8 #If Mount is Transparent Returns r2 = 0x00 ?? Why ? 00196d98: 00001021 addu r2,r0,r0 |r2 = 0 (Success) 00196d9c: 08065b6a j 0x00196da8 #E |>>Returns 0x01 00196da0: 34020001 ori r2,r0,0x0001 | #Else : Not transparent Unit 00196da4: 00001021 addu r2,r0,r0 |r2 = 0 (Success) 00196da8: 03e00008 jr r31 END 00196dac: 00000000 nop
Notes
Emmy on line 00196d94 : Is this supposed to be a beq? Makes more sense for both being invisible failing* If a unit is transparent, the routine checks the ridding byte : - If riding a transparent mount --> Returns 0x00 (success ??) - If riding a non transparent mount --> returns 0x01 (fail)
Return Locations
BATTLE.BIN 0019436c: Set_type_of_target_for_all_targets 001991b8: Calculate_Physical?_Target 0019deb4: AI_ability_processing