$80:B1EC

From ZAMN Hacking
ROM address data
Length 0x32
Type Code
Name getDirectionToTargetPosition
Description Gets the direction from the given sprite to the given target position. (Bugged, see notes)
Arguments/Return value A = [pointer16] sprite
X = [int16] target X position
Y = [int16] target Y position
Returns A = [direction] direction to target
Return type RTL

Note: This subroutine is bugged to not consider the Y components, so will only return left, right, or none. The bug happens due to a TXA instruction at $80:B208 that should have been a TAX instruction.