I found out the optimizations I made to the DMA code, back when I had my older animation engine, no longer has any benefit with my current animation engine.
The stuff about "dma rows" and "dma increment" can be removed. The reason they existed in the first place was because my old animation engine used rectangular animation boxes and the spent a lot of CPU time filling up the dma table, and having extra dma table parameters saved overall CPU time at a cost of vblank time. Now that I'm only using 32x32 and 16x16 boxes, I can just improvise the dma table building routine, so now the benefit is gone.
The reason why I didn't pay any attention to it until now is because I'm adding ninjas to my game, and the ninja jumping animation is 80x80 pixels big, so I'm having DMA overload issues. If I put the DMA threshold to 3kB, the ninja's animation freezes when jumping, but when it's set to 3.5kB I get flickering black bars. I use to be able to get 5kB per frame.
Code:
dma_sprites_loop:
lda.w {dma_rows},x
beq end_dma_sprites_loop
clc
-;
lda.w {dma_address},x
sta $02
adc.w {dma_increment},x
sta.w {dma_address},x
lda.w {dma_bank},x
sta $04
lda.w {dma_legnth},x
beq end_dma_sprites_loop
sta $05
lda.w {dma_destination},x
sta $2116
adc #$0100
sta.w {dma_destination},x
sty $420b
dec.w {dma_rows},x
bne -
inx #2
bra dma_sprites_loop
end_dma_sprites_loop:
stz {dma_updates}
stz {total_dma_legnth}
lda.w {dma_rows},x
beq end_dma_sprites_loop
clc
-;
lda.w {dma_address},x
sta $02
adc.w {dma_increment},x
sta.w {dma_address},x
lda.w {dma_bank},x
sta $04
lda.w {dma_legnth},x
beq end_dma_sprites_loop
sta $05
lda.w {dma_destination},x
sta $2116
adc #$0100
sta.w {dma_destination},x
sty $420b
dec.w {dma_rows},x
bne -
inx #2
bra dma_sprites_loop
end_dma_sprites_loop:
stz {dma_updates}
stz {total_dma_legnth}
The stuff about "dma rows" and "dma increment" can be removed. The reason they existed in the first place was because my old animation engine used rectangular animation boxes and the spent a lot of CPU time filling up the dma table, and having extra dma table parameters saved overall CPU time at a cost of vblank time. Now that I'm only using 32x32 and 16x16 boxes, I can just improvise the dma table building routine, so now the benefit is gone.
The reason why I didn't pay any attention to it until now is because I'm adding ninjas to my game, and the ninja jumping animation is 80x80 pixels big, so I'm having DMA overload issues. If I put the DMA threshold to 3kB, the ninja's animation freezes when jumping, but when it's set to 3.5kB I get flickering black bars. I use to be able to get 5kB per frame.