Skip to content
Techniques & Technology

Sprite crunching

Shrinking a sprite by abusing a VIC-II glitch

A cycle-exact C64 trick that corrupts the VIC-II's internal sprite counter to make sprites shorter than the hardware allows — documented byte by byte by Crossbow of Crest, who got them down to 17 lines and left the record open.

commodore-64graphicsspritesrastervic-iidemosceneadvanced1989–present

Sprite crunching makes a C64 sprite shorter than the 21 lines the hardware gives you, by deliberately corrupting the VIC-II’s internal sprite counter at a cycle-exact moment.

Sprite crunching is based on a glitch in the VIC-chip (as usual) that appears on a cycle-exact position every rasterline.

Why it is hard

The counter normally advances by three each line, ending the sprite when it reaches $3f. Triggering the glitch changes what gets added — and not predictably:

Sometimes 3 will be added (as normal), sometimes something else. Sometimes a negative value will be added(!).

Miss $3f and the sprite does not end. The counter wraps to $00 or $01 and “the sprite will continue to be displayed for some 21 more lines”, misaligned.

So the technique is not parametric. You cannot ask for a 17-line sprite; you have to find a path through the counter’s behaviour that happens to land on one.

Crossbow mapped the table by hand

That path exists because somebody wrote down what the glitch does at every one of the counter’s 64 values. In Krestage by Crest you can find

exact documentation of what happens on each value of the sprite-graphics-counter when triggering the glitch, hand-haxxored by Crossbow himself. Finding the (probably) shortest path through the table, he managed to shrink the sprites from 21 lines to 17.

Codebase64 reproduces the table, and then leaves the record standing open:

Now play away with it. Can you make a sprite smaller than 17 lines and beat Crossbow? ;D

Three productions, three different uses

Production What it did
Rutig Banan / Fairlight Glitch on the third sprite line adding −1, so the sprite draws “almost 3 times” — about 120 lines of sprite area to work in
Krestage / Crest “The first example of sprite crunching when used for shrinking sprites”
Edge of Disgrace / Booze Design Glitch at position $1e adding −9 inside a 4×4 plasma, so $d017 is written “twice every 4 lines” instead of twice per line, “saving some life supporting cycles”

The record it set

Rutig Banan (Pernod/Fairlight, 5 November 1989) is the first recorded use. Eight years later Krestage used the technique to put 144 sprites on screen, against 112 for conventional sprites.

See also

Not yet fact-checked. This entry was drafted by an AI and nobody has verified it. The dates, figures and technical details may be wrong. Use it to find your bearings, then confirm anything that matters against a primary source.