15

I read in this answer that one could create graphics effects outside the usual specifications of the hardware by changing the settings of the machine's VIC-II at specific cycles during the video drawing interval.

What effects can be produced in this way? What settings at what cycle should be changed in order to produce them?

16

The VIC-II has many settings that can be changed, and also has the ability to produce an interrupt whenever a particular scanline has been hit. This allows us to make for example:

horizontal scanlines

set an interrupt when the electron beam reaches a particular scanline. Change the border color when the interrupt happens, and then set another interrupt a few scanlines later, to change the border color back. You now have a horizontal stripe across the border.

text and graphics on the same screen

A very similar trick to the one mentioned above. Maniac Mansion uses this one. Switch to one screen mode every vertical retrace, (that means the beam is at the top of the screen), and then wait a few scanlines and switch to a different screen mode. It is described here.

dithering

Some demos have graphics containing many more colours than the the 16 standard colours. This is done by very quickly switching between one image and another. So if a pixel is first red, then blue, then red again, alternating each frame, you get a purple which is different from the purple that the VIC-II produces. Not great for large areas since the flickering gets too uncomfortable, but you can get some extra colours that way

turn the upper and lower borders off

The VIC-II may be switched between 23 line mode and 24 line mode. If you set it to 24 line mode, and then set it to 23 line mode immediately before the the border would start, then the trigger to start the border never happens. This means that the border does not get drawn to the screen. You can not put pixels or characters in this area, but you can put sprites there.

turning off left and right borders

Similar to turning upper and lower borders off. By switching from 38 column mode to 40 column mode and back again at just the right times, you can cause the trigger that makes the borders appear not happen, which means that the borders will not appear. You can't draw anything to the bitmap, but you can put sprites there. This needs to be done every single scan line though, so it's not that common.

sprite multiplexing

The VIC-II can draw 8 sprites to the screen at any one time. But by reconfiguring one of the sprites as the beam is halfway down the screen, you can get it to appear twice on the screen.

nine sprites horizontally

Although the VIC-II has 8 hardware sprites, by changing the sprite pointer as the beam is halfway along a scanline, you can get sprite 0 to show up near the left-hand edge and near the right-hand edge of the screen. This needs to be done once per scanline that has nine sprites.

Flexible Line Interpretation

Every eighth scanline, the VIC-II halts the CPU so that it can read data twice as quickly! This is called a badline. During this time, it reads 40 bytes of screenmem and 40 bytes of bitmap. But by meddling with the vertical scrolling you can cause the VIC-II to do this on different scanlines, and this can let you overcome the colour clash. You just need to update screenmem (this contains colour information, and then cause a badline so that screenmem will be re-read.

Multicolor Interlace

Because in multicolor mode, each pixel is twice as wide as usual. To mitigate this, create two frames, and alternate between them. As you alternate the frames, also scroll the whole screen left and right by one pixel. Now, both halves of the double-width pixel is interlaced with the adjacent half of the next or previous pixel on the other frame, so that you have the appearance of a greater amount of colours in an attribute cell and higher resolution.

There are probably many others that I have failed to mention here.

  • Thanks for the quick answer. Now I know what "sprite multiplexing" means. (I assumed that it meant drawing a sprite on top of another!) – wizzwizz4 Apr 3 '17 at 14:02
  • 1
    @wizzwizz4 one sprite atop another is used for some effects — e.g. using a multicolour (i.e. half resolution) sprite to define the general shape of an object, and putting a monochrome (i.e. full resolution) sprite on top to add detail. No idea what the jargon for that is though. – Tommy Apr 3 '17 at 14:18
  • 4
    @Toomy The name of the technique you mentioned is "hires overlay". – wizofwor Apr 4 '17 at 7:43
  • are any of the settings persistent? i.e., is it possible to put the chip in a "weird state" that isn't reset by a power cycle? – Woodrow Barlow Sep 26 '17 at 18:43
  • @WoodrowBarlow Not that I've heard of; I'd be surprised. – Wilson Sep 27 '17 at 7:37
7

TV screens are drawn by scan lines, or raster lines. For instance, a PAL screen has 312 raster lines (including borders). The display on the screen is formed by drawing these lines one by one. The raster interrupt feature of the VIC-II allows us to trigger an interrupt when it reaches a predefined raster line. Most of the VIC-II tricks are based on this feature.

Changing screen mode/screen data between specific rasters. This is used to display text and graphics together and logo graphics using character data.

You can scroll only a specific area of the screen. This is used in smooth text scroll and logo swing effects.

You can change the x-scroll value for successive raster lines to make your graphic wave. This is Tech-tech.

There are also special tricks dealing with bad lines. Every 8th raster line is special for the VIC-II because it halts the CPU to fetch the screen data from the RAM. This happens when vertical scroll bits (the first three bits of $d011) and $d020 are the same. You can manipulate the vertical scroll bits to delay a bad line. This means that the VIC-II will delay drawing the next line for a number of raster lines. This is used in Flexible Line Distance (FLD) effects.

There are new graphic modes with increased resolution and color depths like FLI, AFLI, IFLI etc. Additional colors are produced by increasing the number of badlines. The resolution may be increased by interlacing graphics that manipulates raster lines.

There are also simpler effects which do not deal with rasters or bad lines, but changes data on each screen refresh, like color cycling.

  • 1
    Are bold text phrases examples of names that were used at the time? – wizzwizz4 Apr 4 '17 at 8:57
  • 1
    Yes, they are the original names of the effects. – wizofwor Apr 4 '17 at 9:48
  • Bugger. Autocorrection strikes again: "badlines" -> "bad lines". Sorry about that. – Nisse Engström Apr 5 '17 at 6:28
  • @NisseEngström I have seen both spellings. – Wilson Sep 27 '17 at 7:23
  • 1
    "You can change the x-scroll value for successive raster lines to make your graphic wave. This is Tech-tech." techtech usually has the point in shifting successive line to MORE than 8 hardware-assisted pixels. Done by swapping charset the picture drawn with (every +0, +8, +16 etc. pixels shift is a separate charset, while character codes remain unchanged) – lvd Nov 28 '18 at 17:46
6

In addition to the other answers, you can also remove the vertical (left and right) borders. By using the raster interrupt, counting clock cycles and carefully timing an instruction to reduce the screen width from 40 to 38 columns, you can make the VIC believe that it has already started to paint the border, and thereby turned off the sprites, when it actually hasn't. This allows you to place visible sprites in the border area, which can be used to display graphics outside of the normally drawable screen.

You can find more details about this on Stack Overflow: How do I show sprites in the border on C64?

  • 1
    That final number at the end of the shortened URL isn't actually unnecessary; it's your (SO) user ID and works as a referral to give you referral badges. – wizzwizz4 Apr 13 '17 at 22:36
0

This is kind of a question nobody could answer definitely. C64 demoscene still continues to invent new and new ways of abusing VIC-II. You can just look at the demos and note the effects. Start with pouet.net if you are really curious.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.