Prev: 26542 Up: Map Next: 26861
26845: Calculate Midges Movement
Used by the routine at UpdateMidges.
Prepares for the movement of the midges along one axis: a 16-bit value which has the position in H and the fraction of a pixel in L, and a distance to move which is 32 times the speed (so the distance is up to 480 which is just under two pixels).
Input
B The fraction of a pixel (in the high nibble)
C The speed
H The position
Output
DE The distance to move
HL The position and the fraction
CalculateMidgesMovement 26845 LD L,B L=the fraction.
26846 LD A,C Multiply the speed by sixteen.
26847 RLA
26848 RLA
26849 RLA
26850 RLA
26851 AND 240
26853 LD E,A E=the speed multiplied by sixteen.
26854 LD D,0 Clear the high byte of the distance in D.
26856 SLA E Double DE.
26858 RL D
26860 RET Return.
Prev: 26542 Up: Map Next: 26861