barrym95838 wrote:
Comments and critiques are welcome.
What a great learning experience, thank you. I analyzed it but I need some time to digest! So, like you wrote, the approach is to minimize loop overhead by painting more pixels per iteration. I assume the fastest program would just be a series of
STA calls that paints the picture without any branching or jumps.
Here is a solution that does 16 loops, and paints all pixels that are the same color in one iteration:
Code:
main:
CLD
LDA #0
TAX ; from left to middle
LDA #31
TAY ; from right to middle
LDA #0 ; starting color is black
loop:
STA $200,X ; paint left
STA $220,X
STA $240,X
STA $260,X
STA $280,X
STA $2A0,X
STA $2C0,X
STA $2E0,X
STA $300,X
STA $320,X
STA $340,X
STA $360,X
STA $380,X
STA $3A0,X
STA $3C0,X
STA $3E0,X
STA $400,X
STA $420,X
STA $440,X
STA $460,X
STA $480,X
STA $4A0,X
STA $4C0,X
STA $4E0,X
STA $500,X
STA $520,X
STA $540,X
STA $560,X
STA $580,X
STA $5A0,X
STA $5C0,X
STA $5E0,X
INX ; move to the right
STA $200,Y ; paint right
STA $220,Y
STA $240,Y
STA $260,Y
STA $280,Y
STA $2A0,Y
STA $2C0,Y
STA $2E0,Y
STA $300,Y
STA $320,Y
STA $340,Y
STA $360,Y
STA $380,Y
STA $3A0,Y
STA $3C0,Y
STA $3E0,Y
STA $400,Y
STA $420,Y
STA $440,Y
STA $460,Y
STA $480,Y
STA $4A0,Y
STA $4C0,Y
STA $4E0,Y
STA $500,Y
STA $520,Y
STA $540,Y
STA $560,Y
STA $580,Y
STA $5A0,Y
STA $5C0,Y
STA $5E0,Y
DEY ; move to the left
ADC #1
CMP #16
BCS end
JMP loop
end:
BRK