Other Commodore-related stuff -> http://www.iki.fi/a1bert/Dev/

VIC20 Picture Converter/Viewer

VIC20Gfx version 1.1 (28.1.2007) Sources: ppmtovic.c, ppmtovic.h, victoppm.c

See also: C64Gfx
And Also: More Examples by Anders Carlsson



Rediscovering some Pu-239 VIC20 demos after five years made me interested enough in VIC20 demo coding to finally start learning the ins and outs of the VIC-I chip and other VIC20 stuff. Marko Mäkelä's interest in VIC20 and "Veni Vidi Vic!" also helped alot.

I then coded some demo parts for VIC20. Some ideas were conversions from my C64 demos and I guess from there arose also the idea of a sort of FLI for VIC. VIC-I does not have a graphics mode and thus all graphics must be created with user-definable characters. The pixel resulution is awful, but the color resolution is even worse, because the whole screen shares three of the four multicolor colors. In addition, the 16x8-character mode causes each color cell to define the character color for a 16x4-pixel area.

The graphics viewer increases the color resolution considerably by multiplexing the three multicolor colors (in VIC20 they are located in the border+background and auxiliary color registers), which gives three selectable colors for each rasterline. In addition, both color memory halves are used and they are switched every eight lines, doubling the color memory resolution.

Yet another problem is that only colors 0-7 can be used freely. Colors 8-15 can only be used as auxiliary or background color. Fortunately only two of the colors 8-15 are actually usable, the other 6 are only lighter versions of the colors in the 0-7 range.

The graphics converter reads in a PPM-format picture, performs color quantization and dithering, performs color selection and actual conversion, then writes the results into a file, optionally with a viewer program attached so you can simply load and run the file in VIC20.

My three VIC20 demo parts still wait for good music, but here is the picture converter. Releasing it doesn't stop me from using it to create a graphics part for a demo later on.

And now it is later, so visit Vici Iterum MM and get your copy.


Usage: ppmtovic [-<options>] [ppmfile [vicfile]]
       d<n> = do a simple dither in the color conversion (1-n)
       l<n> = the importance of luminance in color conversion (0..20), default 7
       b<n> = brighten or darken the picture (-255..255), default 0
       c<n> = increase the contrast (-100..100 [0%..200%), default 0
       v = verbose, output extra information about the process
       q = quiet, no progress output
       o = optimize color selection (mean average error)
       i<colmem/hi/lo/back> = initialize colors (e.g. -i0/8/9/7)
       u1111111110000000 = use colors (default shown)
       p = insert a PAL viewer (8k exp. by default)
       n = insert an NTSC viewer (8k exp. by default)
       3 = use viewer for 3k expansion
       H = hires mode
For example ppmtovic -n -d1 -c20 pic.ppm pic.ntsc would convert a picture in pic.ppm to an executable program with an NTSC viewer to file pic.ntsc. The picture contrast is first increased to 120% and dithering with the setting 1 is used.

Using the -u option you can select which colors will be used in the conversion. The default is to use colors 0-8, but you very often get better pictures if you don't use red (2) in the conversion. ppmtovic -u1101011111000 -d1 07.ppm 07.v will use the colors black, white, cyan, green, blue, yellow, orange, and light orange in the conversion. This leaves out red, purple, and colors 10-15.

The converter also allows you to give higher importance to the resulting luminance values instead of the right color. For "non-realistic" pictures a higher luminance importance (e.g. -l11) usually gives better results.

  0   black
  1   white
  2   red
  3   cyan
  4   purple
  5   green
  6   blue
  7   yellow
  8   orange
  9   light orange
 10   pink
 11   light cyan
 12   light purple
 13   light green
 14   light blue
 15   light yellow

Hires mode is selected with -H. In this mode border and auxiliary colors in -i are ignored. If only two colors are selected in -u, one of them is used as the background color automatically. More than three enabled colors rarely give good results. For example ppmtovic -H -d1 -u0110000000100000 -c40 -b-10 tmp2.ppm tmp.pic creates a raw graphics file in hires mode with white, red, and light red.

victoppm converts the raw graphics files (saved without a viewer) back to PPM files. Multicolor and hires mode is automatically detected.


This page also presents some examples. Both NTSC and PAL executables are provided (they are compressed with pucrunch). These pictures require 8k memory expansion.

Get PAL Get NTSC 00.gif
Get PAL Get NTSC 01.gif
Get PAL Get NTSC 02.gif
Get PAL Get NTSC 03.gif
Get PAL Get NTSC 04.gif
Get PAL Get NTSC 05.gif
Get PAL Get NTSC 06.gif
Get PAL Get NTSC 07.gif
Get PAL Get NTSC 08.gif
Get PAL Get NTSC 09.gif
Get PAL Get NTSC 10.gif
Get PAL Get NTSC 11.gif
Get PAL Get NTSC 12.gif
Hires-mode example
Hires-mode example
Hires-mode example
Hires-mode example

This picture can be viewed in unexpanded VIC20. Download the appropriate loader (PAL or NTSC) and the file "graphics", put them into the same disk, load and run the loader. The disk should not have another file starting with "gra".

loader.pal loader.ntsc graphics D64 PAL and NTSC: unexpanded.d64.gz

For 3kB RAM expansion: 14-pal.3k 14-ntsc.3k

To the homepage of a1bert@iki.fi