Maybe I'm late to the party, but I only just thought of this.
can become
It saves 7 cycles if attribpalette is not zero page. dec becomes dex because that register is freed for 3 cycles, 2 cycles for no inx, and 2 cycles because pha is faster than absolute,x.
Naturally you have to save and restore the position of the stack pointer before you start, and go through the data backwards if you also want to read it from the stack, but... just. Ugh. Don't know why I hadn't thought of it sooner.
I guess I'm posting in case anyone else never thought of it. I am thoroughly upset, because I'd need to rewrite everything to take advantage of this and there are so many places in my code where it's useful.
Code:
lda [dress4],y;Get 16x16's number
sta attribpalette,x
inx
dec reserved1;If this is the last 16x16 tile to update
beq scrollxpalettes.end;branch
sta attribpalette,x
inx
dec reserved1;If this is the last 16x16 tile to update
beq scrollxpalettes.end;branch
can become
Code:
lda [dress4],y;Get 16x16's number
pha
dex reserved1;If this is the last 16x16 tile to update
beq scrollxpalettes.end;branch
pha
dex reserved1;If this is the last 16x16 tile to update
beq scrollxpalettes.end;branch
It saves 7 cycles if attribpalette is not zero page. dec becomes dex because that register is freed for 3 cycles, 2 cycles for no inx, and 2 cycles because pha is faster than absolute,x.
Naturally you have to save and restore the position of the stack pointer before you start, and go through the data backwards if you also want to read it from the stack, but... just. Ugh. Don't know why I hadn't thought of it sooner.
I guess I'm posting in case anyone else never thought of it. I am thoroughly upset, because I'd need to rewrite everything to take advantage of this and there are so many places in my code where it's useful.