Prev: C8C8 Up: Map Next: C910
C8F7: Add Speed To Position
Used by the routine at HandleBag.
Adds a signed speed to a position. The speed is multiplied by 10 so the high byte of the position is the pixel and the low byte is a fraction of a pixel.
Input
E The speed
HL The position
Output
HL The new position
Sign-extend the speed into DE.
AddSpeedToPosition C8F7 XOR A Clear A.
C8F8 BIT 7,E Jump to AddSpeedToPosition_Multiply if the speed is not negative.
C8FA JR Z,AddSpeedToPosition_Multiply
C8FC CPL Set A to FF.
Multiply the speed by 10 and add it.
AddSpeedToPosition_Multiply C8FD LD D,A Put the high byte in D.
C8FE SLA E Multiply the speed by 10.
C900 RL D
C902 SLA E
C904 RL D
C906 SLA E
C908 RL D
C90A SLA E
C90C RL D
C90E ADD HL,DE Add it to the position and return.
C90F RET
Prev: C8C8 Up: Map Next: C910