Prev: CCBE Up: Map Next: CCE5
CCC2: Set Speeds From Heading
Turns a speed into HorizontalSpeed and VerticalSpeed from the heading of the object. Headings zero and two move vertically, one and three horizontally. Headings two and three have a negative speed.
Input
A The speed
IX The address of the object
Put the speed on the horizontal axis.
SetSpeedsFromHeading CCC2 LD H,$00 Make the speed the horizontal speed, with no vertical speed.
CCC4 LD L,A
CCC5 BIT 6,(IX+$06) Jump to SetSpeedsFromHeading_Sign if the heading is horizontal.
CCC9 JR NZ,SetSpeedsFromHeading_Sign
Put the speed on the vertical axis.
CCCB LD H,A Make the speed the vertical speed, with no horizontal speed.
CCCC LD L,$00
Make the speed negative for headings two and three.
SetSpeedsFromHeading_Sign CCCE BIT 7,(IX+$06) Jump to SetSpeedsFromHeading_Store if the heading is not two or three.
CCD2 JR Z,SetSpeedsFromHeading_Store
CCD4 LD A,L Make the horizontal speed negative.
CCD5 NEG
CCD7 LD L,A
CCD8 LD A,H Make the vertical speed negative.
CCD9 NEG
CCDB LD H,A
Store the speeds.
SetSpeedsFromHeading_Store CCDC LD A,L Set HorizontalSpeed.
CCDD LD ($A214),A
CCE0 LD A,H Set VerticalSpeed and return.
CCE1 LD ($A215),A
CCE4 RET
View the equivalent code in;
Prev: CCBE Up: Map Next: CCE5