Prev: BC12 Up: Map Next: BC5B
BC13: Test a part against a slope, and bounce off it
Used by the routine at next_part_boxes.
One slope a pass (piece_ceiling bit 4). test_landscape_piece tests the part against the slope's shape and leaves in touch_depth how far into it the part is. A shot that hits stops; the ship sets trail_collision to $FE. Then the speed is reflected, by the slope's kind and facing: a 45-degree slope swaps the speeds across and up (bounce_45_negate, bounce_45_swap_only), any other mixes them with factors of 3/8 and 3/4 (bounce_shallow_negate, bounce_shallow).
Input
IX the box
hit_slope BC13 LD A,(piece_ceiling) a slope already hit this pass
BC16 BIT 4,A
BC18 JP NZ,next_box
BC1B CALL test_landscape_piece the shape test (test_landscape_piece)
BC1E LD A,(scratch_count)
BC21 AND A
BC22 JP Z,next_box
BC25 LD A,(piece_ceiling) a slope hit; a shot: stop
BC28 OR $10
BC2A LD (piece_ceiling),A
BC2D LD A,(piece_step_x)
BC30 CP $80
BC32 JP Z,next_box_2
BC35 AND A the ship: trail_collision = $FE
BC36 JR Z,hit_slope_0
BC38 DEC A
BC39 LD (trail_collision),A
hit_slope_0 BC3C LD A,(IX+$04) kind 2, facing bit 6 clear: swap and negate
BC3F LD (pieces_left),A
BC42 AND $7F
BC44 CP $02
BC46 JP Z,bounce_45_negate
BC49 AND $07 kind 2, facing bit 6 set: swap
BC4B CP $02
BC4D JP Z,bounce_45_swap_only
BC50 LD A,(IX+$04) other kinds, by bit 6
BC53 BIT 6,A
BC55 JP Z,bounce_shallow_negate
BC58 JP bounce_shallow
Prev: BC12 Up: Map Next: BC5B