Prev: 8151 Up: Map Next: 81DE
81B5: Plot a pixel and colour its cell
Used by the routines at FLOOD_FILL and DRAW_LINE.
Sets the pixel at (D,E) and fixes the attribute of the cell it lands in, taking the wanted ink from PLOT_INK. The cell's existing ink is compared against the wanted one and flipped if they match, so a line can never be drawn in the colour it is drawn on.
PLOT_PIXEL 81B5 PUSH HL
81B6 CALL PIXEL_ADDRESS Address and mask for the point
81B9 PUSH AF
81BA PUSH HL
81BB LD A,H Screen address to attribute address, the usual way
81BC AND $18
81BE RRCA
81BF RRCA
81C0 RRCA
81C1 ADD A,$58
81C3 LD H,A
81C4 LD A,(HL) Keep the paper, drop the old ink
81C5 AND $38
81C7 LD (HL),A
81C8 LD A,(PLOT_INK) The ink this picture is being drawn in
81CB RLCA
81CC RLCA
81CD RLCA
81CE CP (HL) Same as the paper? Then flip it rather than draw invisibly
81CF JR NZ,PLOT_PIXEL_0
81D1 XOR $38
PLOT_PIXEL_0 81D3 RRCA
81D4 RRCA
81D5 RRCA
81D6 OR (HL)
81D7 LD (HL),A
81D8 POP HL
81D9 POP AF
81DA OR (HL) Finally set the pixel itself
81DB LD (HL),A
81DC POP HL
81DD RET
Prev: 8151 Up: Map Next: 81DE