This section contain material related to demo coding. General VIC programming is not available on this page. Instead it is devoted to coding specific demo effects and tutorials on how to make demos specifically (rather than coding in general). General drawing, non-specific to demo coding, is also on the general VIC page instead.
To give an example: Opening the border is commonly made in demo parts, but simply opening the border does not constitute a demo effect in itself (at least not during the last 20 years).
Many demo effects depend on precise timing. Therefore it might be useful to have a look on the Interrupts and Timing page.
Very basic rastersplitting can be done by waiting for a certain rasterline an then switch some VIC register. The display has 312 rasterlines at max but the VIC rasterline register ($d012) has only a range of 0 to 255. Therefore bit 7 of $d011 indicates if the rasterline is <256 or >255. Now the questions arises how to wait for a certain rasterline in the whole range without the preassumption of beeing in rasterline x when the wait routine is called. Here is a diagram which examples the situation:
Dependent of which rasterline your currently in, you can simply compare $d012 with the desired rasterline or you must first wait for bit 7 of $d011 to attain the right value and then wait again for the desired line. Even more, retrace has to be taken into account, too.
In total you have to consider 6 different cases. you have to consider 6 different cases:
beeing in rasterline 0-255 and
beeing in rasterline 256+ and
waitrasterline: cpx #0 beq wait0To255 ;from here on we wait for a rasterline > 255 bit $d011 bpl *-3 ;inRasterLineGT255 cmp $d012 bcs waitMatchingD012 bit $d011 bmi *-3 bit $d011 bpl *-3 bmi waitMatchingD012 wait0To255: bit $d011 bmi *-3 ;inRasterlineLT256 cmp $d012 bcs waitMatchingD012 bit $d011 bpl *-3 bit $d011 bmi *-3 waitMatchingD012: cmp $d012 bne waitMatchingD012 rts
The most classic demo effect, apart from scrolling text.
Those scrolling texts that we all hate to love that we love to hate. Also see the sprite section for a sprite scroller.