Yeah, the problem with rjmp is that it only covers +/-2 K. Many little loops interleaved in an interesting idea, but 1 cycles was not enough for what I came up with. I'm short of 6 cycles over the entire loop to support horizontal scrolling (need intructions to 'wrap' the vram pointer). Btw, what was the logic you though for the transparency calculations?I envisaged using an rjmp at the end, chances are you can be close enough. (little springboard loops interleaved with tiles if you have too many tiles) gives you a clock back from reloading Z.
Just for the sake of it, here's that 8 cycles loop I'm talking about:
Code: Select all
;180x200 6x8 tiles, 8 clk/pixel
;ROM Sprite tile 19 cycles (16 bytes * 8 = 128)
ldi r16,0x00 ;pix 0
ldi r17,0xff ;pix 1
ldi r18,0x33 ;pix 2
ldi r19,0x56 ;pix 3
ldi r20,0x67 ;pix 4
ldi r21,0x2c ;pix 5
movw zl,r24
ijmp ;back to rom tile loop
;ROM BG tile 10 cycles (20 bytes * 8 = 160)
ldi r21,0x00 ;pix 5
ldi r20,0xff ;pix 4
out PORTA,r16
ldi r19,0x33 ;pix 3
ldi r18,0x56 ;pix 2
ldi r17,0x67 ;pix 1
ldi r16,0x2c ;pix 0
movw ZL,r24 ;load return adress
ijmp ;back to rom tile loop
ld r24:r25, address(loop+2)
ld r6:r7, tile base adress
ld Z,nextTileAddress
ld X,spriteLineBuffer
ld Y,VRAM
ld r8,tile row count
ijmp
loop:
out PORTA,r17
movw Z,r6 ;tile table base adress
ld r23,Y ;get next tile
mul r23,tilesize
ld r0,X+
out PORTA, r18
ld r1,X+
ld r2,X+
ld r3,X+
add ZL,r0
out PORTA, r19
ld r4,X+
ld r5,x+
cpse r0,0xfe ;transparency check
mov r16,r0
adc ZH,r1
out PORTA, r20
cpse r1,0xfe
mov r17,r1
cpse r2,0xfe
mov r18,r2
cpse r3,0xfe
mov r19,r3
inc YL
out PORTA, r21
cpse r4,0xfe
mov r20,r4
cpse r5,0xfe
mov r21,r5 ;over!
add YL,Ytileoffset ;over!
adc YH,Ytileoffset ;over!
andi YL,xwrap ;over!
or YL,restorebits ;over!
cpse YL,last X tile ;over!
ijmp
end:
Uze