Prev: A498 Up: Map Next: A4DC
A4C3: Choose Direction
Used by the routine at MoveProgramPacket.
Finds a direction for a program packet to go in, which is the one that it is heading in if that is possible, and otherwise the one to the side, the opposite one, and the other side.
Input
A Direction of the packet
DE X position
HL Y position
Output
A The type of the cell, if the zero flag is set
C The direction that has been chosen
F The zero flag is set if the packet can go on
ChooseDirection A4C3 CALL TestCellInDirection Try the direction that the packet is heading in, and return if it can go there.
A4C6 RET Z
A4C7 LD A,C Try the direction before it...
A4C8 DEC A
A4C9 AND $03
A4CB CALL TestCellInDirection ...and return if the packet can go there.
A4CE RET Z
A4CF LD A,C Try the opposite direction...
A4D0 XOR $02
A4D2 CALL TestCellInDirection ...and return if the packet can go there.
A4D5 RET Z
A4D6 LD A,C Try the direction after the original one...
A4D7 INC A
A4D8 AND $03
A4DA JR TestCellInDirection Jump to TestCellInDirection.
Prev: A498 Up: Map Next: A4DC