The properties that distinguish a screensaver from a demo are that it appears automatically after a period of inactivity and it disappears again, restoring everything to its previous state, when it senses activity again.
The problem is we don't have any way to reserve some memory for a screensaver on a unexpanded machine. Even with 32K, placing a routine in the lower 8K and running it on the ISR hook doesn't quite do the tick IMHO. Any software except BASIC programs can, and probably will, overwrite it. The F18A, however, has 2K private memory that hardly any software is using.
The F18A GPU can run a routine concurrenty with the CPU to detect inactivity. The problem is that it only has access to VDP RAM, so the detection cannot be based on keyboard input but would have to be based on whether the screen is changing. This would not work for BASIC, for instance, where the cursor is blinking, but it would work for the color bar screen, many menus, and lots of other software.
Once inactivity is detected, the screensaver would save the VDP RAM and registers that it's going to use, and then run the actual screensaver, which would have to be very simple to fit into the 2K together with the saved VDP RAM. The VDP RAM could also be saved to the F18A flash memory, which would free up more RAM and allow the screensaver to use all the VDP memory.
While the screensaver is running it would continue to detect if the CPU is changing the VDP RAM. I imagine this could be done by calculating a VDP RAM checksum after each screensaver frame and check if it matches with a checksum calculated before the next frame. As soon as changes were detected it would stop the actual screensaver and return to background mode.
I once made a F18A demo where the whole screen was wobbling by changing the scroll offset for each pixel line. That would be a good candidate for trying out this idea because it's not changing the content of the VDP RAM at all, which eliminates the need to save/restore the RAM and makes it easy to detect changes to the RAM.
Edited by Asmusr, Fri Nov 9, 2018 11:33 AM.