A86: Updated Sprite Routine
[Prev][Next][Index][Thread]
A86: Updated Sprite Routine
This is an updated version of the sprite routine I recived from Trent
Lillehaugen last week. This version allows you to put the sprite in any of
the 8x8 squares on the screen. To call this, use:
ld b,(x value)
ld c,(y value)
ld hl,(picture)
call DrawPic
Here is the routine:
DrawPic:
ex de,hl ;Put sprite in DE
ld hl,$FC00 ;Point to video memory
ld a,b ;Put the X value in A
ld b,c ;Now both B and C has the Y value
sra b
sla c
sla c
sla c
sla c
sla c
sla c
sla c ;Multiply BC by 2 (This is done by dividing B by 2 and
multiply C by 128)
add hl,bc ;Now add the Y value to the video memory
ld b,0
ld c,a ;Put the X value into C
add hl,bc ;Now add the X value to the video memory
ld b,8
DrawPicLoop:
push bc
ld a,(de)
ld (hl),a
inc de
ld b,0
ld c,16
add hl,bc
pop bc
djnz DrawPicLoop
ret
If you have any suggestions, comments, or ways I could optimize this please send
it to ricci@chipsnet.com, Thanks!
- Ricci Adams
Follow-Ups: