![]() |
Routines |
| Prev: CD08 | Up: Map | Next: CE04 |
|
Used by the routine at draw_landscape.
Called for each piece by draw_landscape after load_piece_steps, with HL at the byte after the piece's direction-and-steps byte and C its number of steps. Only a flat piece (no rise) has two more bytes: the codes of the pieces at its left and right ends, kept in piece_extra_a and piece_extra_b ($16 means none, and codes from $10 have special handling in flat_step_clip). For a tile mirrored left-right ($FF) they are read the other way round with bit 1 changed (left for right); for one turned upside down ($99) bit 0 is changed as well (top for bottom), and the piece's y is moved (XOR $0C).
The address of the next piece is kept in next_piece. Then, for a mirrored tile, the piece's x is reflected across the page (piece_page_x becomes the complement of x plus its x step plus $0F), its direction is remapped through mirror_table (right for left), set_piece_shape reloads the steps, and a flat run is moved back along by its length less one step (24 pixels a step), so it starts at its other end. A flat piece whose right end is $16 is not mirrored at all.
|
||||||||||||
| piece_ends | CD6B | LD A,(piece_rise) | A piece with a rise has no end bytes. | |||||||||
| CD6E | AND A | |||||||||||
| CD6F | JR NZ,piece_ends_4 | |||||||||||
| CD71 | LD A,(tile_upside_down) | An upside-down tile moves a flat piece's y. | ||||||||||
| CD74 | AND A | |||||||||||
| CD75 | JR Z,piece_ends_0 | |||||||||||
| CD77 | LD A,(piece_page_y) | |||||||||||
| CD7A | XOR $0C | |||||||||||
| CD7C | LD (piece_page_y),A | |||||||||||
| piece_ends_0 | CD7F | LD A,(tile_mirrored_left_right) | A mirrored tile reads the ends the other way round. | |||||||||
| CD82 | AND A | |||||||||||
| CD83 | JR Z,piece_ends_2 | |||||||||||
| CD85 | LD A,(HL) | Mirrored: the first byte, changed left for right, is the right end; the second (unless $16) the left end. | ||||||||||
| CD86 | XOR $02 | |||||||||||
| CD88 | LD (piece_extra_b),A | |||||||||||
| CD8B | INC HL | |||||||||||
| CD8C | LD A,(HL) | |||||||||||
| CD8D | CP $16 | |||||||||||
| CD8F | JR Z,piece_ends_1 | |||||||||||
| CD91 | XOR $02 | |||||||||||
| CD93 | LD (piece_extra_a),A | |||||||||||
| CD96 | INC HL | |||||||||||
| CD97 | JR piece_ends_3 | |||||||||||
| piece_ends_1 | CD99 | LD (piece_extra_b),A | Mirrored, second byte $16: the right end is none. | |||||||||
| CD9C | INC HL | |||||||||||
| CD9D | JR piece_ends_3 | |||||||||||
| piece_ends_2 | CD9F | LD A,(HL) | Not mirrored: left end, then right end. | |||||||||
| CDA0 | LD (piece_extra_a),A | |||||||||||
| CDA3 | INC HL | |||||||||||
| CDA4 | LD A,(HL) | |||||||||||
| CDA5 | LD (piece_extra_b),A | |||||||||||
| CDA8 | INC HL | |||||||||||
| piece_ends_3 | CDA9 | LD A,(tile_upside_down) | Upside down: both ends top for bottom, except $16. | |||||||||
| CDAC | AND A | |||||||||||
| CDAD | JR Z,piece_ends_4 | |||||||||||
| CDAF | LD A,(piece_extra_a) | |||||||||||
| CDB2 | XOR $01 | |||||||||||
| CDB4 | LD (piece_extra_a),A | |||||||||||
| CDB7 | LD A,(piece_extra_b) | |||||||||||
| CDBA | CP $16 | |||||||||||
| CDBC | JR Z,piece_ends_4 | |||||||||||
| CDBE | XOR $01 | |||||||||||
| CDC0 | LD (piece_extra_b),A | |||||||||||
| piece_ends_4 | CDC3 | LD (next_piece),HL | Where the next piece starts. | |||||||||
| CDC6 | LD A,(tile_mirrored_left_right) | Not mirrored, or mirrored with no right end: done. | ||||||||||
| CDC9 | AND A | |||||||||||
| CDCA | RET Z | |||||||||||
| CDCB | LD A,(piece_extra_b) | |||||||||||
| CDCE | CP $16 | |||||||||||
| CDD0 | RET Z | |||||||||||
| CDD1 | LD A,(piece_page_x) | Reflect the x across the page. | ||||||||||
| CDD4 | LD B,A | |||||||||||
| CDD5 | LD A,(piece_step_x) | |||||||||||
| CDD8 | ADD A,B | |||||||||||
| CDD9 | ADD A,$0F | |||||||||||
| CDDB | CPL | |||||||||||
| CDDC | LD (piece_page_x),A | |||||||||||
| CDDF | EXX | Remap the direction through mirror_table and reload the steps. | ||||||||||
| CDE0 | LD E,(IX+$03) | |||||||||||
| CDE3 | LD D,$00 | |||||||||||
| CDE5 | LD HL,mirror_table | |||||||||||
| CDE8 | ADD HL,DE | |||||||||||
| CDE9 | LD A,(HL) | |||||||||||
| CDEA | LD (IX+$03),A | |||||||||||
| CDED | CALL set_piece_shape | |||||||||||
| CDF0 | EXX | |||||||||||
| CDF1 | LD A,(piece_rise) | A slope: done. | ||||||||||
| CDF4 | AND A | |||||||||||
| CDF5 | RET NZ | |||||||||||
| CDF6 | LD B,C | A flat run: back along by its length less one step. | ||||||||||
| CDF7 | LD A,(piece_page_x) | |||||||||||
| CDFA | DEC B | |||||||||||
| CDFB | RET Z | |||||||||||
| piece_ends_5 | CDFC | SUB $18 | ||||||||||
| CDFE | DJNZ piece_ends_5 | |||||||||||
| CE00 | LD (piece_page_x),A | |||||||||||
| CE03 | RET | |||||||||||
| Prev: CD08 | Up: Map | Next: CE04 |