
Here is the code for a normal, working 32x20 pixel wide sprite:
I'm even using A7 in the sprite loop so that there are only registers inside, which I guess is best for the cache.
Code: Select all
move.w #3,XCOUNT(a4) ;2 + 1 words each bitplane (line)
move.w #16,SRCXINC(a4) ;16 bytes between words (8bpl)
move.w #-32+2,SRCYINC(a4) ;go to next bitplane (line)
move.w #16,DSTXINC(a4) ;16 bytes between words (8bpl)
move.w #-32+2,DSTYINC(a4) ;go to next bitplane (line)
move.b #2,HOP(a4)
move.b #3,BLITTER+OP ;SOURCE DIRECT for sprite data
;d2 = sprite skew value
;a0 = destination address
lea BLITTER+LINENUM,a4 ;start blit (HOG mode)
lea BLITTER+DSTADDR,a5 ;destination address
lea BLITTER+YCOUNT,a6 ;lines
lea BLITTER+ENDMSK1,a2
;;;;or.b #%01000000,d2 ;NFSR
move.b #%11000000,d0 ;start blit (HOG mode)
move.b d2,BLITTER+SKEW ;skew value
move.l a0,d3
lea BLITTER+SRCADDR,a0 ;source address
lea BLITTER+ENDMSK1,a2 ;endmask 1
moveq.w #8,d1 ;num lines = bitplanes
move.l #32,d7 ;offset to next line, source
move.l (a3)+,d5 ;get left and right mask
move.w sr,-(sp) ;save status register
move.w #$2700,sr ;turn off interrupts
move.l a7,old_a7 ;save stack pointer
move.l #320,a7 ;offset to next line dest
move.w #20-1,d4
sprite_loop
move.w d5,d6
swap d6
clr.w d6
lsr.l d2,d5
lsr.l d2,d6
move.l d5,(a2) ;set left and middle mask
move.w d6,4(a2) ;set right mask
move.l a1,(a0) ;source address
move.l d3,(a5) ;dest address
move.w d1,(a6) ;lines
move.b d0,(a4) ;start blit (HOG mode)
move.l (a3)+,d5 ;get mask value during blit
add.l a7,d3 ;next dest plane
add.l d7,a1 ;next source plane
dbra d4,sprite_loop
move.l old_a7(pc),a7 ;restore stack pointer
move.w (sp)+,sr ;turn on interrupts
If I enable the NFSR bit, I also must change this line:
Code: Select all
move.w #-32+2,SRCYINC(a4) ;go to next bitplane (line)
This moves the address back to the start of the next plane, which is 32-2 bytes back on a 32 pixel wide sprite. If NFSR skip the last word I had guessed I only need to remove 2 from this value, but the output is just a mess so there must be something else.
I have used the NFSR bit on STE without any problems and the only thing I must do there is to jump over 2 bytes in the SRCYINC register.