Prev: C27E Up: Map Next: C331
C27F: Erase and redraw one piece of the carried load
Used by the routine at carried_part.
The old image is erased only when it has to be: when the load is let go, when a redraw is forced (carried_part_redraw), or when the ship has turned since it was drawn (its facing byte against the one kept at carried_part_facing). Otherwise the new image is drawn over the old one, which is at the same place: the ship does not move on the screen. The place is fixed relative to the ship: x $68 for the 5-wide piece, $78 and $23 rows higher for the 3-wide one, $60 when facing left, and y $0D above the ship's line ship_line, just above the ship's top, so the load rides on top of the ship. Facing left, the mirrored eraser and drawer are used (mirror_ship_sprite, set_mirrored_drawer). Read only: never ran.
Input
IX The piece's place (screen x, y)
DE The piece's graphic
#R$5C28 The piece's width in bytes (old and new)
draw_carried_piece C27F PUSH DE Keep the graphic.
C280 LD A,(carried_part_facing) Let go: erase it.
C283 BIT 6,A
C285 JR NZ,draw_carried_piece_0
C287 AND A Never drawn: nothing to erase.
C288 JR Z,draw_carried_piece_2
C28A LD B,A Erase only if forced, or if the ship faced the other way when it was drawn.
C28B LD A,(carried_part_redraw)
C28E AND A
C28F JR NZ,draw_carried_piece_0
C291 LD A,(ship_facing)
C294 XOR B
C295 BIT 7,A
C297 JR Z,draw_carried_piece_2
draw_carried_piece_0 C299 LD A,(ground_cell) Set up the erase: the old height is the full height, clipped at the top of the play area (clip_height_to_top); its old place; the eraser for width 5 or 3 (entry points in direct_erase_row), mirrored if it was drawn facing left (mirror_ship_sprite); the screen address.
C29C LD (scratch_count),A
C29F LD L,(IX+$00)
C2A2 LD H,(IX+$01)
C2A5 LD A,H
C2A6 LD (direct_old_line),A
C2A9 LD A,(scratch_count)
C2AC CALL clip_height_to_top
C2AF LD A,B
C2B0 LD (scratch_count),A
C2B3 LD (sprite_screen_pos),HL
C2B6 LD IY,direct_erase_five
C2BA LD A,(sprite_width)
C2BD CP $05
C2BF JR Z,draw_carried_piece_1
C2C1 LD IY,direct_erase_three
draw_carried_piece_1 C2C5 LD A,(carried_part_facing)
C2C8 CALL mirror_ship_sprite_0
C2CB LD HL,(sprite_screen_pos)
C2CE CALL pixel_to_screen
C2D1 EXX
draw_carried_piece_2 C2D2 POP DE Let go: no new image; run the mover for the erase alone.
C2D3 LD A,(carried_part_facing)
C2D6 BIT 6,A
C2D8 JR Z,draw_carried_piece_3
C2DA XOR A
C2DB LD (ground_cell),A
C2DE JP draw_direct_pair
draw_carried_piece_3 C2E1 LD (IX+$00),$68 The 5-wide piece: x $68, y the ship's screen row less $0D.
C2E5 LD A,(ship_line)
C2E8 SUB $0D
C2EA LD (IX+$01),A
C2ED LD HL,direct_draw_five The 3-wide piece: x $78, $23 rows higher, and the narrower drawer.
C2F0 LD A,(sprite_width_drawn)
C2F3 CP $05
C2F5 JR Z,draw_carried_piece_4
C2F7 LD (IX+$00),$78
C2FB LD A,(IX+$01)
C2FE SUB $23
C300 LD (IX+$01),A
C303 LD HL,direct_draw_three
draw_carried_piece_4 C306 LD A,(ship_facing) Facing left: x $60.
C309 BIT 7,A
C30B JR Z,draw_carried_piece_5
C30D LD (IX+$00),$60
draw_carried_piece_5 C311 PUSH HL Draw it: its new place, the height clipped at the top, the screen address, the mirrored drawer if facing left, then erase and draw (draw_direct_pair).
C312 LD L,(IX+$00)
C315 LD H,(IX+$01)
C318 LD A,H
C319 LD (direct_new_line),A
C31C LD A,(ground_cell)
C31F CALL clip_height_to_top
C322 LD A,B
C323 LD (ground_cell),A
C326 CALL pixel_to_screen
C329 POP IX
C32B CALL set_mirrored_drawer
C32E JP draw_direct_pair
Prev: C27E Up: Map Next: C331