Prev: A99F Up: Map Next: A9DD
A9C3: Move Entity
Used by the routines at TryMove and MoveDestroyer.
Moves an entity in the direction that it is heading, by up to the number of steps that is given. The entity stops at the start of a cell if the next cell is not empty. The routine keeps a copy of the position, so that a move can be undone.
Input
B Number of steps to take
DE X position
HL Y position
IX Entity
Output
A 01 if the entity has been blocked
B Number of steps that are left
DE New X position
HL New Y position
F The zero flag is reset if the entity has been blocked
MoveEntity A9C3 LD ($9653),DE Keep the X position...
A9C7 LD ($9655),HL ...and the Y position, so that the move can be undone.
A9CA LD A,(IX+$07) Fetch the direction of the entity...
A9CD AND $03 ...and jump to move in direction zero (X decreasing)...
A9CF JP Z,MoveLeft
A9D2 DEC A ...or direction one (Y increasing)...
A9D3 JP Z,MoveUp
A9D6 DEC A ...or direction two (X increasing)...
A9D7 JP Z,MoveRight
A9DA JP MoveDown ...or otherwise direction three (Y decreasing).
Prev: A99F Up: Map Next: A9DD