Interrupts

From SpecNext official Wiki
Jump to: navigation, search

Default Interrupt Handler

The default interrupt handler is at address $0038 in ROM and is automatically called by the Z80 in Interrupt Mode 1.

It:

  • updates the system variable frame counter;
  • scans the keyboard and updates the keyboard state system variables.

The default interrupt handler preserves all registers and has no external requirements.

You can replace the interrupt handler by either:

  • Setting the Z80 to interrupt mode 2 (IM 2) and configuring the address for a custom interrupt handler. Due to the restrictions on the Z80's interrupt specification, this requires placing the interrupt handler at an address where the high and low bytes are the same.
  • Using Next Memory Management to page out the ROM at address $0038 and replace it with a RAM page with your own routine at offset $38.

Interrupt Timing

The standard Spectrum ULA raises an interrupt every video frame. This is very commonly used in games to synchronize graphics with the updates of the screen.

You can adjust the timing of video interrupts using Raster Interrupt Control Register ($22). This will allow you to add an extra interrupt that occurs at a particular line address, or disable the standard ULA interrupt.

Using this register to "move" the standard interrupt to just after the final line of the visible screen can increase the time available for processing between frames.