Prev: CF4F Up: Map Next: CF7E
CF5B: Scale Displacement
Used by the routine at MoveEntity.
Works out the displacement of an entity along an axis. The high byte of the speed word at EntitySpeed is multiplied by the value in BC, which is part of a direction vector, and divided by 10. The sign is taken from B.
Input
BC The part of the direction vector
Output
HL The displacement
ScaleDisplacement CF5B LD HL,($5CEA) Fetch the word at EntitySpeed into HL.
CF5E PUSH BC Remember BC.
CF5F LD D,H H moves into D.
CF60 CALL Multiply Call Multiply.
CF63 SRL H Shift H right.
CF65 RR L Rotate L right through the carry flag.
CF67 SRL H Shift H right.
CF69 RR L Rotate L right through the carry flag.
CF6B SRL H Shift H right.
CF6D RR L Rotate L right through the carry flag.
CF6F SRL H Shift H right.
CF71 RR L Rotate L right through the carry flag.
CF73 POP BC Bring back BC.
CF74 INC B Advance B.
CF75 RET NZ Return if the zero flag is reset.
CF76 LD A,L L moves into A.
CF77 CPL Invert the bits of A.
CF78 LD L,A A moves into L.
CF79 LD A,H H moves into A.
CF7A CPL Invert the bits of A.
CF7B LD H,A A moves into H.
CF7C INC HL Advance HL.
CF7D RET Return.
Prev: CF4F Up: Map Next: CF7E