[A83] Re: Sprites in 83+ ASM
[Prev][Next][Index][Thread]
[A83] Re: Sprites in 83+ ASM
Except that ldi decrements bc also :-) Also, you had bc = offset in buffer,
which wouldn't quite work out.
; de = sprite, hl = offset in buffer
AlignedSprite:
ld a,8 ; sprite is 8 pixels high
ld bc,12 ; rows are 12 bytes apart
AlignedSpriteLoop:
ld a,(de) ; get byte from sprite
inc de ; increment sprite pointer to next row
ld (hl),a ; write byte to video memory
add hl,bc ; point to next row
dec a ; decrement counter
jr nz,AlignedSpriteLoop ; loop for all bytes
ret ; all done
In a message dated 3/10/01 3:09:16 AM Eastern Standard Time, david@acz.org
writes:
> (oops, accidentally sent the last one before finishing)
>
> VideoRam = _plotSScreen
>
> bcall _ClrLCDFull
> bcall _GRBUFCLR
>
> ld hl,Sprite ; point to sprite
> ld de,VideoRam ; point to video ram
> call AlignedSprite
>
> bcall _GRBUFCPY
>
> ; de = sprite, bc = offset in buffer
> AlignedSprite:
> ld a,8 ; sprite is 8 pixels high
> ld bc,11 ; rows are 12 bytes apart (ldi increments it)
> AlignedSpriteLoop:
> ldi ; copy byte from sprite to video buffer
> ex de,hl ; need to use hl for addition, swap pointers
> add hl,bc ; point to next row
> ex de,hl ; exchange pointers again
> dec a ; decrement counter
> jr nz,AlignedSpriteLoop ; loop for all bytes
> ret ; all done
>
> Sprite:
> .db %00000000
> .db %01111110
> .db %00000100
> .db %00001000
> .db %00010000
> .db %00100000
> .db %01111110
> .db %00000000
----
Jonah Cohen
<ComAsYuAre@aol.com>
http://jonah.ticalc.org