Prev: 53071 Up: Map Next: 53118
53083: 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 16. The sign is taken from B.
Input
BC The part of the direction vector
Output
HL The displacement
ScaleDisplacement 53083 LD HL,(23786) Fetch the word at EntitySpeed into HL.
53086 PUSH BC Remember BC.
53087 LD D,H H moves into D.
53088 CALL Multiply Call Multiply.
53091 SRL H Shift H right.
53093 RR L Rotate L right through the carry flag.
53095 SRL H Shift H right.
53097 RR L Rotate L right through the carry flag.
53099 SRL H Shift H right.
53101 RR L Rotate L right through the carry flag.
53103 SRL H Shift H right.
53105 RR L Rotate L right through the carry flag.
53107 POP BC Bring back BC.
53108 INC B Advance B.
53109 RET NZ Return if the zero flag is reset.
53110 LD A,L L moves into A.
53111 CPL Invert the bits of A.
53112 LD L,A A moves into L.
53113 LD A,H H moves into A.
53114 CPL Invert the bits of A.
53115 LD H,A A moves into H.
53116 INC HL Advance HL.
53117 RET Return.
Prev: 53071 Up: Map Next: 53118