Prev: A218 Up: Map Next: A2AD
A282: Find Direction To Robot
Used by the routines at MoveThief and MoveHunter.
Chooses a direction for an enemy, at random, that heads towards the robot in either the X direction or the Y direction.
Input
IX Entity
Output
A Direction (00 to 03)
FindDirectionToRobot A282 LD A,($9617) Fetch the random number.
A285 CP $80 Jump to use the Y direction if the number is below 80.
A287 JR C,FindDirectionToRobot_Y
A289 LD A,($9692) Fetch the X cell of the camera...
A28C SUB (IX+$02) ...and subtract the X cell of the entity.
A28F AND $3F Limit the difference to 00-3F.
A291 CP $20 Jump if the robot is less than 20 cells ahead.
A293 JR C,FindDirectionToRobot_DirectionTwo
A295 LD A,$00 Otherwise use direction zero...
A297 RET ...and return.
FindDirectionToRobot_DirectionTwo A298 LD A,$02 Use direction two...
A29A RET ...and return.
FindDirectionToRobot_Y A29B LD A,($9694) Fetch the Y cell of the camera...
A29E SUB (IX+$04) ...and subtract the Y cell of the entity.
A2A1 AND $3F Limit the difference to 00-3F.
A2A3 CP $20 Jump if the robot is less than 20 cells ahead.
A2A5 JR C,FindDirectionToRobot_DirectionOne
A2A7 LD A,$03 Otherwise use direction three...
A2A9 RET ...and return.
FindDirectionToRobot_DirectionOne A2AA LD A,$01 Use direction one...
A2AC RET ...and return.
Prev: A218 Up: Map Next: A2AD