Re: A86: FindPixel


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

Re: A86: FindPixel




On Sun, 22 Mar 1998, A. El-Helw wrote:

> 
> Is there an equivelent/routine i can use for find_pixel.. the ones in ZKart
> don't work right b/c they are modified for it... any ideas?
> 						-Ahmed

Will this suit your application?

;--------------------------------------------------------------------
; The Eble-Yopp-Yopp-Eble-Eble-Eble-Yopp Fast FindPixel Routine :)
; 36 bytes / 121 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
        add a,l
        ld l,a
        adc a,h
        sub l
        ld h,a
        ld c,(hl)       ; c = bitmask for (hl)
;48 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)
;121 t-states up to this point
        ret

FP_RLD:  .db $00
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


References: