19

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?

wizzwizz4
  • 18,543
  • 10
  • 78
  • 144
  • 1
    A good reference site for programming these effects can be found here: http://codebase64.org/doku.php?id=base:vic – cbmeeks Apr 04 '17 at 19:39

4 Answers4

23

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.

Omar and Lorraine
  • 38,883
  • 14
  • 134
  • 274
  • 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 03 '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 03 '17 at 14:18
  • 4
    @Toomy The name of the technique you mentioned is "hires overlay". – wizofwor Apr 04 '17 at 07: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. – Omar and Lorraine Sep 27 '17 at 07:37
  • "horizontal scanlines" - this one is interesting. The Atari's ANTIC did everything else on this list, and I always though that a single extra register that had a color clock value for this purpose would add much flexibility. But how many cycles did you have in this interrupt? – Maury Markowitz Nov 28 '18 at 15:27
  • Oh sorry I think I'm simply reading it wrong. The interrupt in question took place at a specified VERTICAL location? – Maury Markowitz Nov 28 '18 at 15:35
  • @MauryMarkowitz Yes, it happens at a particular scanline, right? so that you get a horizontal stripe in the border. – Omar and Lorraine Nov 28 '18 at 15:45
  • Right, I read it to mean it happened at a point ALONG a horizontal scan. Which would be difficult. So reading this description, the VIC-II seems very similar to the ANTIC with the exception that on the ANTIC you could "write down" all of these interrupts and changes in the display list instead of beam racing. – Maury Markowitz Nov 28 '18 at 15:56
  • Was it possible to display more than eight sprites on two consecutive scan lines, or would a line with more than eight sprites have to be followed by a line with fewer? – supercat Oct 01 '22 at 05:32
  • @supercat it is just about possible to display 9 sprites on any scanline except badlines. It's done by moving the sprite 0 to the right half of the screen sometime before the raster reaches it, but before it's already drawn sprite 0. Apparently it's really hard to do; I have never attempted this myself. – Omar and Lorraine Oct 01 '22 at 17:00
  • Ah, now I see what you're asking, you'd also have to move the sprite back again later on the same scanline, perhaps during the border. I would think it's possible, but hard, but again, I haven't tried it – Omar and Lorraine Oct 01 '22 at 17:02
  • @OmarL: From what I recall of the VIC-II's design, sprites are displayed using a shift register which gets loaded when the sprite data is fetched, and then has bits fall out as they are displayed. If one displays early in one scan line a sprite that was fetched in the previous scan line, and the sprite gets re-fetched before the beam leaves the screen one could display it again on that scan line, but doing so would empty the shifter. – supercat Oct 01 '22 at 17:46
  • @OmarL: As a consequence, even if one were to move the sprite to the start of the next scan line, it retrigger but contain only blank pixels until the next time its data was fetched. – supercat Oct 01 '22 at 17:47
  • @supercat, oh yeah, I don't know how it does it then. That might be material for another question. – Omar and Lorraine Oct 01 '22 at 19:02
8

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.

Omar and Lorraine
  • 38,883
  • 14
  • 134
  • 274
wizofwor
  • 2,788
  • 2
  • 14
  • 38
  • 1
    Are bold text phrases examples of names that were used at the time? – wizzwizz4 Apr 04 '17 at 08:57
  • 1
    Yes, they are the original names of the effects. – wizofwor Apr 04 '17 at 09:48
  • Bugger. Autocorrection strikes again: "badlines" -> "bad lines". Sorry about that. – Nisse Engström Apr 05 '17 at 06:28
  • @NisseEngström I have seen both spellings. – Omar and Lorraine Sep 27 '17 at 07:23
  • 3
    "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
8

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?

Nisse Engström
  • 253
  • 2
  • 7
0

And when you open at least pal C64 border (at least top/bottom border) you can put sprites but also you get black graphics what content changes using last byte i think graphics memory bank at least default settings this single byte graphics are readed from 16383. I wanted add even this old thread.