Prev: B5F7 Up: Map Next: B626
B5FF: Bouncing ball (types 182 and 183)
The ball_bounce block (ball_bounce). Falls under gravity, and every time it lands it jumps again and picks a new heading: two units a frame along X or along Y, chosen at random, pointing towards the player if the player is Sabrewulf and away if he is Sabreman. It keeps that heading all the way through the air, however often a wall stops it. The frame flips between the two types every frame, and it kills on contact.
Which way "towards" means is decided by patching two JR instructions rather than by testing: see bounce_ball_set_sense.
upd_182_183 B5FF CALL upd_12_to_15 pixel offsets for the ball sprite
B602 LD L,(IX+$09) keep dX and dY
B605 LD H,(IX+$0A)
B608 PUSH HL
B609 LD A,(IX+$0B) remember dZ from before the move, for the bounce sound
B60C LD ($5BC2),A
B60F CALL dec_dZ_and_update_XYZ gravity, then move, clipped against the room and other objects
B612 POP HL put dX and dY back: the clipping may have cut them, but the ball keeps its heading until it bounces
B613 LD (IX+$09),L
B616 LD (IX+$0A),H
B619 LD A,($5C08) object 0's type is the player's legs: 16 to 29 for Sabreman gives $38 (JR C), anything else $30 (JR NC)
B61C SUB $10
B61E CP $20
B620 LD A,$30
B622 JR NC,bounce_ball_set_sense
B624 ADD A,$08
Prev: B5F7 Up: Map Next: B626