A86: a question


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

A86: a question



Has anyone that has seen Matt Johnson's sprite routine (where ix points to the sprite to display) know how it points to the next sprite in order?  I want to know how ix points to that next sprite.
here's the routine:
 
;PutSprite
;Input: bc = x,y; ix = 8x8 sprite location
;Output: sprite drawn; ix points to next sprite (if your sprites follow
;    in sequence); hl and and de destroyed
 
PutSprite:
 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
 ld e,8   ;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
 xor (hl)   ;change this to or if you want
 ld (hl),a
 inc l
 ld a,(hl)
 xor 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
 
Thanks for any help,
--------------
Jbrett
tbarwick@esn.net
http://ww2.esn.net/~tbarwick
I just added a TI-86 page, Check it out!!!