Prev: CC53 Up: Map Next: CC8A
CC5B: Slow Player Down
Works out the speed when the sheriff is not walking, from the distance to the next multiple of eight. Headings zero and two use the vertical position, one and three the horizontal. The speed is four, two or one. If he is already at a multiple of eight he stops.
Input
IX The address of the sheriff
Heading zero.
SlowPlayerDown CC5B LD A,(IX+$03) Fetch the vertical position.
Find the distance to the next multiple of eight.
SlowPlayerDown_Distance CC5E AND %00000111 Keep the lowest three bits.
CC60 JR Z,SlowPlayerDown_Stop Jump to SlowPlayerDown_Stop if the position is a multiple of eight.
CC62 NEG Find the distance to the next multiple of eight.
CC64 ADD A,$08
CC66 LD C,$04 Set a speed of four.
CC68 CP C Jump to SlowPlayerDown_Speed if the distance is four or more.
CC69 JR NC,SlowPlayerDown_Speed
CC6B SRL C Halve the speed.
CC6D CP C Jump to SlowPlayerDown_Speed if the distance is two or more.
CC6E JR NC,SlowPlayerDown_Speed
CC70 LD C,A Use the distance.
Move the sheriff at this speed.
SlowPlayerDown_Speed CC71 LD A,C Jump to MovePlayerForward.
CC72 JR MovePlayerForward
Heading one.
SlowPlayerDown_One CC74 LD A,(IX+$01) Fetch the horizontal position.
CC77 JR SlowPlayerDown_Distance Jump to SlowPlayerDown_Distance.
Heading two.
SlowPlayerDown_Two CC79 LD A,(IX+$03) Fetch the vertical position.
Heading two or three.
SlowPlayerDown_Negate CC7C NEG Make it negative.
CC7E JR SlowPlayerDown_Distance Jump to SlowPlayerDown_Distance.
Heading three.
SlowPlayerDown_Three CC80 LD A,(IX+$01) Fetch the horizontal position.
CC83 JR SlowPlayerDown_Negate Jump to SlowPlayerDown_Negate.
The sheriff is at a multiple of eight, so he stops.
SlowPlayerDown_Stop CC85 LD (IX+$05),$00 Set the speed to zero and return.
CC89 RET
View the equivalent code in;
Prev: CC53 Up: Map Next: CC8A