Prev: 42136 Up: Map Next: 42204
42179: 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 42179 CALL TestCellInDirection Try the direction that the packet is heading in, and return if it can go there.
42182 RET Z
42183 LD A,C Try the direction before it...
42184 DEC A
42185 AND 3
42187 CALL TestCellInDirection ...and return if the packet can go there.
42190 RET Z
42191 LD A,C Try the opposite direction...
42192 XOR 2
42194 CALL TestCellInDirection ...and return if the packet can go there.
42197 RET Z
42198 LD A,C Try the direction after the original one...
42199 INC A
42200 AND 3
42202 JR TestCellInDirection Jump to TestCellInDirection.
Prev: 42136 Up: Map Next: 42204