Re: A86: Re: FindPixel


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

Re: A86: Re: FindPixel




On Tue, 5 May 1998, Matt2000 wrote:

> I have three questions
> 
> 1.) How does that make it faster

Take a look at the first part of the old routine:

        ld hl,FP_Bits   ; HL -> bitmask table
        ld a,e          ; A = x coordinate
        and $07         ; A = bit offset
        add a,l         ; add bit offset to HL
        ld l,a          ; | still adding
        adc a,h         ; | still adding
        sub l           ; | still adding
        ld h,a          ; v done
        ld c,(hl)       ; C = bitmask (saved for later)

Because the addition of the bit offset to L could cause a carry, H must be
updated as well.  Now take a look at the new routine with the aligned
table:

        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)

Because the table starts on an 8-byte boundary and is only 8 bytes long,
adding 0-7 to it will never cause a carry, so the 3 instructions that
update H can be deleted for a savings of 12 T-states.

> 2.) Will you ever stop optimizing! ;)
> 

I thought I was done... apparently not.  :-)


> 3.) Am I the only one who figured out how findpixel works line by line? It
> took me many hours to do so, now I am afraid to death of your putSprite,

Don't fear PutSprite, fear Line.

> that will take decades to figure out. You guys need to add those
> strategically placed comments once and a while  :-)

Done.  Check out the new pages.

--------
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: