Improve the game loop

It can now skip frames. Replays are a *lot faster* on the "max speed" setting.
A comment here explaining the logic below would go a long way.  There's no avoiding this code being fiddly, but it would be nice to be able to understand the big picture without having to trace the different code paths ourselves.