Prev: A43E Up: Map Next: A524
A498: Break up a dissolving object's image
Used by the routines at draw_aligned_row and draw_row_shifted.
An object that has been destroyed dissolves over seven passes (prepare_draw): its new image, just drawn into the buffer, is ANDed with that step's mask from dissolve_mask_bits, rotated a bit to the right at every byte so the gaps do not line up in columns. The masks keep seven bits, then six, down to one, so the object crumbles away.
dissolve_sprite A498 LD A,(dissolve_step) Not dissolving: go and copy the box back
A49B AND A
A49C JP Z,dissolve_sprite_2
A49F AND $0F D is the mask for this step
A4A1 LD HL,sprite_left_clip
A4A4 CALL add_a_to_hl
A4A7 LD D,(HL)
A4A8 LD HL,(saved_speed) The new image's start in the buffer
A4AB LD A,(new_sprite_width) The bytes a row covers (one more if the image is not on a byte boundary), and the rows
A4AE LD E,A
A4AF LD A,(new_sprite_rows)
A4B2 LD C,A
A4B3 LD A,(new_sprite_x)
A4B6 AND $07
A4B8 JR Z,dissolve_sprite_0
A4BA INC E
dissolve_sprite_0 A4BB LD B,E
dissolve_sprite_1 A4BC LD A,D AND each byte with the mask, turning the mask a bit each byte
A4BD AND (HL)
A4BE LD (HL),A
A4BF RRC D
A4C1 INC L
A4C2 DJNZ dissolve_sprite_1
A4C4 LD A,$00 On to the next row (the LD's operand is patched by erase_old_draw_new)
A4C6 ADD A,L
A4C7 LD L,A
A4C8 DEC C
A4C9 JR NZ,dissolve_sprite_0
This entry point is used by the routine at erase_old_draw_new.
dissolve_sprite_2 A4CB LD DE,(piece_page_x) The copy back: the screen address of the box, and the buffer
A4CF LD HL,$F800
A4D2 LD A,(sprite_left_clip) Straddling the left edge: copy just the part right of it, as draw_sprite_pair worked out
A4D5 AND A
A4D6 JR Z,dissolve_sprite_3
A4D8 LD A,($A531)
A4DB LD L,A
A4DC JP dissolve_sprite_7
dissolve_sprite_3 A4DF LD A,(piece_dx) B is the box's width in pixels
A4E2 ADD A,A
A4E3 ADD A,A
A4E4 ADD A,A
A4E5 LD B,A
A4E6 LD A,(piece_x) Does the box start at column 0?
A4E9 AND A
A4EA JR Z,dissolve_sprite_4
A4EC LD C,A Does it reach past x=$E8, the right edge of the play area? If not, copy all of it (copy_box_out)
A4ED ADD A,$17
A4EF ADD A,B
A4F0 JP NC,copy_box_out
A4F3 JR dissolve_sprite_5
dissolve_sprite_4 A4F5 INC E From column 0: leave the frame column out, and copy the rest
A4F6 INC L
A4F7 LD A,(piece_dx)
A4FA DEC A
A4FB JR dissolve_sprite_6
dissolve_sprite_5 A4FD LD A,$EE Past the right edge: copy only the bytes left of x=$E8
A4FF SUB C
A500 SRL A
A502 SRL A
A504 SRL A
dissolve_sprite_6 A506 LD B,A Patch the step and the DJNZ for that many bytes
A507 LD A,(piece_dx)
A50A SUB B
A50B LD ($A531),A
A50E LD A,B
A50F XOR $07
A511 DEC A
A512 ADD A,A
A513 ADD A,$03
A515 LD ($A520),A
dissolve_sprite_7 A518 LD C,$FF C $FF; B the rows plus one
A51A LD A,(piece_rise)
A51D LD B,A
This entry point is used by the routine at copy_out_part_row.
dissolve_sprite_8 A51E PUSH DE Keep the row's screen address; copy a row (copy_out_part_row) or finish
A51F DJNZ dissolve_sprite_8
A521 JP copy_out_done
Prev: A43E Up: Map Next: A524