Prev: DC71 Up: Map Next: DCA8
DC79: Slow Player Down
Slows the player down when no control is used to move. The distance to the next position that is a multiple of eight units is found, and the speed is the distance (up to four units).
Input
IX Player
Heading zero.
SlowPlayerDown DC79 LD A,(IX+$03) Fetch the Y position of the player (moving up the screen).
Find the distance to the next multiple of eight.
SlowPlayerDown_Distance DC7C AND %00000111 Keep the lowest three bits.
DC7E JR Z,SlowPlayerDown_Stop Jump to SlowPlayerDown_Stop if the position is a multiple of eight.
DC80 NEG Work out the distance to the next multiple of eight units.
DC82 ADD A,$08
DC84 LD C,$04 Set a speed of four.
DC86 CP C Jump to SlowPlayerDown_Speed if the distance is four or more.
DC87 JR NC,SlowPlayerDown_Speed
Halve the greatest speed, and jump to SlowPlayerDown_Speed if the distance is two or more.
DC89 SRL C Halve the speed.
DC8B CP C Jump to SlowPlayerDown_Speed if the distance is two or more.
DC8C JR NC,SlowPlayerDown_Speed
DC8E LD C,A Use the distance.
Move the player at this speed.
SlowPlayerDown_Speed DC8F LD A,C Set the speed and move the player.
DC90 JR MovePlayer_Speed
Heading one.
SlowPlayerDown_Right DC92 LD A,(IX+$01) Fetch the X position of the player (moving right).
DC95 JR SlowPlayerDown_Distance Jump to SlowPlayerDown_Distance.
Heading two.
SlowPlayerDown_Down DC97 LD A,(IX+$03) Fetch the Y position of the player (moving down the screen).
Heading two or three.
SlowPlayerDown_Negate DC9A NEG Make it negative.
DC9C JR SlowPlayerDown_Distance Jump to SlowPlayerDown_Distance.
Heading three.
SlowPlayerDown_Left DC9E LD A,(IX+$01) Fetch the X position of the player (moving left).
DCA1 JR SlowPlayerDown_Negate Jump to SlowPlayerDown_Negate.
The player is at a multiple of eight, so the player stops.
SlowPlayerDown_Stop DCA3 LD (IX+$05),$00 Set the speed of the player to zero and return.
DCA7 RET
View the equivalent code in;
Prev: DC71 Up: Map Next: DCA8