[A86] Re: What's wrong w/ this?
[Prev][Next][Index][Thread]
[A86] Re: What's wrong w/ this?
Now it draws the sprite. But it puts it like 8 rows down on the screen.
X-axis works. Thats why I added hl + de (offset) to get like $FC01. (It's not
aligned)
PS: Thank's aaron, I can't believe I missed that.
ps_normal:
ld b,a
call _findpixel
ld d,0
ld e,a
ps_draw:
add hl,de
ld a,(ix)
or (hl)
ld (hl),a
ps_shift:
ld a,16
ld d,0
ld e,a
inc ix
djnz ps_draw
ret
; =============================================================
; Input: B,C = X,Y
; Output: HL= address in video memory, A & E = bitmask in byte
; =============================================================
_findpixel:
ld hl,offsets ; possible offsets
ld a,b ; and deals with a, not b
and $07 ; a = bit offset
add a,l ; simulated 16-bit addition (a + hl)
ld l,a
adc a,h ; adc = add through carry
sub l
ld h,a
ld e,(hl) ; e = bitmask for (hl)
ld hl,_rld ; temp storage for Y
ld (hl),c ; store Y
ld a,b ; a = x/8 (byte offset within row)
rrca ; 1 byte
rrca ; 4 clock cycles
rrca ; rotates a right 1 bit
rld
or $FC
ld l,(hl)
ld h,a ; hl -> byte in vid mem
ld a,e ; now a holds the bitmask
ret
_rld: .db $00
offsets: .db $80,$40,$20,$10,$08,$04,$02,$01
Josh Gentry
"Real programmers code in pen during math class."
http://www.freewebz.com/jdgentry