Prev: A57E Up: Map Next: A611
A59F: Rub out the old image and draw the new one, straight on the screen
The other sprite drawer, for the player's ship (draw_ship), the carried rocket part (draw_carried_piece) and the lift jet (lift_jet): no buffer, but the rows of the old image's erase and the new image's draw interleaved -- one row rubbed out, one drawn, both moving up the screen -- so no part of the ship is missing for long. The images are byte-aligned (no shift tables); a ship facing left is drawn right to left through the bit-reversing table on page $F9 (direct_erase_row_mirrored, direct_draw_row_mirrored). Erase is AND NOT the graphic, draw is OR, as in draw_sprite_pair.
The old image is in the alternate register set (HL' its screen address, DE' its graphic, IY its row routine, its rows in scratch_count), the new in the main set (HL, DE, IX, its rows in ground_cell). When their bottom lines (direct_old_line, direct_new_line) differ, the rows below the higher one's bottom are done first on their own, so that the two then move up in step.
Input
HL The new image's screen address
DE The new image's graphic
IX The new image's draw-row routine
HL' The old image's screen address
DE' The old image's graphic
IY The old image's erase-row routine
draw_direct_pair A59F LD A,L Keep each image's column, to come back to at every row
A5A0 LD (sprite_width_drawn),A
A5A3 EXX
A5A4 LD A,L
A5A5 LD (sprite_width),A
A5A8 EXX
A5A9 LD A,(ground_cell) A' counts the new image's rows
A5AC EX AF,AF'
A5AD LD A,(scratch_count) Either image absent, or both on the same bottom line: interleave all the rows
A5B0 AND A
A5B1 JP Z,direct_next_pair
A5B4 LD A,(ground_cell)
A5B7 AND A
A5B8 JP Z,direct_next_pair
A5BB LD A,(direct_old_line)
A5BE LD C,A
A5BF LD A,(direct_new_line)
A5C2 SUB C
A5C3 JP Z,direct_next_pair
A5C6 JR NC,draw_direct_pair_1
A5C8 NEG The old image is lower: its rows below the new one's bottom are rubbed out alone first
A5CA LD C,A
A5CB LD A,(scratch_count)
A5CE SUB C
A5CF LD (direct_old_line),A
A5D2 JR C,draw_direct_pair_0
A5D4 LD A,C
A5D5 LD (scratch_count),A
draw_direct_pair_0 A5D8 XOR A No new rows meanwhile
A5D9 EX AF,AF'
A5DA CALL direct_next_pair
A5DD EXX Then the rest of both, interleaved
A5DE LD A,(direct_old_line)
A5E1 LD (scratch_count),A
A5E4 LD A,(ground_cell)
A5E7 EX AF,AF'
A5E8 JP direct_next_pair
draw_direct_pair_1 A5EB LD C,A The new image is lower: its rows below the old one's bottom are drawn alone first
A5EC LD A,(ground_cell)
A5EF SUB C
A5F0 LD (direct_new_line),A
A5F3 JR C,draw_direct_pair_2
A5F5 LD A,C
A5F6 EX AF,AF'
draw_direct_pair_2 A5F7 LD A,(scratch_count) No old rows meanwhile
A5FA LD (direct_old_line),A
A5FD XOR A
A5FE LD (scratch_count),A
A601 CALL direct_next_pair
A604 LD A,(direct_old_line) Then the rest of both
A607 LD (scratch_count),A
A60A LD A,(direct_new_line)
A60D EX AF,AF'
A60E JP direct_next_pair
Prev: A57E Up: Map Next: A611