Prev: F900 Up: Map Next: F9AC
F939: Make a slope piece's shifted copies
Used by the routine at build_shifted_pieces.
For build_shifted_pieces, the slopes and the wall. A slope is made one byte wider than its graphic, row by row, the rows alternating left to right and right to left like the blitters that draw them; the open side of each row is filled with the checkerboard's bits ($55 on rows made left to right, $AA on the others), on the right normally and on the left for the ceilings (piece_step_x set). The header's first count (row_count) cuts the zig-zag after each variant: a variant of 9 rows is 5 rows left to right and 4 back, so every variant begins with a row made left to right, as the blitter starting there expects.
The pieces' graphics are packed so tightly that each copy reads a few bytes past its graphic's end (into the next graphic's header, or into the first copy made), giving a fourth, partial variant that the game never draws.
Input
HL the piece's header (three bytes; see read_piece_header)
HL' where the copy shifted by 2 goes; the copies shifted by 4 and 6 follow it directly
shift_slope_piece F939 CALL read_piece_header Read the header
shift_slope_piece_0 F93C PUSH HL Back here for each shift
shift_slope_piece_1 F93D LD B,C A row left to right; ceilings: the checkerboard on the left first
F93E LD A,(piece_step_x)
F941 AND A
F942 JR Z,shift_slope_piece_2
F944 LD E,$55
F946 INC D
F947 LD A,(DE)
F948 DEC D
F949 EXX
F94A OR (HL)
F94B LD (HL),A
F94C EXX
shift_slope_piece_2 F94D CALL shift_byte_forward The row's bytes shifted in
F950 INC HL
F951 DJNZ shift_slope_piece_2
F953 LD A,(piece_step_x) Ceilings: the right-hand byte is left with the spill only
F956 AND A
F957 JR Z,shift_slope_piece_3
F959 EXX
F95A INC HL
F95B EXX
F95C JR shift_slope_piece_4
shift_slope_piece_3 F95E CALL pad_right_checker Floors: the checkerboard's bits on the right
shift_slope_piece_4 F961 LD A,(row_count) The variant's last row? Then no row back
F964 DEC A
F965 LD (row_count),A
F968 JR Z,shift_slope_piece_8
F96A LD A,(piece_step_x) A row right to left; first style: the checkerboard on the right first
F96D AND A
F96E JR NZ,shift_slope_piece_5
F970 LD E,$AA
F972 LD A,(DE)
F973 CALL shift_byte_high_0
shift_slope_piece_5 F976 LD B,C The row's bytes shifted in, right to left
shift_slope_piece_6 F977 CALL shift_byte_low_0
F97A CALL pad_right_checker_0
F97D CALL shift_byte_high
F980 DJNZ shift_slope_piece_6
F982 LD A,(piece_step_x) Ceilings: the checkerboard on the left
F985 AND A
F986 EXX
F987 JR Z,shift_slope_piece_7
F989 EXX
F98A LD E,$AA
F98C INC D
F98D LD A,(DE)
F98E DEC D
F98F EXX
F990 OR (HL)
F991 LD (HL),A
shift_slope_piece_7 F992 INC HL On past the row's last byte
F993 EXX
F994 JR shift_slope_piece_9
shift_slope_piece_8 F996 LD A,(row_count_spare) Start the next variant
F999 LD (row_count),A
shift_slope_piece_9 F99C LD A,(scratch_count) The next pair of rows
F99F DEC A
F9A0 LD (scratch_count),A
F9A3 JR NZ,shift_slope_piece_1
F9A5 POP HL The next shift
F9A6 CALL next_shift
F9A9 JR NZ,shift_slope_piece_0
F9AB RET
Prev: F900 Up: Map Next: F9AC