Re: A86: how does find pixel work?!?
[Prev][Next][Index][Thread]
Re: A86: how does find pixel work?!?
eightynine@juno.com wrote:
> Could someone please comment and explain whats happening here or tell me
> how to find out. I am coming from the TI-85, not that it is too much
> different. I have made some pretty cool games for the 85 using putsprite
> which uses find pixel, but I have never really known how it works. I
> think that it is time that I learn. This knowledge is what seperates
> people who know what they are doing from those who are just screwing
> around. I want to be one of those who knows what is going on. You can
> make plenty of cool stuff w/o knowing this crap, but like Matt Johnson
> says in his assembly tutorial having someone elses code in yours is a
> crappy feeling. I should at least know how it works. Thanks, Mike
>
> FIND_PIXEL:
> push bc
> push de
> ld hl,ExpTable
> ld d,0
> ld a,b
> and $07
> ld e,a
> add hl,de
> ld e,(hl)
> ld h,d
> srl b
> srl b
> srl b
> ld a,c
> add a,a
> add a,a
> ld l,a
> add hl,hl
> add hl,hl
> ld a,e
> ld e,b
> add hl,de
> pop de
> pop bc
> ret
>
> ExpTable:
> .db $80,$40,$20,$10,$08,$04,$02,$01
>
> _____________________________________________________________________
> You don't need to buy Internet access to use free Internet e-mail.
> Get completely free e-mail from Juno at http://www.juno.com
> Or call Juno at (800) 654-JUNO [654-5866]
You can look on 86 central for a very commented findpixel routine. It's not
so bad using other people's code if the code is super optimised. But in that
case, use this find pixel routine:
;----------------------------------------------------------------------
; FIND PIXEL by CLEM (117 cycles 34 bytes)
;
; Input: x->b
; y->c
;
; Output: hl : byte in LCD memory
; a : bitmask for (hl)
;
; Destroyes : bc
;----------------------------------------------------------------------
FindPixel:
ld h,63
ld a,c
add a,a
add a,a
ld l,a
ld a,b
rra
add hl,hl
rra
add hl,hl
rra
or l
ld l,a
ld a,b
and 7
ld bc,FP_Bits
add a,c
ld c,a
adc a,b
sub c
ld b,a
ld a,(bc)
ret
FP_Bits: .db $80,$40,$20,$10,$08,$04,$02,$01
Follow-Ups:
References: