I'm trying to scroll a portion of a plane vertically using blitter, so far I have no problem going up but as soon as I change direction I'm getting some unexplicable (for me!) results.
This routine is executed at every frame. Source and destination match, the shift is obtained by adding the size of a line to the source (A3) so the image moves up 1px every frame. 1 is also subtracted from H so the size of operation don't mess with next bitplane.
As long as SCROLL_DIR_Y=0 the scroll works OK and when it's 1 the size of a line is added to the destination (A4) instead, to obtain the opposite direction. But as soon as this is triggered the result of the blit is as in second image, without any scrolling in-between.
Using modulos of 0 and scrolling the whole area have the same results.
I'm obviously missing something, maybe an expert eye can give me a hint?
Code:
__SCROLL_BG_Y:
MOVEM.L D0-A6,-(SP) ; SAVE TO STACK
BTST.B #6,DMACONR ; for compatibility
MOVE.W #%0000100111110000,BLTCON0
; ## MAIN BLIT ####
MOVE.L BGPLANE0,A3
MOVE.L BGPLANE0,A4
MOVE.B SCROLL_DIR_Y,D5
TST.B D5
BEQ.S .goUp
ADD.L #336/16*2,A4 ; POSITION Y
BRA.S .goBlit
.goUp:
ADD.L #336/16*2,A3 ; POSITION Y
.goBlit:
bsr WaitBlitter
MOVE.W #$FFFF,BLTAFWM ; BLTAFWM
MOVE.W #$FFFF,BLTALWM ; BLTALWM
MOVE.W #%0000000000000000,BLTCON1 ; BLTCON1
MOVE.W #bpl-wblit,BLTAMOD ; BLTAMOD
MOVE.W #bpl-wblit,BLTDMOD ; BLTDMOD
MOVE.L A3,BLTAPTH ; BLTAPT SRC
MOVE.L A4,BLTDPTH ; DESC
MOVE.W #(h-1)*64+160/16,BLTSIZE ; BLTSIZE
; ## MAIN BLIT ####
MOVEM.L (SP)+,D0-A6 ; FETCH FROM STACK
RTS
Going up OK:
Going down: