I had a read of the Electron AUG - I found this, which seems to work:
First, turn on VBL events using *FX14,4
Then, set the event vector at $220 to point to my new event handling function, which contains simply:
Code:
EventHandler:
cmp #4
bne EventIsNotVBL
LDA #0
STA waitForVsync
EventIsNotVBL:
rts
In fact, as VBL events are the only ones I turned on, maybe even that cmp/bne is unnecessary.
Pretty simple stuff, and perhaps not the absolute fastest way of doing it, but it works on both the BBC and Electron.
The Electron version is pretty playable - it's still a bit choppy compared to the BBC, but not bad at all. It might improve it further if I can decouple the game logic from the rendering, so that the game itself runs at the same speed as the BBC, even if it doesn't render quite so fast.
Kees - thanks for that, I've saved a copy for future reference. It looks like the osbyte $79 method of reading the keyboard still works even if keyboard interrupts are turned off, which is helpful. Maybe could be made even faster by using the hardware method of reading the keyboard, but I might come back to that later...