A technique called 'anonymous IRQ handlers' simplifies Commodore 64 raster interrupt programming by eliminating the need to name individual interrupt handlers. Instead of spreading interrupt logic across multiple named subroutines, all interrupt handling code is written sequentially in a single subroutine using an `irq_wait_rasterline()` macro. The macro internally sets up the next interrupt handler using an anonymous label, calls `irq_leave()` to return from the current interrupt, and resumes execution after the interrupt fires. This approach supports conditionals and loops within the interrupt chain, making the code easier to write, read, and modify. A trampoline interrupt is used to bootstrap the first call into the sequential handler. Full KickAssembler source code is provided.
Table of contents
Background: Commodore 64 Raster InterruptsThe Problem: Interrupt Handlers Get Messy, QuicklyThe Solution: Anonymous IRQ HandlersThe First IRQ HandlerConclusionsFull Source CodeSort: