A86: 95 t-state FindPixel routine


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

A86: 95 t-state FindPixel routine



This version is a little more specific in table placement but can be optimized
to 91 with syntax checking.
~Code7~
;Z80 Assembly Programmers Organization (ZAPO)
;Even faster findpixel routine
;~Code7~
;
;95 t-states
;30-37 bytes
;not counting optional return
;
;Input:
;b=x
;c=y
;
;Output:
;hl = byte in LCD memory
;a = bitmask for (hl)
;de destroyed
;
;if you use a=x and c=y for input and use the
;shorter version (FindPixelShort), then this routine
;takes only 91 t-states but will destroy your x value
;
;Feb 16,1999



;the start of this offset table program must be placed where
;the second hex digit of the address is a 7 and the 3rd and 4th
;are 0, examples would be $d700, or $e700
;If you are not sure if the table will be there when running your
;assembly program, copy the table to such a location and change
;the "ld de,Offset" to the location you moved it to.

Offset: .db $80,$40,$20,$10,$8,$4,$2,$1

;end offset table


;the find pixel routine itself can be placed anywhere
FindPixel:
	ld a,b
FindPixelShort:
	ld h,$3f
	add a,a
	add a,a
	ld l,a
	add hl,hl
	add hl,hl
	ld a,c
	rra
	rra
	rra
	add a,l
	ld l,a
	ld d,Offset >>8	
	ld a,c
	and d
	ld e,a
	ld a,(de)

	ret

.end