Hey everyone!
An update on the progress I've made in my quest for FPS.
I just can't leave well enough alone and had to try to squeeze a little more performance out of this.
And I've finally found something useful to do on this project with basic self modifying code!
For whatever reason I really wanted at least some routine to use it and gain performance.
I made a simple unrolled routine that draws a pixel, increments y, and then draws another for a total of 64 times.
This is around 8.2 cycles a pixel vrs 13.3 for a loop that did it before.
I could shift and add to get the x3 I need for the jump, but a lookup is a few cycles faster.
Code:
...
TAX ; RLE count
LDA .RLEArray,x ; Load JMP location
STA .RLEJump+1 ; Store low byte location
lda PlotColor ; Last pixel color used
.RLEJump:
JMP .RLERender ;Self modify! Jump to count
.RLERender:
sta (Screen),y; Draw it! 64 ; This is location 0 index 64
iny ; Next pixel
sta (Screen),y; Draw it! 63 ; This is location 3 index 63
iny ; Next pixel
... ETC ...
sta (Screen),y; Draw it! 2; This is location 186 index 2
iny ; Next pixel
sta (Screen),y; Draw it! 1 ; This is location 189 index 1
iny ; Next pixel
jmp .readloop ; Decode another byte
.ORG $800 ;Page align
.RLEArray: ;Decending Array of 3 byte skips
; I don't use 'zero' so use '1' twice IE two 189
.BYTE 189,189,186,183,180,177,174,171,168,165,162
.BYTE 159,156,153,150,147,144,141,138,135,132
.. ETC ..
.BYTE 9, 6, 3, 0
What surprised me was that this did not really add that much to the overall FPS. I only increased it by 0.3 FPS on average to 50.4 FPS.
However, after turning on a debug pixel that shows red when it can’t complete in a vsync and watching the playback and thinking about it I realized a couple of things.
Most frames are fine now, approaching 99%+.
And of the vast majority of frames that were still slow some had lots of small variations over several frames, and some large variations over a few frames.
The long runs of pixels seem to only happen often in the second case.
This means that while the routine is a lot faster, the number of frames that can really take advantage of it is actually pretty limited.
The good news is that these frames with improvement were some of the worst visually.
While objectively it did not add much to the performance using FPS as the metric, the subjective smoothness is much better now that these frames lag less.
I wonder if I'll find anything else to improve?