A83: Pixplotting routine..


[Prev][Next][Index][Thread]

A83: Pixplotting routine..




Hi guys..
I wrote myself a pixplottingroutine, and I think it became quite good.. I
thought I should share it with you..  There is probably someone outthere in
nead of a really fast pixplotter :) And someone can probably make it even
faster...
and there is probably also someone who wants to learn more asm, that can
learn something from it..
It plots to the graph-backup and with just a small change (see comments in
code) you can transform it to a pixel-changer..  or a pixel clearer..
(it's very well commented too, so I think there should be no problem to
follow what I have done..)

enough talk..  here it is..  say what you think of it and I will try to
defend what I have done :)

;+-----+--------------------------------------------------------------------
---+
;| ALH |       > PIX <    Put a pixel in Graph Backup ¦        a=x e=y
   |
;+-----+--------------------------------------------------------------------
---+

;/-----------| PIX
|-----------------------------------------------------------\

PIX
;	push	af		; Uncomment these to save regs..  
;	push	de

	ld	d,0		; Do y*12
	sla	e
	sla	e
	ld	hl,0
	add	hl,de
	add	hl,de
	add	hl,de

       ld      d,0             ; Do x/8
       ld      e,a
       srl     e
       srl     e
       srl     e
       add     hl,de
       ld      de,8e29h
       add     hl,de           ; Add address to graphbuf

       ld      de,0007h     	; Get the remainder of x/8
       and     e
	ld	e,a
	ld	IX,pixtable  	; Look up in table witch pixel to be set
	add	IX,de		
	ld	a,(IX+0)  	; and load this
				

	or	(HL)		; 'xor' to toggle pixel, 'and' to clear
	ld	(HL),a		

;	pop	de
;	pop	af

	ret

pixtable
	.db	10000000b
	.db	01000000b
	.db	00100000b
	.db	00010000b
	.db	00001000b
	.db	00000100b
	.db	00000010b
	.db	00000001b

;\-----------| PIX
|-----------------------------------------------------------/