Prev: C065 Up: Map Next: C083
C069: Check Object Close To Player
Checks whether the object at IX is within a given number of cells of the player, along both axes. The ghosts, creatures and bonuses use it to find out whether they are near enough to matter.
Input
IX Object
C Distance in cells
Output
F The carry flag is set if the object is closer than the distance
Compare the columns.
CheckPlayerClose C069 LD A,($BC90) Fetch the player's column from BC90.
C06C SUB (IX+$02) Work out how many columns the object is from the player.
C06F JP P,CheckPlayerClose_Columns Jump to CheckPlayerClose_Columns if the difference is not negative.
C072 NEG Otherwise turn the distance round, so that it is positive.
CheckPlayerClose_Columns C074 CP C Compare the distance in columns with the limit.
C075 RET NC Return with the carry flag clear if the object is too far away.
Compare the rows.
C076 LD A,($BC92) Fetch the player's row from BC92.
C079 SUB (IX+$04) Work out how many rows the object is from the player.
C07C JP P,CheckPlayerClose_Rows Jump to CheckPlayerClose_Rows if the difference is not negative.
C07F NEG Otherwise turn the distance round, so that it is positive.
CheckPlayerClose_Rows C081 CP C Compare the distance in rows with the limit.
C082 RET Return with the carry flag set only if the object is close enough.
View the equivalent code in;
Prev: C065 Up: Map Next: C083