Description of line and frame interrupts in VDP mode 4 by Charles MacDonald WWW: http://cgfm2.emuviews.com Introduction ------------ Here are some details on how interrupts work on the Genesis VDP when it is switched into mode 4, which should be equivalent to the SMS/GG. That said, some of the things described may only apply to the Genesis. 1.) Overview ------------ Once the VDP asserts the /IRQ line, it will not clear it until the control port is read. This means that when you return from an interrupt routine, the same routine will be immediately called again, and so on until you read the control port. Reading the control port will clear bit 7 (frame interrupt pending), bit 6 (line interrupt pending), and bit 5 (sprite collision occurance). 2.) Line interrupts ------------------- The VDP has a counter which is decremented on lines $00 to $C0. When the counter underflows (meaning it goes from 0 to -1), it is reloaded with the contents of register #10, and bit 6 of the status flags is set. If IE1 = 1 and bit 6 is set, the VDP will assert the /IRQ line. By modifying IE1 or disabling interrupts on the CPU side, you can make an interrupt occur on or after the line when it was supposed to. If register #10 is written to on lines $00 to $C0 (inclusive), the counter will not be updated until line $E0. If register #10 is written to on lines $E0 to $FF (inclusive), the counter will be updated immediately. If the value written to register #10 is larger than $C0, the interrupt will never occur as the counter will be reloaded before it can expire. Writing any value to register #10 on lines $C1 to $DA, $D5 to $DA will make an interrupt occur on line $F9. The second range is for the period where the V counter jumps back. Writing any value to register #10 on lines $DB to $DF will make an interrupt occur on line $FF. I'll point out that the Sega documentation says the V counter is 'invalid' during the vertical blanking period, so the unusual behavior described above could be a result of that; and furthermore could have different results on other machines. It may be specific to the Genesis only. 3.) Frame interrupts -------------------- On line $C0, bit 7 of the status flags is set. If IE0 = 1 and bit 7 is set, the VDP will assert the /IRQ line. By modifying IE0 or disabling interrupts on the CPU side, you can make an interrupt occur on or after the line when it was supposed to.