Prev: 43423 Up: Map Next: 43485
43459: 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 1 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 43459 LD (38483),DE Keep the X position...
43463 LD (38485),HL ...and the Y position, so that the move can be undone.
43466 LD A,(IX+7) Fetch the direction of the entity...
43469 AND 3 ...and jump to move in direction zero (X decreasing)...
43471 JP Z,MoveLeft
43474 DEC A ...or direction one (Y increasing)...
43475 JP Z,MoveUp
43478 DEC A ...or direction two (X increasing)...
43479 JP Z,MoveRight
43482 JP MoveDown ...or otherwise direction three (Y decreasing).
Prev: 43423 Up: Map Next: 43485