Re: LF: Sprite routine?


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

Re: LF: Sprite routine?



On Sun, 1 Jun 1997 12:01:52 +0200 <georg.aaberg@eraconn.se> writes:

>Hi!
>
>I was wondering if anyone got a good B&W sprite routine?!
>Thanks!
>	/Gorby

Not sure about the "good" part, but I have a routine.  This one is a lot
faster than the one in SPRITE.ASM because it just ORs the sprite on the
screen without using a mask.

To use this routine, load A0 with a pointer to your sprite, A1 with a
pointer to LCD_MEM (or whatever buffer you want to draw in), D0 with the
X coordinate, and D1 with the Y coordinate.  D0-D3 and A0-A1 are trashed
by this routine.

The first word of a sprite should be the number of lines in the
sprite minus 1.  Then follows one longword for each line of the sprite.
The 8 most significant bits should be zero.  Then up to 17 bits
for each pixel in the sprite, and all zeros for the least significant
bits.   There is an example sprite after this routine.

put_sprite:
         move.w   (a0)+,d2
         add.w    d1,d1
         move.w   d1,d3
         lsl.w    #4,d3
         sub.w    d1,d3
         add.w    d3,a1
         move.w   d0,d3
         lsr.w    #4,d3
         add.w    d3,d3
         add.w    d3,a1
         btst     #3,d0
         bne.s    right
left:    not.w    d0
         andi.w   #7,d0
         addq.w   #1,d0
         moveq    #30,d3
leftl:   move.l   (a0)+,d1
         asl.l    d0,d1
         or.l     d1,(a1)
         add.w    d3,a1
         dbra     d2,leftl
         rts
right:   and.w    #7,d0
         beq.s    center
         moveq    #30,d3
rightl:  move.l   (a0)+,d1
         asr.l    d0,d1
         or.l     d1,(a1)
         add.w    d3,a1
         dbra     d2,rightl
         rts
center:  moveq    #30,d3
centerl: move.l   (a0)+,d1
         or.l     d1,(a1)
         add.w    d3,a1
         dbra     d2,centerl
         rts

example_sprite:
	 dc.w     8
         dc.l     %00000000011111111110000000000000
         dc.l     %00000000100000000001000000000000
         dc.l     %00000000100110011001000000000000
         dc.l     %00000000100000000001000000000000
         dc.l     %00000000100000000001000000000000
         dc.l     %00000000100100001001000000000000
         dc.l     %00000000100011110001000000000000
         dc.l     %00000000100000000001000000000000
         dc.l     %00000000011111111110000000000000

--
Patrick Davidson (ariwsi@juno.com)
Visit my home page!  Stuff for Amiga, TI-85, TI-92, even DOS!
http://www.calweb.com/~kwdavids/patrick/
http://www.toptown.com/hp/ariwsi/


References: