![]() |
Routines |
| Prev: CCF5 | Up: Map | Next: CD6B |
|
Used by the routine at draw_landscape.
Called for each piece by draw_landscape with the piece's direction in +3 of the piece state at IX (current_piece). A tile turned upside down (draw_landscape's $99) first remaps the direction through upside_down_table: 0-6 to 7-13 and back, which turns each piece over top to bottom. Then set_piece_shape loads the direction's three steps from piece_shapes: the x step in pixels (piece_dx), the column step in screen bytes (piece_dcolumn) and the rise in rows (piece_rise), each per step of the piece, and sets direction_flag to $FF for a piece that steps right or 1 for one that steps left.
The directions, by their steps (x pixels, bytes, rows): 0 flat (24, 3, 0); 1 a gentle slope (16, 2, 8); 2 a steep one (8, 1, 8); 3 steeper (8, 1, 16); 4-6 the same three going left (-16, -2, 8; -8, -1, 8; -8, -1, 16); 7-13 the same seven upside down (the rise is still taken from 0-6, and piece_ceiling bit 7 marks them); 14 and 15 a wall, going right or left (0, +1 or -1, 16).
From those: piece_rows, the rows to work on per step (piece_rise, or 4 for a flat piece); piece_step_y, the size of the column step; piece_dx_copy, the x step (0 for a wall); piece_step_x, the size of the x step, or 8 for a wall. A wall in an upside-down tile is also moved 8 pixels.
|
||||||||
| load_piece_steps | CD08 | LD A,(tile_upside_down) | An upside-down tile: the direction through upside_down_table. | |||||
| CD0B | AND A | |||||||
| CD0C | JR Z,load_piece_steps_0 | |||||||
| CD0E | LD E,(IX+$03) | |||||||
| CD11 | LD D,$00 | |||||||
| CD13 | LD HL,upside_down_table | |||||||
| CD16 | ADD HL,DE | |||||||
| CD17 | LD A,(HL) | |||||||
| CD18 | LD (IX+$03),A | |||||||
| load_piece_steps_0 | CD1B | CALL set_piece_shape | The direction's steps. | |||||
| CD1E | LD A,(piece_rise) | Rows per step: the rise, or 4 for a flat piece. | ||||||
| CD21 | LD (piece_rows),A | |||||||
| CD24 | AND A | |||||||
| CD25 | JR NZ,load_piece_steps_1 | |||||||
| CD27 | OR $04 | |||||||
| CD29 | LD (piece_rows),A | |||||||
| load_piece_steps_1 | CD2C | LD A,(piece_dcolumn) | The column step, and the x step kept in piece_dx_copy. | |||||
| CD2F | LD (piece_step_y),A | |||||||
| CD32 | LD A,(piece_dx) | |||||||
| CD35 | LD (piece_dx_copy),A | |||||||
| CD38 | AND A | A wall (no x step): 8 pixels, with the sign of its direction. | ||||||
| CD39 | JR NZ,load_piece_steps_2 | |||||||
| CD3B | LD A,(direction_flag) | |||||||
| CD3E | NEG | |||||||
| CD40 | ADD A,A | |||||||
| CD41 | ADD A,A | |||||||
| CD42 | ADD A,A | |||||||
| CD43 | LD B,A | |||||||
| load_piece_steps_2 | CD44 | LD (piece_step_x),A | piece_step_x the size of the x step; going left, piece_step_y the size of the column step. | |||||
| CD47 | BIT 7,A | |||||||
| CD49 | JR Z,load_piece_steps_3 | |||||||
| CD4B | NEG | |||||||
| CD4D | LD (piece_step_x),A | |||||||
| CD50 | LD A,(piece_step_y) | |||||||
| CD53 | NEG | |||||||
| CD55 | LD (piece_step_y),A | |||||||
| load_piece_steps_3 | CD58 | LD A,(tile_upside_down) | A wall upside down: 8 pixels over. | |||||
| CD5B | CP $99 | |||||||
| CD5D | RET NZ | |||||||
| CD5E | LD A,(piece_dx_copy) | |||||||
| CD61 | AND A | |||||||
| CD62 | RET NZ | |||||||
| CD63 | LD A,(piece_page_x) | |||||||
| CD66 | ADD A,B | |||||||
| CD67 | LD (piece_page_x),A | |||||||
| CD6A | RET | |||||||
| Prev: CCF5 | Up: Map | Next: CD6B |