Skip to content
Techniques & Technology

Raster Tricks 101

Bending the beam on the Commodore 64

Raster timing turns the VIC-II into a multitool: split-screen status bars, colour gradients, sprite multiplexing, and more.

commodore-64 raster-interruptstimingdemo-scene 1982–present

[🎥 suggested: animation showing raster bars changing colour mid-frame]

Overview

Raster tricks rely on synchronising code with the VIC-II’s electron beam. By running instructions on precise scanlines, programmers can change colours, scroll values, and sprite positions mid-frame—creating effects the hardware wasn’t “supposed” to do.

Fast facts

  • Raster interrupts: writing to $D011/$D012 and enabling $D01A fires an IRQ when the beam hits a chosen line.
  • Split screens: update background colours or character sets during the IRQ to create HUDs and "status bars."
  • Sprite multiplexing: reposition sprites after they've been drawn so they reappear lower down the screen, effectively increasing the sprite count.

A first colour bar

The simplest raster trick — change the border colour every line:

; Set up raster IRQ at line 0
    sei
    lda #<bar_irq
    sta $0314
    lda #>bar_irq
    sta $0315
    lda #0
    sta $d012           ; First IRQ at line 0
    lda $d011
    and #$7f
    sta $d011           ; Clear bit 7 (lines 0-255)
    lda #$01
    sta $d01a           ; Enable raster IRQ
    cli

; Each IRQ: pick the next colour and the next line
bar_irq:
    inc $d020           ; Next border colour
    lda $d012
    clc
    adc #1
    sta $d012           ; Next IRQ one line later
    lda #$01
    sta $d019           ; Acknowledge
    jmp $ea31

This produces a rolling rainbow on the border. The same loop is the basis of every more sophisticated raster effect — change $d020, $d018, $d011, scroll registers, or sprite positions instead.

See also