A86: FindPixel
[Prev][Next][Index][Thread]
A86: FindPixel
I've improved the speed of FindPixel. I decided to align FP_Bits on an
8-byte boundary so that the HL=HL+A addition becomes simpler. The
downside is it could use up to 4 bytes more memory than the previous
version. Please look over it and make sure I didn't make any mistakes.
This is also available at
http://www.cis.ohio-state.edu/~eble/ti86/fasterfp.html .
;---------------------------------------------------------------------
; The Eble-Yopp-Yopp-Eble-Eble-Eble-Yopp-Eble Faster FindPixel Routine
; 33-40 bytes/109 t-states not counting ret or possible push/pop of BC
;---------------------------------------------------------------------
; Input: D = y
; E = x
; Output: HL= address of byte in video memory
; A = bitmask (bit corresponding to pixel is set)
; C is modified
;
; +-----------+
; |(0,0) | <- Screen layout
; | |
; | (127,63)|
; +-----------+
;
;---------------------------------------------------------------------
FindPixel:
ld hl,FP_Bits
ld a,e
and $07 ; a = bit offset
or a,l
ld l,a
ld c,(hl) ; c = bitmask for (hl)
;36 t-states up to this point
ld hl,FP_RLD
ld (hl),d
ld a,e ; a = x/8 (byte offset within row)
rrca
rrca
rrca
rld
or $FC
ld l,(hl)
ld h,a ; hl -> byte in vid mem
ld a,c ; now a = bitmask for (hl)
;109 t-states up to this point
ret
FP_RLD: .db $00
.org (($+8) & 0FFF8h) ; align FP_Bits on the next 8-byte boundary
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
.end
--------
Dan Eble (mailto:eble@cis.ohio-state.edu)
(http://www.cis.ohio-state.edu/~eble)
"Behold, how great a matter a little fire kindleth!" -- James 3:5