FairLight TV 122: The VIC Trick

215

The Commodore 64’s VIC-II chip is packed with odd behaviors that can be manipulated to create interesting graphical effects. Bacchus from Fairlight TV recently demonstrated a clever trick that plays with sprite and graphics priorities, a technique that has been used in demos but often goes unnoticed.

How the C64 Handles Graphics and Sprites

The C64’s display consists of two main sections: the graphics area and the border. The graphics area, typically dark blue by default, is where characters and bitmaps appear. This can be in text mode, bitmap mode, or multicolor mode. The border surrounds this area and can sometimes be removed, particularly at the top and bottom, with a bit of trickery. The side borders, however, are more challenging to eliminate.

Sprites exist independently from background graphics and have a priority system that determines which appears on top when they overlap. Sprite 0 always has the highest priority, followed by Sprite 1, and so on. If two sprites are at the same location, the lower-numbered sprite will be rendered on top.

Playing with Sprite and Graphics Priority

A lesser-known quirk of the VIC-II chip is how it handles sprite-to-graphics priority. A specific register allows either sprites or background graphics to take precedence when they overlap. Normally, if a higher-priority sprite is set to be behind graphics and a lower-priority sprite is set to be in front of graphics, the rendering result is predictable. But what happens when they overlap in such a way that both conditions need to be applied? This is where things get interesting.

Bacchus modified an old sprite-moving program to demonstrate this effect. The setup involves two sprites, one white and one red, controlled by a joystick. A bit in the priority register determines whether sprites appear in front of or behind background graphics. By toggling sprite priorities dynamically, it is possible to create a strange layering effect where the lower-priority sprite appears in front of graphics but still respects the normal sprite stacking order.

Observing the Effect in Action

When executed, the white sprite remains behind background graphics, while the red sprite—despite being a lower-priority sprite—appears in front of the graphics layer. However, when the white sprite moves in front of the red one, it retains its lower priority relative to the graphics, effectively creating a pseudo-transparency effect. The graphics priority overrides the sprite priority, making for a visually interesting result.

Practical Applications and Demo Use

This effect has been used in at least one Fairlight demo, specifically 3037. Although it appears for only a brief moment, it demonstrates how manipulating sprite and graphics priority can be a valuable tool for creating layered effects. The priority shifting trick allows for visual styles that are difficult to achieve using standard C64 graphics techniques.

For those interested in experimenting with this technique, Bacchus has made the source code available on GitLab. He encourages anyone curious about C64 graphics programming to explore and modify the code.

 

Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments