Prev: AFE4 Up: Map Next: B01A
AFE8: Move Actor
Works out the new position of an actor from its velocities. The velocities are signed and in units of one sixteenth of a pixel, so they are first scaled by GetWholePixels. The new position is returned in E and D and is not written to the actor record.
If the actor would move off the screen it is moved to the neighbouring room instead, using EnterRoomLeft (left), EnterRoomRight (right), EnterRoomBelow (below) or EnterRoomAbove (above). The top of the screen is at 28 the bottom at C0 and the width of the actor (held in Actor_Width) is taken into account at the right.
Input
IX Actor record
Output
D New Y position
E New X position
MoveActor AFE8 LD A,(IX+$01) Store the room of the actor in Moved_Actor_Room.
AFEB LD ($96AB),A
AFEE LD D,(IX+$04) Fetch the Y position of the actor into D.
AFF1 LD A,(IX+$06) Fetch the X velocity of the actor.
AFF4 CALL GetWholePixels Convert the X velocity to whole pixels.
AFF7 AND A Jump to MoveActorLeft if the actor is moving left.
AFF8 JP M,MoveActorLeft
The actor is moving right.
AFFB ADD A,(IX+$03) Add the X position of the actor.
AFFE LD E,A Stash the new X position in E.
AFFF LD A,($96AD) Fetch the width of the actor from Actor_Width.
B002 ADD A,E Add the new X position to find the right edge of the actor.
B003 JP C,EnterRoomRight Jump to EnterRoomRight if the actor has left the screen on the right.
This entry point is used by the routine at MoveActorLeft.
Now move the actor up or down.
MoveActor_Vertical B006 LD A,(IX+$07) Fetch the Y velocity of the actor.
B009 CALL GetWholePixels Convert the Y velocity to whole pixels.
B00C AND A Jump to MoveActorUp if the actor is moving up.
B00D JP M,MoveActorUp
B010 ADD A,(IX+$04) Add the Y position of the actor.
B013 LD D,A Stash the new Y position in D.
B014 CP $C0 Jump to EnterRoomBelow if the actor has left the screen at the bottom.
B016 JP NC,EnterRoomBelow
B019 RET Return.
Prev: AFE4 Up: Map Next: B01A