Re: A83: Re: Buffer Draw Routines... (As seen on Dim-TI TCPA)


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

Re: A83: Re: Buffer Draw Routines... (As seen on Dim-TI TCPA)




I just checked my own routine..

it is 50 bytes and takes 223 clocks. thats all. not plus any outside routine
and it is not depending on where in the byte the pixel is.
I think it is quite beatiful too :) 

it is for now only plotting pixels and is not saveing regs. but that is easlily
changed.
here is it for you who doesn't want to check in Matthews tuts :)

;+-----+----------------------------------------------------+
;| 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 pixel to set
	add	IX,de		
	ld	a,(IX+0)	; and load this

	or	(HL)		; 'xor' toggle, 'and' cpl 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 |----------------------------------------/

James Matthews wrote:
> 
> Look at Olle's sprite routine...I think its even smaller isn't it?
> 
> Later,
> 
> James.
> 
> ==========================================
> E-mail matthews@tkb.att.ne.jp              ICQ: 7413754
> http://home.att.ne.jp/gold/tomcat21/index.html
> http://hyperion.advanced.org/18242/
> ==========================================
> -----Original Message-----
> From: Scott Dial <homosapian@geocities.com>
> To: ASM83 <assembly-83@lists.ticalc.org>
> Date: Tuesday, February 23, 1999 11:14 AM
> Subject: A83: Buffer Draw Routines... (As seen on Dim-TI TCPA)
> 
> >
> >I think that are great but the PIXEL routine which is the basis for most
> >of the routines is extremely unoptimized... I made it much quicker and
> >smaller (I believe someone mention this before on the list) So I made
> >the following:
> >
> >;-----------------------------------------------------------------------;
> >; Pixel Plotting Routine - By Jason Kovacs, with ZLIB's GetPix Routine.
> >;
> >; Revision by Scott Dial
> >;
> >; All clock times are + GETPIX
> >;
> >; Original - 44 Bytes
> >;
> >; White - 182 Clocks                                                   ;
> >; Black - 175 Clocks                                                   ;
> >; Xor   - 172 Clocks                                                   ;
> >; Revision - 36 Bytes
> >;
> >; White - 136 Clocks                                                   ;
> >;  Black - 143 Clocks
> >;
> >;  Xor   - 126 Clocks
> >;
> >; This increase in speed and shorting in size makes almost every other
> >;
> >; routine increase in speed and shorten in size.
> >;
> >;-----------------------------------------------------------------------;
> >; Input:  D = X, E = Y, C = Pixel Color (0-Clear, 1-Plot, 2-XOR Pixel).
> >;
> >; Output: Pixel is Plotted to Graph Buffer according to Command in 'C'.
> >;
> >;-----------------------------------------------------------------------;
> >
> >PIXEL:
> >        push bc                 ; [11] Save Loop Value and Color
> >        push de                 ; [11] Save the Coordinates
> >        push hl                 ; [11] Save these Values
> >        ld a, c                 ; [ 4] Load this to check which Color
> >        or a                    ; [ 4] CP 0
> >        jr z, PIXEL_WHITE       ; [12/7] Execute PIXEL_WHITE if C=0
> >        dec a                   ; [ 4] CP 1
> >        jr z, PIXEL_BLACK       ; [12/7] Execute PIXEL_BLACK if C=1
> >        ld a, d                 ; [ 4] 'a' now has X Coordinate
> >        call GETPIX             ; [17] Call the Pixel Routine from ZLIB
> >        xor (hl)                ; [ 7] 'XOR' to Toggle the Pixel
> >PIXEL_RET:
> >        ld (hl), a              ; [ 7] Write the new byte to Graph
> >Buffer
> >        pop de                  ; [11] Retrieve the Coords for Other
> >Routines
> >        pop bc                  ; [11] Retrieve the Loop Value and Color
> >        ret                     ; [10] Return
> >
> >PIXEL_WHITE:
> >        ld a, d                 ; [ 4] 'a' now has X Coordinate
> >        call GETPIX             ; [17] Call the Pixel Routine from ZLIB
> >        CPL                     ; [ 4] Compliment 'a' for the correct
> >Bit Mask
> >        and (hl)                ; [ 7] 'AND' to Clear the Pixel
> >        jr PIXEL_RET            ; [12]
> >PIXEL_BLACK:
> >        ld a, d                 ; [ 4] 'a' now has X Coordinate
> >        call GETPIX             ; [17] Call the Pixel Routine from ZLIB
> >        or (hl)                 ; [ 7] 'OR' to Plot the Pixel
> >        jr PIXEL_RET            ; [12]
> >
> >--
> >Scott "_Wrath_" Dial
> >homosapian@geocities.com
> >ICQ#3608935
> >http://www.geocities.com/~homosapian/
> >
> >


References: