Prev: D4CB Up: Map Next: D672
D588: Patch the flat-step blitter for the play area's edges and the piece's end caps
Used by the routine at landscape_step_loop.
Flat steps (directions 0 and 7) are three bytes wide and four rows tall, all drawn by blit_flat_step, which has three patchable JRs in its loop and two on its cut path (flat_blit_left_edge, flat_blit_left_rows). This routine resets the loop's three to draw all three columns, then patches them by the column the step starts in (the low five bits of column_address are three less than that column):
Then the piece's end caps. A flat piece carries two cap bytes (piece_extra_a for its first step, piece_extra_b for its last, read by piece_ends); bit 4 marks a cap to act on, and bit 7 is set here when it is acted on (landscape_end_pieces looks for $91 and $93). A cap's low two bits pick one of four extra graphics stored after the three variants (offset $24 + 12 * n), drawn in place of the variant. Cap $16 ($96 once seen) draws just the first column, and skips the step if that column is outside. An odd cap marks a drop at that end of the run: if the step is on a byte boundary and the horizontal scroll is moving towards that end, its address and x are kept (first_step_address, piece_kept, scratch_count) for the column fill after the piece (fill_flat_end_column).
The first step of a piece whose start cap is exactly $10 loses its first column (the first JR to flat_blit_lose_first) when the ground is off a byte boundary.
Input
C' Steps left (equal to piece_steps on the piece's first step, 1 on its last)
flat_step_clip D588 XOR A All three loop JRs to displacement 0: draw every column.
D589 LD ($E25A),A
D58C LD ($E25E),A
D58F LD ($E262),A
D592 LD A,(column_address) The step's start column.
D595 AND $1F
D597 CP $1D
D599 JR Z,flat_step_clip_0
D59B CP $1C
D59D JR Z,flat_step_clip_2
D59F CP $18
D5A1 JR Z,flat_step_clip_3
D5A3 CP $19
D5A5 JR Z,flat_step_clip_4
D5A7 LD A,(last_step_in_border) A last step hanging into the border (last_step_in_border set) is not drawn.
D5AA AND A
D5AB JP NZ,after_step_drawn_1
D5AE LD A,(piece_steps) First step, start cap $10, off a byte boundary: lose the first column.
D5B1 CP C
D5B2 JR NZ,flat_step_clip_5
D5B4 LD A,(piece_extra_a)
D5B7 CP $10
D5B9 JR NZ,flat_step_clip_5
D5BB LD A,(origin_x)
D5BE AND $07
D5C0 JR Z,flat_step_clip_5
D5C2 LD A,$EE
D5C4 JR flat_step_clip_1
flat_step_clip_0 D5C6 LD A,$33 Start column 0: from the second byte on.
flat_step_clip_1 D5C8 LD ($E25A),A
D5CB XOR A
D5CC LD ($E2AA),A
D5CF INC A
D5D0 LD ($E2A5),A
D5D3 JR flat_step_clip_5
flat_step_clip_2 D5D5 LD A,$33 Start column 31: only the third byte.
D5D7 LD ($E25A),A
D5DA LD A,$0B
D5DC LD ($E2AA),A
D5DF XOR A
D5E0 LD ($E2A5),A
D5E3 JR flat_step_clip_5
flat_step_clip_3 D5E5 LD A,$26 Start column 27: two columns.
D5E7 LD ($E262),A
D5EA JR flat_step_clip_5
flat_step_clip_4 D5EC LD A,$24 Start column 28: one column.
D5EE LD ($E25E),A
flat_step_clip_5 D5F1 LD A,(piece_steps) First step with a start cap to act on: mark it.
D5F4 CP C
D5F5 JP NZ,flat_step_clip_10
D5F8 LD A,(piece_extra_a)
D5FB BIT 4,A
D5FD JP Z,draw_step
D600 OR $80
D602 LD (piece_extra_a),A
flat_step_clip_6 D605 LD B,A An odd cap (a drop) facing the scroll's direction, on a byte boundary: keep the step's address and screen x for fill_flat_end_column.
D606 CP $96
D608 JR Z,flat_step_clip_8
D60A BIT 0,A
D60C JR Z,flat_step_clip_9
D60E CP $91
D610 LD A,(scroll_across)
D613 JR Z,flat_step_clip_7
D615 NEG
flat_step_clip_7 D617 BIT 7,A
D619 JR NZ,flat_step_clip_9
D61B LD A,(IX+$00)
D61E AND $07
D620 JR NZ,flat_step_clip_9
D622 LD A,B
D623 LD (piece_kept),A
D626 EXX
D627 LD HL,(column_address)
D62A LD (first_step_address),HL
D62D LD A,(piece_x)
D630 LD (scratch_count),A
D633 EXX
D634 JR flat_step_clip_9
flat_step_clip_8 D636 LD A,(column_address) Cap $16: one column only, or nothing if that column is outside.
D639 INC A
D63A INC A
D63B AND $1F
D63D CP $1C
D63F JP NC,after_step_drawn_2
D642 XOR A
D643 LD ($E25A),A
D646 LD ($E262),A
D649 LD A,$24
D64B LD ($E25E),A
flat_step_clip_9 D64E LD A,B Graphic offset of the cap: $24 + 12 * (cap AND 3), and on to the draw.
D64F AND $03
D651 ADD A,A
D652 ADD A,A
D653 LD B,A
D654 ADD A,A
D655 ADD A,B
D656 ADD A,$24
D658 EXX
D659 LD E,A
D65A LD D,$00
D65C JR draw_step_0
flat_step_clip_10 D65E LD A,C Last step with an end cap to act on: mark it and treat it the same way.
D65F CP $01
D661 JR NZ,draw_step
D663 LD A,(piece_extra_b)
D666 BIT 4,A
D668 JR Z,draw_step
D66A OR $80
D66C LD (piece_extra_b),A
D66F JP flat_step_clip_6
Prev: D4CB Up: Map Next: D672