A86: Re: FindPixel


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

A86: Re: FindPixel




>Hello !
>
>I'm CLEM, the french programmer who don't speak
>english :-(
>There are my 2 findpixel routines. If anyone can
>optimize it, let me know.


Dan Eble already won the Findpixel routine (and always will), remember?
Unless you use another routine posted many many months earlier and uses a
lot lot of memory (around 16k right?) but is only
around 30 something T-states

Later,
    Matt

;---------------------------------------------------------------------
; The Eble-Yopp-Yopp-Eble-Eble-Eble-Yopp-Eble Faster FindPixel Routine
; 32-39 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
;         Flags are modified
;
; +-----------+
; |(0,0)      |  <- Screen layout
; |           |
; |   (127,63)|  Note: make sure coordinates are within bounds
; +-----------+
;
;---------------------------------------------------------------------
FindPixel:
        ld hl,FP_Bits   ; HL -> bitmask table
        ld a,e          ; A = x coordinate
        and $07         ; A = bit offset
        or a,l          ; add bit offset to HL (the addition to L will
        ld l,a          ;  not carry, because the table is aligned)
        ld c,(hl)       ; C = bitmask (saved for later)
;36 t-states up to this point
        ld h,$3F        ; to understand this, draw a picture
        ld a,d          ; A = y coordinate (top two bits clear)
        add a,a         ; does not carry
        add a,a         ; does not carry
        ld l,a
        ld a,e
        rra             ; puts 0 into the high bit
        add hl,hl       ; does not carry
        rra             ; puts 0 into the high bit
        add hl,hl       ; does not carry
        rra             ; puts 0 into the high bit
        or l
        ld l,a
        ld a,c          ; A = bitmask (saved from above)
;109 t-states up to this point
        ret

.org (($+8) & 0FFF8h)   ; align FP_Bits on the next 8-byte boundary
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01

.end