User Tools

Site Tools


No renderer 'pdf' found for mode 'pdf'
base:the_double_irq_method

This is an old revision of the document!


The double (raster) IRQ method

Theory

This method is one of the more easy methods to grasp when it comes to stable timing. The following explanation of the method assumed you've accustomed yourself to the previous articles in this series.

As stated earlier a raster IRQ will trigger at cycle 0 on the chosen scanline, but due to the fact that the CPU must finish the current opcode + that the CPU needs 7 cycles to actually save the state and move the PC to the IRQ-handle we'll end up somewhere on cycle 7-14 (assuming no sprites on this raster line).

So, due to the finish-current-opcode problem we have a jitter of 7 cycles. However the shorted opcode (in time) is a NOP f.e., so wouldn't it be nifty if we knew that the CPU was executing NOPs when the raster IRQ occured? That would me still 7 cycles for IRQ-setup, but only a jitter of 1 cycle. I.e. we would end up on cycle 7 or 8.

A 2 cycle NOPs only gives a 1-cycle jitter because either the CPU has just finished the current opcode and can thus jump immediatly to the IRQ-handle, or it is half way through the NOP and must stall and additional one cycle to finish it.

Now, how to guarantee the CPU to execute NOPs when the IRQ occurs?

It's quite easy, let's configure a raster IRQ at raster line X to pull the CPU out of the main-code. This IRQ will jitter with 7 cycles at most since the main code can be anything. Now, immediatly let's configure the VIC to trigger another raster IRQ at line X+1. We're almost at X+1 but quite not there yet so let's just fill up with NOPs. This would ensure that when the second IRQ occurs we know 100% that the CPU will be executing NOPs and thus give us a jitter of only 1 cycle at line X+1.

(will continue soon… ;D )

base/the_double_irq_method.1429238051.txt.gz · Last modified: 2016-11-05 21:10 (external edit)