Prev: B85C Up: Map Next: B8A9
B865: Handle Ball Up Down
Handles a ball that bounces straight up and down. It falls until it hits the floor, then it rises at a speed of 03 until it reaches the top of its bounce, which is 20 above the height at which it was first seen, and starts to fall again.
Input
IX Address of the ball object
Work out the top of the bounce if it is not already stored.
HandleBallUpDown B865 CALL SetPixelAdjustments_Ball Set the pixel adjustments of a ball.
B868 LD A,($5BBD) Fetch the height of the bounce from BallBounceHeight.
B86B AND A Test whether it has been worked out.
B86C JR NZ,HandleBallUpDown_Frame Jump to HandleBallUpDown_Frame if it has.
B86E LD A,(IX+$03) Fetch the height of the ball.
B871 ADD A,$20 Add 20 to get the height of the bounce.
B873 LD ($5BBD),A Store it at BallBounceHeight.
Fall until the ball hits the floor, then rise.
HandleBallUpDown_Frame B876 CALL ToggleGraphic Toggle the graphic of the ball between its two frames.
B879 CALL PlaySoundFromHeight Play the sound of a falling object.
B87C BIT 2,(IX+$0D) Jump to HandleBallUpDown_Rise if the ball is rising.
B880 JR NZ,HandleBallUpDown_Rise
B882 CALL ApplyGravityAndMove Apply gravity to the ball and move it.
B885 BIT 2,(IX+$0C) Jump to HandleBallUpDown_Draw if the ball has not hit the floor.
B889 JR Z,HandleBallUpDown_Draw
B88B SET 2,(IX+$0D) Flag the ball as rising.
B88F CALL PlayBumpSound Play the sound of a bounce.
HandleBallUpDown_Draw B892 JR SetDeadlyFlagsAndDraw Make the ball deadly and flag it to be drawn again.
HandleBallUpDown_Rise B894 LD (IX+$0B),$03 Set the speed in Z to 03.
B898 CALL ApplyGravityAndMove Move the ball.
B89B LD A,($5BBD) Fetch the height of the bounce from BallBounceHeight.
B89E CP (IX+$03) Compare it with the height of the ball.
B8A1 JR NC,HandleBallUpDown_Draw Jump to HandleBallUpDown_Draw if the ball is still below the top of the bounce.
B8A3 RES 2,(IX+$0D) Flag the ball as falling.
B8A7 JR HandleBallUpDown_Draw Jump to HandleBallUpDown_Draw.
Prev: B85C Up: Map Next: B8A9