Wow, Dave, this is great! And also a bit strange to see my own code analysed like that
I knew my cycle timings had to be spot on (or else it would all fall apart) but to see it confirmed is really nice!
Your FPGA + ICE-6502 would have been an invaluable tool for me when I first created a stable raster on the Electron.
Big compliment to you that your FPGA can play this demo flawlessly!
I would love to see your FPGA + ICE-6502 in action at ABUG!
(crazy idea: would these tools also help in hunting down the spurious Bad Sum errors I'm getting with my Bad Apple demo on Elk/MMFS?)
As you discovered, after the initial PAL field detection code and syncing to DispEnd interrupt, all interrupts are turned off (and FE00 is not polled again) and 40K cycles are counted for every PAL frame to stay in sync.
MODE 1 (and all other high bandwidth screen modes) are interesting because of the memory contention issue. It allowed me to create a new version of the basketball demo that doesn't require a strict stable raster (like this version). Because of the "self-synchronizing" property (still not exactly sure how this works). I can use a normal DispEnd interrupt (including interrupt jitter) and adjust the timing between fields manually during development. That way 100% cycle counting (which is a slow and painful process) is not necessary during VBLANK (But is still needed during active display if you want some scanline shenanigans).
About (software) emulators.
Electrem chokes on the initial sync phase. After a few seconds it finally exits the sync phase but the timing for the actual demo is all wrong as well.
Elkulator is pretty accurate. I only need to add/subtract 16 cycles here and there to get it to work. Really helps during development and for taking a video of my demo.
MAME: somehow I can't get it to work anymore. It chokes on disk access and I have put it aside for now.
Electroniq (my own): is the worst of all because I didn't have cycle accuracy in mind when I wrote it. I could improve it so much with my current understanding of the Electron