Prev: B7A3 Up: Map Next: B7E7
B7A9: Handle Spiked Ball
Handles a spiked ball. It hangs in the air until, one time in sixteen, it is chosen to drop (only one ball drops at a time), and then it falls to the floor and stays there. Nothing happens while the balls are not allowed to drop.
Input
IX Address of the spiked ball object
HandleSpikedBall B7A9 CALL SetDeadlyFlags Make the spiked ball deadly.
B7AC CALL SetPixelAdjustments_Block Set the pixel adjustments of a spiked ball.
Hang in the air until this ball is chosen to drop.
B7AF LD A,($5BC0) Fetch the flag that stops the balls from dropping from SpikedBallHoldFlag.
B7B2 AND A Test it.
B7B3 RET NZ Return if the balls may not drop.
B7B4 BIT 2,(IX+$0D) Jump to HandleSpikedBall_Drop if this ball is dropping.
B7B8 JR NZ,HandleSpikedBall_Drop
B7BA LD HL,$5BBF Point HL at SpikedBallDroppingFlag.
B7BD LD A,(HL) Fetch it.
B7BE AND A Test it.
B7BF RET NZ Return if another ball is dropping.
B7C0 LD A,($5BA5) Fetch the second random seed from RandomSeed2.
B7C3 CP $10 Compare it with 10 for a one in sixteen chance.
B7C5 RET NC Return if it is not that time.
B7C6 SET 2,(IX+$0D) Flag this ball as dropping.
B7CA LD (HL),$01 Flag that a ball is dropping.
B7CC RET Return.
Make the ball fall.
HandleSpikedBall_Drop B7CD CALL ApplyGravityAndMove Apply gravity to the ball and move it.
B7D0 BIT 2,(IX+$0C) Jump to HandleSpikedBall_Landed if the ball has hit the floor.
B7D4 JR NZ,HandleSpikedBall_Landed
B7D6 CALL PlaySoundFromHeight Play the sound of a falling object.
HandleSpikedBall_Draw B7D9 JP SetWipeAndDrawFlags Flag the ball to be drawn again.
HandleSpikedBall_Landed B7DC RES 2,(IX+$0D) Flag this ball as no longer dropping.
B7E0 LD HL,$5BBF Point HL at SpikedBallDroppingFlag.
B7E3 LD (HL),$00 Flag that no ball is dropping.
B7E5 JR HandleSpikedBall_Draw Jump to HandleSpikedBall_Draw.
View the equivalent code in;
Prev: B7A3 Up: Map Next: B7E7