Prev: BA8D Up: Map Next: BC12
BA8F: Test a part against a solid block, and bounce
Used by the routine at next_part_boxes.
The block is tested only if the record is moving into it: a floor (kind bit 2 set) when it moves down or not at all (last_speed_up, the climb speed it had last pass negated, so positive while it falls), a ceiling (bit 2 clear: bit 3 is set) when it moves up or not at all, a wall by its speed across (last_speed_across; bit 4 of the kind says which way). Then the boxes are tested for overlap (boxes_overlap). A shot that hits stops there.
Floors and ceilings: the climb speed is reversed and halved (negate_hl, halve_hl), clamped (clamp_object_speed) and dropped if small (dead_band). For the ship the new speed sets this pass's step at once (move_ship's second entry) with a bump (sound_crackle). An object hitting it has its screen fields cleared and, on a floor (bit 3 clear), its bottom line put 20 above the box's; one that has stopped under a ceiling is given a speed of 2 downwards (+9 = $FE while the collision code has its speeds turned round), so that it drops away. A ship hitting a ceiling (bit 3) without add-on 9 sets trail_hold to 4 (counted down in draw_trail).
Walls: the speed across reversed; for the ship halved, clamped and dropped if small, then this pass's step across worked out again (accelerate_across's second entry) with a sound (sound_buzz), and trail_collision set.
Also, before any of this, for the ship: a floor (bit 2) whose bottom line is 0 to 40 below the ship's and which spans part of x+4 to x+40 sets lift_jet_skip, which stops lift_jet drawing the lift jet below the ship that add-on 5 brings -- unless add-on 2 is fitted.
Every branch ran in the build's sessions, the bit-3 boxes, the walls and the hop included.
Input
IX the box
hit_block BA8F LD A,(piece_ceiling) a block already hit this pass
BA92 BIT 7,A
BA94 JP NZ,next_box
BA97 LD HL,(box_x) HL = the part's x and bottom line; a shot: just test
BA9A LD A,(piece_step_x)
BA9D CP $80
BA9F JR Z,hit_block_6
BAA1 LD A,(piece_step_x) an object
BAA4 INC A
BAA5 JP NZ,hit_block_2
BAA8 LD A,L the ship: the span under it, x+4 to x+40
BAA9 ADD A,$04
BAAB CP $E8
BAAD JR C,hit_block_0
BAAF LD A,$E8
hit_block_0 BAB1 LD D,A
BAB2 ADD A,$24
BAB4 JR NC,hit_block_1
BAB6 LD A,$F8
hit_block_1 BAB8 LD E,A
BAB9 BIT 2,(IX+$04) a floor (bit 2) under that span, 0 to 40 lines down, and no add-on 2: lift_jet_skip
BABD JR Z,hit_block_2
BABF LD A,(addon_two)
BAC2 AND A
BAC3 JR NZ,hit_block_2
BAC5 LD A,(IX+$01)
BAC8 SUB H
BAC9 JR C,hit_block_2
BACB CP $29
BACD JR NC,hit_block_2
BACF LD A,(IX+$00)
BAD2 CP E
BAD3 JR NC,hit_block_2
BAD5 ADD A,(IX+$02)
BAD8 CP D
BAD9 JR C,hit_block_2
BADB LD (lift_jet_skip),A
hit_block_2 BADE LD A,(IX+$04) a wall?
BAE1 AND $30
BAE3 JR NZ,hit_block_4
BAE5 LD A,(last_speed_up) a floor or ceiling: tested only if the record moves into it
BAE8 AND A
BAE9 JR Z,hit_block_6
BAEB BIT 2,(IX+$04)
BAEF JR NZ,hit_block_3
BAF1 NEG
hit_block_3 BAF3 BIT 7,A
BAF5 JP NZ,next_box
BAF8 JR hit_block_6
hit_block_4 BAFA BIT 4,A a wall: likewise, across
BAFC LD A,(last_speed_across)
BAFF JR NZ,hit_block_5
BB01 NEG
hit_block_5 BB03 AND A
BB04 JR Z,hit_block_6
BB06 BIT 7,A
BB08 JP Z,next_box
BB0B JR hit_block_6
hit_block_6 BB0D LD DE,(box_height) do they overlap (boxes_overlap)?
BB11 CALL boxes_overlap
BB14 LD A,(scratch_count)
BB17 AND A
BB18 JP Z,next_box
BB1B LD A,(piece_step_x) a shot: stop
BB1E CP $80
BB20 JP Z,next_box_2
BB23 LD A,$80 a block hit; the box's bottom line less 20, and its kind
BB25 LD (piece_ceiling),A
BB28 LD A,(IX+$01)
BB2B SUB $14
BB2D LD (current_piece),A
BB30 LD A,(IX+$04) IX the record again; a wall?
BB33 LD ($DEDD),A
BB36 LD B,A
BB37 AND $30
BB39 LD IX,(collision_object)
BB3D JP NZ,hit_block_11
BB40 LD A,(piece_step_x) the ship hitting a ceiling (bit 3) without add-on 9: trail_hold = 4
BB43 AND A
BB44 JR Z,hit_block_7
BB46 BIT 3,B
BB48 JR Z,hit_block_8
BB4A LD A,(addon_nine)
BB4D AND A
BB4E JR NZ,hit_block_8
BB50 LD A,$04
BB52 LD (trail_hold),A
BB55 JR hit_block_8
hit_block_7 BB57 CALL clear_screen_fields an object: clear its screen fields; on a floor, sit it 20 above the box's bottom
BB5A BIT 3,B
BB5C JR NZ,hit_block_8
BB5E LD A,(current_piece)
BB61 LD (IX+$05),A
hit_block_8 BB64 LD H,(IX+$09) the climb speed reversed, halved, clamped, dropped if small; keep it
BB67 LD L,(IX+$0A)
BB6A CALL negate_hl
BB6D CALL halve_hl
BB70 CALL clamp_object_speed
BB73 CALL dead_band
BB76 LD (IX+$09),H
BB79 LD (IX+$0A),L
BB7C LD A,H
BB7D LD (last_speed_up),A
BB80 OR L still moving: a bounce
BB81 JR Z,hit_block_9
BB83 LD A,(piece_ceiling)
BB86 OR $40
BB88 LD (piece_ceiling),A
BB8B JR hit_block_10
hit_block_9 BB8D LD A,(piece_step_x) stopped: an object under a ceiling drops away at 2
BB90 INC A
BB91 JR Z,hit_block_10
BB93 BIT 3,B
BB95 JP Z,next_box
BB98 LD (IX+$09),$FE
hit_block_10 BB9C LD A,(piece_step_x) the ship: a bump; this pass's step from the new speed
BB9F INC A
BBA0 JP NZ,next_box
BBA3 LD A,L
BBA4 OR H
BBA5 CALL NZ,sound_crackle
BBA8 LD DE,$0000
BBAB LD (climb_fraction),DE
BBAF CALL move_ship_7
BBB2 LD A,($DEDD) a box of kind exactly 4 (the flat floor), and the ship's line below the box's bottom less 20: this pass's step up is 2
BBB5 CP $04
BBB7 JP NZ,next_box
BBBA LD A,(view_page_y)
BBBD LD B,A
BBBE LD A,(current_piece)
BBC1 CP B
BBC2 JP NC,next_box
BBC5 LD A,$02
BBC7 LD (scroll_down),A
BBCA JP next_box
hit_block_11 BBCD LD H,(IX+$07) a wall: the speed across reversed; an object just has its screen fields cleared
BBD0 LD L,(IX+$08)
BBD3 CALL negate_hl
BBD6 LD A,(piece_step_x)
BBD9 AND A
BBDA JR NZ,hit_block_12
BBDC CALL clear_screen_fields
BBDF JR hit_block_13
hit_block_12 BBE1 CALL halve_hl the ship: halved, clamped, dropped if small; keep it
BBE4 CALL clamp_object_speed
BBE7 CALL dead_band
hit_block_13 BBEA LD (IX+$07),H
BBED LD (IX+$08),L
BBF0 LD A,H
BBF1 LD (last_speed_across),A
BBF4 LD A,(piece_step_x) the ship: a sound; this pass's step across again; trail_collision
BBF7 INC A
BBF8 JP NZ,next_box
BBFB LD A,L
BBFC OR H
BBFD CALL NZ,sound_buzz
BC00 LD DE,$0000
BC03 LD (ship_position_across),DE
BC07 CALL speed_to_scroll
BC0A LD A,$01
BC0C LD (trail_collision),A
BC0F JP next_box
Prev: BA8D Up: Map Next: BC12