A86: 102 t-state findpixel routine


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

A86: 102 t-state findpixel routine




;Z80 Assembly Programmers Organization (ZAPO)
;Even faster findpixel routine
;~Code7~
;
;102 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 98 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, an example would be
;somewhere before $d7ff, which is usually close to the beginning
;of a regular TI86 asm program.  If you are not sure if it will
;always be there when running your assembly program, copy the table
;it to a location where the second hex digit of the address is a 7
;and change the "ld de,Offset" to the location you moved it to.

.pad ($+8) & $fff8
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 de,Offset
	ld a,c
	and d
	or e
	ld e,a
	ld a,(de)

	ret


.end