A86: 16X16 sprites


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

A86: 16X16 sprites




Ok I hade a put sprite routine and i had it do 16 cols at a time then i 
added 8 to the x,y and i did that agean.....only the second time it didn't 
print it out right.
Here is my code:

Start:
    ld bc,$260a
    call show_o   ;i have the same x cords on both of them but
    ld bc,$370a   ;only the first one printed out of the x cord
    call show_o   ;the second one printed out on about 12-14th cord
    ret


show_o:
    ld ix,Oleft
    push bc
    ld a,16
    call PutSprite
    ld ix,Oright
    pop bc
    ld a,8
    add a,b
    ld b,a
    ld a,16
    call PutSprite
    ret

;This is Dux's putsprite but i canged it a tad
PutSprite:
push af
ld h,63			;shifted to $fc with add hl,hl
ld a,c
add a,a			;a*4
add a,a
ld l,a
add hl,hl			;hl*4 (what was c has been mlt by 16
add hl,hl
ld a,b			;a/8
rra
rra
rra
or l				;add to more significant bytes
ld l,a
ld a,7			;use bottom 7 bits for counter
and b
ld d,a			;save counter copy in d
pop af
ld e,a			;8 rows
push bc

ps_loop:
ld b,d			;get saved bit offset in b
ld a,(ix)			;get this byte of the sprite in a
inc ix			;point ix to the next byte of the sprite
ld c,0
call bit_shift
or (hl)			;change this to or if you want
ld (hl),a
inc l
ld a,(hl)
or c			;also changable to or (if you changed the first)
ld (hl),a
ld a,15			;add 15 to hl (now ready for next row)
call add_hl_a
dec e			;counter (8 rows)
jr nz,ps_loop
pop bc
ret

add_hl_a:			;add hl,a
add a,l
ld l,a
ret nc
inc h
ret

bit_shift:			;while(b=<0)
dec b			; a>>c
ret m
srl a
rr c
jr bit_shift

thanx

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com