1;
2; Pixel operation for MODE6
3;
4
5	EXTERN	__gfx_coords
6	EXTERN	pixeladdress_MODE6
7	EXTERN	l_cmp
8
9; We enter here with: hl = x, de = y
10        push    hl              ;save x
11	ld	hl,192		;hl = maxy
12        inc     hl
13        call    l_cmp
14        pop     hl
15        ret     nc
16
17        ex      de,hl           ;de = x, hl = y
18        push    hl              ;save y
19	ld	hl,512		;max x
20        inc     hl
21        call    l_cmp
22        pop     hl
23        ret     nc
24        ex      de,hl
25        ld      (__gfx_coords),hl       ;x
26        ld      (__gfx_coords+2),de     ;y
27
28	push	bc		;Save callers
29	call	pixeladdress_MODE6
30        ld      b,a
31        ld      a,1
32        jr      z, continue	; pixel is at bit 0...
33.plot_position
34	rlca
35        djnz    plot_position
36continue:
37	; So here we have de=hl=screen location
38	; a = pixel mask
39IF NEEDplot
40	or	(hl)
41	ld	(hl),a
42ENDIF
43IF NEEDunplot
44	cpl
45	and	(hl)
46	ld	(hl),a
47ENDIF
48IF NEEDxor
49	xor	(hl)
50	ld	(hl),a
51ENDIF
52IF NEEDpoint
53	and	(hl)
54ENDIF
55	pop	bc	;Restore callers
56	ret
57
58
59