nippur72 wrote:It's necessary to link to IRQ so that your main cycle is executed at precise intervals? [...]
This is often done. An interrupt server is installed, and the main program then only executes '.loop JMP loop'. Everything is done within the IRQ.
In that case it is preferable to synchronise the IRQ with the raster beam. On the C64, this is easy as the video-chip supplies such an IRQ, on the VIC-20 you use a VIA timer instead.
Is there any other technique?
Busy-waiting for a cyclic condition, as Carlsson wrote. Technically spoken, an inferior method - you should still be able to use the main program for doing things, that:
- don't require exact timing, or even
- possibly need longer to complete than a full IRQ cycle, because:
And what does happen if your main cycle last longer than IRQ frequency?
Case 1: The speed of the game will suddenly drop by half. The next IRQ happens within the processing of the first IRQ, but you acknowledge both IRQ's at the end of your handler. Thus, every second IRQ is lost. But you've kept the synchronisation to the raster beam.
Edit: The foreground process outside the IRQ is allowed to execute till the next IRQ.
Case 2: You acknowledge the first IRQ at the beginning of your handler. In that case, the next IRQ will be honored immediately as your processing of the first one ends. You'll lose the synchronisation to the raster beam, and get a flickery display.
Edit: The foreground process will grind to a halt.
Michael