Prev: C3E3 Up: Map Next: C4ED
C421: Erase and redraw the ship's image
Used by the routines at draw_rocket and draw_ship.
Entered from draw_ship on odd passes or when the image must change, and called by draw_rocket. The old image is erased only on a turn, while a part is being fitted (part_being_fitted) or while docking with the finished rocket (death byte 10); the new one is drawn at the same place (ship_screen_x, ship_screen_y), mirrored if the ship now faces left. Then on into draw_trail.
draw_ship_image C421 LD HL,$0000 No erase so far (old height 0), y the ship's (ship_screen_y), widths 6, IX the ship record.
C424 LD (scratch_count),HL
C427 LD A,(ship_screen_y)
C42A LD (direct_old_line),A
C42D LD HL,$0606
C430 LD (sprite_width),HL
C433 LD IX,ship_record
C437 LD A,(death_count) Docking with the rocket: erase it.
C43A CP $0A
C43C JR Z,draw_ship_image_0
C43E LD C,(IX+$18) Turning? ship_turned says so (the trail is then redrawn too), and the fire delay is cleared.
C441 LD A,(steer_push)
C444 AND A
C445 JR Z,draw_ship_image_2
C447 XOR C
C448 AND $80
C44A LD (ship_turned),A
C44D JR Z,draw_ship_image_2
C44F XOR A
C450 LD (gun_cooling),A
draw_ship_image_0 C453 LD HL,(ship_screen_x) Set up the erase: the old graphic (ship_graphic), height (ship_height) and place (ship_screen_x), the 6-wide eraser, mirrored if it faced left (mirror_ship_sprite).
C456 LD (sprite_screen_pos),HL
C459 LD DE,(ship_graphic)
C45D LD A,(ship_height)
C460 LD (scratch_count),A
C463 LD IY,direct_erase_row
C467 CALL mirror_ship_sprite
C46A LD HL,(sprite_screen_pos)
C46D CALL pixel_to_screen
C470 EXX
C471 LD A,(IX+$1F) A part being fitted?
C474 AND A
C475 JR Z,draw_ship_image_2
C477 BIT 7,A One with bit 7 set is drawn by toggle_carried_part.
C479 JR Z,draw_ship_image_1
C47B CALL toggle_carried_part
C47E LD A,$80
C480 LD (carried_part_redraw),A
C483 JR draw_ship_image_3
draw_ship_image_1 C485 LD B,A Otherwise it goes into the player's list of parts (from +7 of score), the old image is erased now, the ship's graphic rebuilt with it (build_ship_sprite), and the erase set up again for nothing (read only).
C486 DEC A
C487 LD HL,addon_slots
C48A CALL add_a_to_hl
C48D LD (HL),B
C48E CALL draw_direct_pair
C491 CALL build_ship_sprite
C494 LD A,$80
C496 LD (carried_part_redraw),A
C499 LD IX,ship_record
C49D LD HL,$0000
C4A0 LD (scratch_count),HL
C4A3 LD HL,$0606
C4A6 LD (sprite_width),HL
C4A9 JR draw_ship_image_3
draw_ship_image_2 C4AB LD A,(IX+$1F) Not turning: erase only if a part is being fitted.
C4AE AND A
C4AF JR NZ,draw_ship_image_0
draw_ship_image_3 C4B1 LD A,(steer_push) Being steered: the facing byte follows.
C4B4 AND A
C4B5 JR Z,draw_ship_image_4
C4B7 LD (IX+$18),A
draw_ship_image_4 C4BA LD A,(death_count) Docking: no new image.
C4BD CP $0A
C4BF JR Z,draw_ship_image_5
C4C1 LD A,(ship_screen_y) The new image at the same place, with the current graphic and height, mirrored if it now faces left.
C4C4 LD (direct_new_line),A
C4C7 LD DE,(ship_graphic)
C4CB LD HL,(ship_screen_x)
C4CE LD (sprite_screen_pos),HL
C4D1 CALL pixel_to_screen
C4D4 LD A,(ship_height)
C4D7 LD (ground_cell),A
C4DA LD IX,direct_draw_row
C4DE CALL set_mirrored_drawer
draw_ship_image_5 C4E1 CALL draw_direct_pair Erase and draw.
C4E4 CALL colour_ship Colour the ship (colour_ship).
C4E7 LD A,(death_count) Docking or dying: stop here.
C4EA CP $0A
C4EC RET NC
Prev: C3E3 Up: Map Next: C4ED