I improved ZX Spectrum display updates by tracking changed rows and sending only the parts of the screen that need updating. This trades some modularity for speed and makes larger, slower SPI displays more practical.
I proposed tracking which rows had been updated, at a cost of 296 bits.
I would reuse the same update code I'm using.
I said tracking affected video RAM rows to partially update the display makes a big difference with slower and larger displays.
After tracking affected video RAM rows for partial updates, I described a 480x320 display as perfectly usable.
I pushed support for partial display updates in the ZX2040 Spectrum Emulator.
I said that large plain SPI displays are quite usable with partial updates.
I said this made it possible to build large-screen ZX Spectrum portable gaming machines for 20 eur/usd.
I described the original ZX Spectrum emulator I used as a masterpiece in modularity.
I proposed a bitmap of all the scan lines of the Spectrum graphics as a simple way to support partial display updates.
I noted that the 192-bit scan-line bitmap costs 24 bytes, which I considered a very cheap memory price to pay.
When a Z80 program writes to video memory, I need to compute the scan line from the written address and set its bit.
When the border changes, it is better to set the whole scan lines bitmap as all dirty and we rewrite everything, rather than track only the left and right border areas. I described this as: set the whole scan lines bitmap as all dirty and we rewrite everything.
I judged that updating only the left and right border areas would be a small gain (border changes seldom) and more complexity.
To save memory, the emulator writes the menu (when it is active) to the Spectrum video RAM; such accesses would not be detected, as this is performed directly accessing the RAM array in the emulator context. I therefore force a full update if menu=on.
Because direct menu writes are not detected, I force a full update if menu=on.
I noted that bitmap-area writes and colors-area writes need two different logics for setting scan-line bits.
I said that even if the bitmap and color are unchanged, blinking still has to be handled.
I said that tracking the actual rendered pixel value would be required to handle blinking by comparing rendered output.
The approach I described for blinking is to consider a scan line dirty if it contains any blinking attribute.
At each video update, I read each scan line and skip it if its corresponding bitmap bit is not set, avoiding a very costly SPI write to the display.
At the end of processing, I set the scan-line bitmap to all zeroes.
I noted a remaining bug in the partial-update approach: the border is not part of the bitmap.
The ZX Spectrum updates the border by writing to a port; the ULA stores the new value and generates the appropriate border color.
I concluded that I also need to track the last border color I updated.
I said the scan-line bitmap is just 192 bits.
I noted that after introducing setting this bit, memory accesses are no longer "agnostic".
I described departing from clean and isolated code implementing the different Spectrum components for a speed gain.