Prev: D0BD Up: Map Next: D2C0
D292: Test whether a piece in a left-hand map cell ends before the play area's left edge
Used by the routine at draw_landscape.
Used by draw_landscape for each piece of the two left-hand map cells of the 2x2 window (bit 1 of the cell counter ground_cell clear). It finds the piece's rightmost x within the cell from the piece's collision box and compares it with view_x, the in-cell x that sits at the play area's left edge. A piece that ends left of it cannot be seen and is skipped without walking its steps.
The box (IX) is five bytes of a map cell's collision-box list (loader_entry, ground_cell_bottom_left, ground_cell_top_right or ground_cell_bottom_right: the view's page, the one below, right, below-right). It holds the piece's start x at +0 and, for a flat piece, its length in pixels at +2; for a sloped piece +2 holds the x of its far end, and +0 its start x (moved on by a step's width for a piece running left, direction_flag = 1). +4 is a class byte from piece_classes for the collision code (collide_with_landscape).
Input
IX Piece's collision box
B In-cell x at the play area's left edge (view_x)
Output
F Z clear (NZ) if the piece is wholly left of the edge
piece_off_left_edge D292 LD A,(piece_rise) Flat piece (no rise, piece_rise zero): right end = start x + length.
D295 AND A
D296 JR NZ,piece_off_left_edge_0
D298 LD A,(IX+$00)
D29B ADD A,(IX+$02)
D29E JR piece_off_left_edge_3
piece_off_left_edge_0 D2A0 LD A,(piece_dx_copy) A vertical wall (no run, piece_dx_copy zero) is 8 pixels wide.
D2A3 AND A
D2A4 JR NZ,piece_off_left_edge_1
D2A6 LD A,(piece_page_x)
D2A9 ADD A,$08
D2AB JR piece_off_left_edge_3
piece_off_left_edge_1 D2AD LD A,(direction_flag) A sloped piece: its right end is +0 if it runs left (direction_flag = 1), else +2.
D2B0 CP $01
D2B2 JR Z,piece_off_left_edge_2
D2B4 LD A,(IX+$02)
D2B7 JR piece_off_left_edge_3
piece_off_left_edge_2 D2B9 LD A,(IX+$00)
piece_off_left_edge_3 D2BC CP B NZ (skip) if the right end is left of the edge; Z otherwise.
D2BD RET C
D2BE XOR A
D2BF RET
Prev: D0BD Up: Map Next: D2C0