Prev: EE29 Up: Map Next: EE54
EE42: Move Object Horizontally
Used by the routines at Handle_Flying_Creature and Handle_Carrying_Eagle.
Adds a velocity to the x position of an object. The velocity is multiplied by sixteen and added to the x position and its fraction (byte 0A of the record), so that the position changes by a sixteenth of the velocity in each call. The new x position is returned, but it is not stored in the record: that is up to the caller.
Input
HL The x velocity, with the sign extended to sixteen bits
IX Object record
Output
A The new x position
F The zero flag is set if the new x position is less than 80
Move_Object_Horizontally EE42 ADD HL,HL Multiply the velocity by sixteen.
EE43 ADD HL,HL
EE44 ADD HL,HL
EE45 ADD HL,HL
EE46 LD C,(IX+$0A) Fetch the fraction of the x position.
EE49 LD B,(IX+$01) Fetch the x position.
EE4C ADD HL,BC Add the velocity to the position.
EE4D LD (IX+$0A),L Store the new fraction.
EE50 LD A,H Fetch the new x position.
EE51 BIT 7,A Test bit 7 of the new x position.
EE53 RET Return.
Prev: EE29 Up: Map Next: EE54