Prev: E3BD Up: Map Next: E41B
E3D8: Look up a terrain piece's shape
Used by the routines at load_piece_steps and piece_ends.
Called by load_piece_steps and piece_ends with the piece in hand. Copies its direction's three bytes from piece_shapes to piece_dx (run in pixels), piece_dcolumn (width in bytes) and piece_rise (rise in rows); directions 7 and up (the ceilings, and the walls) use the records seven lower and set piece_ceiling to $80. Then sets direction_flag and the displacement of the JR at the end of landscape_step_loop to match: for a piece that climbs to the right (width positive) direction_flag is $FF and the JR skips the NEG at slope_step_at_right_edge; for one that climbs to the left it is 1 and the NEG is done.
Input
IX the collision-box list of the map cell being drawn (see draw_landscape); (IX+3) the piece's direction
set_piece_shape E3D8 LD HL,piece_shapes The shape records
E3DB LD A,(IX+$03) Directions 0 to 6 go straight to their record
E3DE CP $07
E3E0 JR C,set_piece_shape_0
E3E2 LD A,$80 Directions 7 to 15: say so, and use records 0 to 8
E3E4 LD (piece_ceiling),A
E3E7 LD A,(IX+$03)
E3EA SUB $07
set_piece_shape_0 E3EC LD E,A Three bytes a record
E3ED ADD A,A
E3EE ADD A,E
E3EF LD E,A
E3F0 LD D,$00
E3F2 ADD HL,DE
E3F3 LD A,(HL) Run, width and rise
E3F4 LD (piece_dx),A
E3F7 INC HL
E3F8 LD A,(HL)
E3F9 LD (piece_dcolumn),A
E3FC INC HL
E3FD LD A,(HL)
E3FE LD (piece_rise),A
E401 LD A,$01 Say it climbs to the left: direction 1, the NEG done
E403 LD (direction_flag),A
E406 XOR A
E407 LD ($D463),A
E40A LD A,(piece_dcolumn)
E40D BIT 7,A It does if the width is negative
E40F RET NZ
E410 LD A,$FF Climbs to the right: $FF, and the JR jumps over the NEG
E412 LD (direction_flag),A
E415 LD A,$02
E417 LD ($D463),A
E41A RET
Prev: E3BD Up: Map Next: E41B