A86: Findpixl Wars


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

A86: Findpixl Wars



Dan's routine revisited.  Line beginning with a '!' have been changed.  
This routine is 38b/136t without counting the 'ret' or using push/pop.  
Haha!  I never thought I'd see this small of a FindPixel routine.

James
;---------------------------------------
FindPixel:
        ld a,e
        and $07         ; a = bit offset
        ld b,0
        ld c,a
        ld hl,FP_Bits
        add hl,bc
        ld b,(hl)       ; b = bitmask for (hl)
;56 t-states up to this point
        ld a,d
        rlca            ; multiply y by 4
!       add a, a        ;Same thing, but won't set the low bit.
        ld l,a
!       ld h,$3F        ;$FC two bits to the right.
        add hl,hl       ; multiply y by 4 again
        add hl,hl       ;   because there are 16 bytes in a pixel row
        ld a,e
        rrca            ; divide x by 8 (8 pixels/byte)
        rrca
        rrca
        and $0F
!       or l
!       ld l, a
        ld a,b          ; now a = bitmask for (hl)
;136 t-states up to this point
        ret

FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01


Follow-Ups: