Commodore VIC-20

Introduction

The Commodore VIC-20 was a very successful microcomputer that was released in 1981 and was discontinued in 1985. It was powered by the 8-bit 6502 CPU running at about 1MHz and had 5KB of RAM (about 3.5KB available to BASIC programs) that could be expanded to up to 40KB.

Notes:

Screenshots on this page were taken using the VIC-20's composite video output upscaled.

The dollar ($) symbol is used to denote a hex value.

Overview

Let's have a look at the VIC-20 and in particular this is an European model:

The Commodore badge can be seen top left of the computer, the red power LED to the right, and the 66 key keyboard takes up most of the remaining space of the top of the case. The black keys consist of the majority of keys you would expect to find on a computer keyboard along with more specific Commodore type keys such as RUN/STOP (on its own stops a running BASIC program), the 'Commodore' key or C= key (allows accessing of graphic symbols, for example) and the CLR/HOME key (press on its own to place the text cursor at the top left-hand corner of the screen or use with SHIFT to also clear the screen). The INST/DEL key on its own deletes one character to the left of the cursor (functions like the backspace key of a modern computer keyboard) but when used with SHIFT a space is inserted at the cursor's current position, moving all characters to the right of the cursor one space to the right.

There are also 4 brown function keys, whose purpose are defined by a running BASIC program and normally have no use when writing BASIC programs (it would have been useful to have common BASIC keywords automatically assigned to the function keys). To access the odd numbered function keys press the key on its own and for the even numbered function keys press SHIFT with the key.

The keyboard provides some useful shortcuts; for example, you can press CTRL and any of the number keys 1 to 8 to change the text colour to be used to the colour written on the key. In addition, you can press CTRL and 9 to reverse the text colour or CTRL and 0 to turn the reverse effect off. There are some shorthand means to type keywords which involves typing the first letter followed by the second letter SHIFTed but the PRINT statement also has '?' as a shortcut.

Most of the black keys has two graphic symbols on them and to access them press SHIFT and the key to get the symbol on the right of the key or C= and the key to get the symbol on the left of the key. As the symbols can be enclosed in double quotes, simple graphics can be created just with PRINT statements. The key with the up arrow to the left of the RESTORE key also has the pi symbol displayed on it which can be accessed by pressing the key and either the C= or SHIFT key. The symbol can be used as a shortcut for pi and can be displayed using the PRINT keyword or used in a calculation.

When the VIC-20 is first powered on the computer starts up in upper case mode and you can use the C= and SHIFT keys together to toggle between mixed case and upper case. Although BASIC keywords can be typed in both upper case and lower case the downside of mixed case mode is that only one of the graphic symbols on a key are available since SHIFT and the key produces the upper case version of the key character. The SHIFT LOCK key thus saves pressing SHIFT and a key to get the upper case version which is similar to the caps lock key of a modern computer keyboard although on the VIC-20 shift lock also affects the number keys.

Unfortunately, there are only two cursor keys (labelled 'CRSR'), one for horizontal movement and the other for vertical movement so you must use SHIFT and the CRSR key to move the cursor in the opposite direction horizontally/vertically. This arrangement makes editing slower than having four separate cursor keys and to further frustrate there is no copy key. However, you can simply use the cursor keys to get back to a line of text, edit and press RETURN to save your changes and if you want to duplicate a line you can just LIST the line to be copied, change the line number and then press RETURN.

At the right side of the computer is a DB-9 CONTROL port connector supporting a single digital joystick (including Atari 2600 joysticks), paddle or light pen, and next to the CONTROL port is a toggle power switch, and further on the 9VAC power input. At the back of the computer is an expansion port (typically for cartridge software), video port (for connection to a monitor or a TV via an RF adapter), serial port (typically for a printer or disk drive such as the Commodore 1540 or 1541), a cassette port (for saving and loading software on cassette using Commodore's special cassette player) and a user port carrying both RS-232 and Centronics signals (very useful for connecting your own circuits to for control by the VIC-20). Oddly, none of the ports at the back of the computer are labelled. On the bottom of the VIC-20 is a label with the serial number, the power rating (9VAC 25W) and the place of manufacture (West Germany).

To use the VIC-20 plug in its power supply, connect either a TV (using an RF adapter) or monitor, and turn the power switch on and you will be greeted with this screen:

The banner announces that the VIC-20 has Commodore BASIC V2 built in and that there are 3,583 bytes available for BASIC programs of the 5KB of RAM in total. The computer reports that it's ready and there is a flashing cursor waiting for you to issue it commands. The large border and small area for typing shows just how low resolution the VIC-20's screen is. This screenshot as well as the others on this page show how poor the composite video output of a VIC-20 is (and RF is even worse) with vertical bars especially noticeable in the border area but the text area looks far worse if you change the colours. The default colours are supposed to be cyan for the border, white for the text background and dark blue for the text. Please see the Troubleshooting section for help with video issues.

As a demonstration of a simple BASIC program and how, as previously mentioned, the graphic symbols can be PRINTed to form more complicated graphics please see this listing:

Note that rather than typing LIST to list the program I use the shorthand (first letter and then second letter SHIFTed). The result of this program is as follows:

Again, rather than type RUN in full I've used the first letter of RUN followed by the second letter SHIFTed. It's a very basic example but I hope it gets across how useful the built-in symbols are for creating graphics.

To save programs you can use tapes with the Datasette, disks with a disk drive (such as the 1541), or a modern solution such as the SD2IEC. Please see the Accessories section for more information.

To finish off this section, you may like to view a video I did about the VIC-20:

Accessories

Commodore 1541

Please go to Commodore 1541.

Programmer's Aid Cartridge

Released in 1982 by Commodore, the Programmer's Aid Cartridge, model VIC-1212, was designed to help both new and experienced programmers write and debug BASIC programs with greater ease by adding useful BASIC commands, and shortcut programming features accessible by pressing CTRL and a key, and through the use of the function keys. The Programmer's Aid Cartridge is not compatible with the VIC 1010 Memory Expansion Board (it must be turned off) but it can be used with the VIC Machine Code Monitor (VIC 1212) and the Super Expander Cartridge (VIC 1211A).

The commands available in direct mode (cannot be used in a program) are:

HELP, TRACE, STEP, OFF, DUMP, KEY, EDIT, PROG, and KILL.

Note that as with the VIC-20'S built-in BASIC keywords, the commands supplied with the Programmer's Aid cartridge can also be entered by typing the first letter and then the second letter SHIFTed.

There are also six editing functions, accessed by holding down CTRL and pressing a key, such as CTRL U which erases all the characters on a line based on where the cursor is.

To use the Programmer's Aid Cartridge, make sure the VIC-20 is powered off and then insert the cartridge into the VIC-20's expansion port with the label facing up. Power on the computer and issue this command to enable the cartridge:

SYS 28681

Notice that, as can be seen in the screenshot above, the welcome message incorrectly spells Programmer's Aid as Programmers' Aid (not that the meaning has too much of a difference).

While the cartridge is enabled it can cause BASIC programs to run slow so when you have got your program working and you no longer need to use the cartridge you can disable it using:

KILL

The function keys will still be usable, however.

When the Programmer's Aid Cartridge is enabled its commands are available for you to use and two modes will be provided, program and edit mode, with program being the default mode. To switch between the two modes either use CTRL and F1 together or use the PROG and EDIT commands. Whether you are in either of the two modes determine what keywords are assigned to the function keys but you can use all available commands in both modes by typing the keywords in full. The function keys can be used on their own (F1, F3, F5 and F7) or with SHIFT (F2, F4, F6 and F8) or CTRL (F9, F10, F11, and F12) in order to access the 12 commands, and the function keys can be reprogrammed.

For quick reference, in program mode the following commands are assigned to the function keys:

KEY 1 “LIST”
KEY 2 “MID$(“
KEY 3 “RUN (RETURN)”
KEY 4 “LEFT$(“
KEY 5 “GOTO”
KEY 6 “RIGHT$(“
KEY 7 “INPUT”
KEY 8 “CHR$(“
KEY 9 “EDIT (RETURN)”
KEY 10 “GOSUB”
KEY 11 “RETURN (RETURN)”
KEY 12 “STR$(“

The keywords assigned to the function keys in edit mode are:

KEY 1 “LIST”
KEY 2 “AUTO“
KEY 3 “RUN (RETURN)”
KEY 4 “DELETE“
KEY 5 “FIND”
KEY 6 “CHANGE“
KEY 7 “TRACE (RETURN)”
KEY 8 “STEP (RETURN)“
KEY 9 “PROG (RETURN)”
KEY 10, “RENUMBER”
KEY 11 “MERGE”
KEY 12 “OFF (RETURN)“

The KEY command can be used to list whatever is assigned to the function keys:

To edit what is assigned to the function keys you can either use the cursor keys to move to the KEY listing, alter a line and press return, or you can use the KEY command with the key number and the string to add. For example:

KEY 1,"AUTO 10,5"

Notice in the screenshot above there is a left arrow displayed in reverse which simulates the return key being pressed as part of the string. One way to add the 'return' is first to press CTRL and RVS ON and then the left arrow key (the one at the top-left hand of the keyboard) and then finish off the string with the double quotes.

The string AUTO 10,5 has now been assigned to key 1 but to explain what AUTO does let's look at an example:

The AUTO keyword is very handy as it will automatically number the lines for us instead of manually having to type ourselves. AUTO 10, as used in the example above, starts on line 10 and every time we enter a BASIC line and press return, the next line number is added in increments of 10

As an example of a very useful keyword, CHANGE searches a BASIC program and replaces one thing with another. In the program that follows I've used a loop to count from 1 to 10 by use of the variable I (ignore that the NEXT is missing):

By using CHANGE, I altered any occurrence of the variable I with N by using:

CHANGE I,N

Now the loop uses the variable N instead of I, including the PRINT statement on line 20. This was a very simple example and CHANGE can also be used to replace strings.

The HELP keyword attempts to highlight mistakes in a BASIC program but it doesn't always prove too useful as one can see here:

On line 20 you can see I've missed off the T in PRINT so when I RUN the program BASIC comes back with a syntax error in line 20. When I use the HELP keyword it highlights the 'I' as the error which although is incorrect it's close to where the mistake actually is. With other errors the HELP command may prove to be more useful.

Next we'll look at the TRACE keywork which displays in the top-right of the display the 6 most recently executed lines of a running BASIC program:

In the above example only line 10 and 20 are shown since the program encounters an error as from the previous example program we looked at. If the program ran for longer, however, we can use the SHIFT or CTRL key to slow down the program so we can see clearer what lines are being executed.

To turn off TRACE use the OFF command which also turns off STEP, a keyword which forces a program to execute one line at a time so that the user can advance the program when required.

Here is a link to the manual which gives further information about the Programmer's Aid Cartridge including details of the various keywords provided:

http://cini.classiccmp.org/pdf/Commodore/VIC-1212%20Programmer's%20Aid.pdf

A scanned version of the manual:

https://magisterrex.files.wordpress.com/2011/06/vic1212programmersaidmanual.pdf

SD2IEC

Please go to SD2IEC.

Super Expander with 3K RAM Cartridge

Created by Commodore and released in 1981, the Super Expander with 3K RAM Cartridge, model VIC-1211A, gives the VIC-20 an additional 3KB of RAM (although 136 bytes is used by the cartridge) and provides some much needed BASIC keywords to manipulate graphics much easier than using POKE instructions to directly update the computer's memory as required by the very limited V2 BASIC built-in to the VIC-20. The Super Expander also gives the programmer a more straightforward means to produce music on the VIC-20 and get the status of joysticks and light pen, as well as providing shortcuts for common BASIC keywords by way of the VIC-20's function keys (their use of which could be redefined). Unfortunately, the Super Expander gives no easy means to create a bitmap display, limiting the cartridge's ability to make fast graphics more practical. Another shortfall of the Super Expander is that any programs written to take advantage of the cartridge must have the same cartridge installed on another VIC-20 in order for the program to run on that computer.

With the VIC-20 powered off plug in the Super Expander cartridge and then turn the VIC-20 on for the Super Expander to become active and for its features to become immediately available. You will see a screen similar to this:

The only real difference in the boot screen is the almost 3KB extra RAM useable for BASIC programs.

The Super Expander has an interesting approach to graphics; it treats the screen as being 1024 x 1024 units and the Super Expander's drawing commands expect coordinates for that resolution which in turn get scaled to the VIC-20's actual screen resolution. This would have especially made sense for portability between systems as, for example, location 512, 512 would be the middle of the screen regardless of the real screen resolution of a given system, rather than just for the two resolutions offered by the VIC-20. The Super Expander 64, the Commodore 64 equivalent of the VIC-20's Super Expander, expects coordinates to be specified in the range for the actual screen resolution that the C64 is using in its selected graphic mode, so that is a missed opportunity.

Commands included with the Super Expander let you set the graphic mode to use, the colours to work with, and points can be plotted, lines and circles drawn, text displayed, and areas filled in with colour. I wrote a brief program to show a little of what the Super Expander can do with graphics:

Since I listed the program after running it, the colours I set in the program have been used, making the listing harder to read so I'll reproduce it here:

10 GRAPHIC 2
20 COLOR 0,5,3,0
30 DRAW 1,512,250 TO 712,450 TO 412,450 TO 512,250
40 CIRCLE 1,200,600,150,150
50 PAINT 1,200,600
60 CHAR 2,2,"SHAPES"
90 GET A$: IF A$="" THEN 90
100 GRAPHIC 0

Line 10 puts the VIC-20 into high resolution mode which only supports 2 colours out of a palette of 8 but gives more pixels than the multicolour mode. Note that if you change to high resolution/multicolour code while in direct mode (not from within a BASIC program) you can still change the graphic mode again by typing the command and pressing RETURN even though you won't be able to see what you're typing.
Line 20 sets up the colours to use; black for the 'screen' colour, green for the border, cyan for the 'character' colour, and black for the auxiliary colour (not used in high resolution mode).
Line 30 draws the triangle. The DRAW keyword is very flexible as you can draw a single line or specify multiple points to create polygons.
Line 40 renders the circle.
Line 50 fills in the circle by specifying a point within the circle.
Line 60 draws the text "SHAPES". Note that text can only be placed at text positions (row, column) not any pixel as with other graphics commands.
Line 90 waits for a key to be pressed so that the shapes can be seen for as long as desired.
Line 100 returns the VIC-20 to text mode. The Super Expander manual says that you should use GRAPHIC 4 to return to text mode but GRAPHIC 0 appears to do the same thing.

This is the result of the program I wrote which draws a filled circle (which the VIC-20 renders as an ellipse instead of a circle due to non-square pixels), an unfilled triangle and the text 'SHAPES':

Just having dedicated graphics commands available makes programming much easier and should have been built in to the VIC-20.

For sound a single keyword is provided that lets you set all sound settings at once, however, the Super Expander also provides a music mode - which can be used in either direct mode or within a program - accessible by pressing CTRL and the left arrow key, that lets you play musical notes assigned to keys. In direct mode a to g on the VIC-20's keyboard play notes a to g (which is difficult to get used to if you play the piano) and a number of other keys alter how the notes sound.

By default the following commands are assigned to the function keys (use shift with the function key to access the even numbered functions):

F1 GRAPHIC
F2 COLOR
F3 DRAW
F4 SOUND
F5 CIRCLE
F6 RUN + RETURN
F7 POINT
F8 LIST + RETURN

Note: the '+ RETURN' means that a return will automatically be added as if you had typed the keyword and pressed the return key immediately after.

The KEY keyword can be used to list what is assigned to each function key as well as to redefine what each function key does with a limit of 128 characters for each function key.

Because 3KB is included with the Super Expander the memory for BASIC programs starts at 0x400 (dec. 1024) instead of 0x1000 (dec. 4096) and memory range 0x1000 to 0x1FFF (dec. 4096 to 8191) must be used for screen/high resolution graphics.

The following site has links for text and PDF versions of the user manual as well as downloadable versions of the example programs found in the manual:

http://www.zimmers.net/anonftp/pub/cbm/vic20/manuals/super-expander/index.html

Vixen Switchable 16K RAM Cartridge

Manufactured by Stonechip electronics, unknown release date, but likely to be around 1983.

Has two switches accessible on the front of the cartridge, SW1 and SW2, and position A is marked on the left side position B on the right side. Some cartridges appear to have four switches, however, two of them are latched together; likely whatever switches were available to Stonechip were used. The switches set how much RAM the VIC-20 is expanded by as to retain compatibility with software that may not be able to function with certain RAM combinations. Adds a maximum of 16KB (16384) to the VIC-20.

To use the cartridge first set the configuration switches on the cartridge (they are not accessible when the cartridge is in the computer) and then insert it into the VIC-20 while the computer's power is off, with the cartridge's label facing up. If using a powered memory expansion board then it must be turned off before inserting (or removing) the cartridge. When the VIC-20 is powered on it should report the increase in available RAM, if not, power of, reinsert the cartridge and try turning the VIC-20 on again. If there still is no sign of increase in memory then the cartridge may need cleaning or repair.

Switchable to 3KB, 8KB or 16KB but essentially you're adding either 11KB or 16KB.

Here is a link to a scan of the instruction leaflet that was originally included with the cartridge:

https://www.retrocomputers.online/wp-content/uploads/2020/11/Vixen16kRAM.pdf

Unless you are familiar with the VIC-20's memory map (how the RAM and ROM are arranged and used by the computer) it can be confusing to understand where the extra RAM appears and how it can be used. To help clarify I will summarise the various configurations (called modes in the instructions linked above) and how the RAM is mapped in:

Mode 1

SW1=A, SW2=B.

19,967 bytes available to BASIC (16,384 + 3,583 = 19,967).

8KB block 1 $2000 - $3FFF (8,192 - 16,383).
8KB Block 2 $4000 - $5FFF (16,384 - 24, 575).

BASIC can use all of the extra RAM.

Mode 2

SW1=B, SW2=B.

11,775 bytes available to BASIC (3,583 + 8192 = 11,775). BASIC cannot see the 3KB block.

8KB block 1 $2000 - $3FFF (8,192 - 16,383).
1KB blocks 1 to 3 $0400 - $0FFF (1,024 - 4,095).

Mode 3

SW1=B, SW2=A.

6,655 bytes available to BASIC (3,583 + 3072 =6,655). BASIC cannot see the 8KB block.

8KB block 3 $6000 - $7FFF (24,576 - 32,767).
1KB blocks 1 to 3 $0400 - $0FFF (1,024 - 4,095).

Mode 4

SW1=A, SW2=A.

3,583 bytes available to BASIC. BASIC cannot see the two 8KB blocks.

8KB Block 2 $4000 - $5FFF (16,384 - 24, 575).
8KB block 3 $6000 - $7FFF (24,576 - 32,767).

Although in certain configurations BASIC cannot make use of some or all of the extra RAM it can still be accessed from BASIC using POKE and PEEK, as well as from machine language programs. We can easily test the extra RAM by using POKE and PEEK by either using in direct mode or through a program, which is useful for testing multiple bytes. For example, in mode 1 we can start with reading the first byte of 8KB block 1:

?PEEK(8192)

The value you get back could be any value from 0 to 255 since the RAM will start up in an unknown state, however, you should always get the same value. If you get different values from the same extra RAM memory location without using POKE then either the RAM is bad or it isn't actually there (which would happen, for example, if you accessed a RAM block not available in a configuration).

You can then use POKE to write a value, such as 255, which sets all bits to 1:

POKE8192,255

Use the same PEEK as before and it should report back 255 or whatever value you POKEd there, if not, the RAM is bad.

You can see the POKEs and PEEKs in action below:

Test the other memory locations of the block and the other blocks, which for mode 1 the other block is 2, starting at 16384. As mentioned, you could put together a BASIC program to write and read the memory locations of the extra RAM, making sure you get back the value you put there.

It is common for the bits of plastic holding the PCB inside the cartridge to break away and so if you hear any rattling inside the Vixen that is likely the reason for the noise. To open up the cartridge use a plastic spudger and work your way around the case to separate both parts, which does require some force. Now would be a good time to clean the PCB contacts if you haven't already and if you do need to fix the PCB back down you can use hot glue but try to line up the PCB in its original position so that the remains of the plastic posts line up with the PCB holes.

The top of the PCB (see below) has silver tracks and 'V20' written top right (likely referencing VIC-20) whereas the bottom half has the wrinkly green tracks common with old PCBs (and is not a fault) and 'V2016A' is written top left (possibly a model number) and 'STONECHIP' bottom right. The top half of the board is home to a number of chips, resistors, capacitors and the switches.

The IC's are as follows:

74LS11 x 1 triple 3-input AND gate.
74LS157 x 4 quad 2-input multiplexer.
74LS132 x 1 quad 2-input NAND Schmitt trigger.
74LS00 x1 quad 2-Input NAND gate.
TMS4416-20 x 2 16,384 word by 4-bit dynamic RAM.
74LS393 x 1 dual 4-bit binary counter.

The only chips that I found to have a date code on them are the RAM chips, with a date of 1983.

Successors

The very successful Commodore 64 followed on from the VIC-20 and you can read about the successor at Commodore 64.

The C64 is a modern, emulated Commodore 64 and VIC-20 hybrid with built-in games; for more information please see The C64.

Similar to The C64, The VIC 20 is a limited edition version of The C64 that was released in Europe in October 2020 and features VIC-20 branding instead of Commodore 64. You can check out the official site for more details:

https://retrogames.biz/thevic20

8-bit guy did a video on a modern VIC-20 kit:

Troubleshooting

Dark video

You may find that the video output of your VIC-20 seems dark and one way to be sure is if when you turn the computer on the supposed white background appears grey. The VIC-20 actually has two composite video outputs, video high and video low, so it's worth checking what both connections look like. See the 'No video' section for more information. There is an adjustment you can do to your VIC-20 in order to brighten its composite output which you can read about on this forum:

https://atariage.com/forums/topic/266431-vic-20-pro-tip-adjust-your-pots/

Note that if you adjust for composite video and then use an RF adapter you may need to perform the adjustments again.

As a comparison here is a screenshot I took from the composite connection before making the adjustment:

And this is the much brighter image after the adjustment:

No video

The VIC-20 is unusual in that it has two composite video outputs called video high and video low and depending on the revision of the computer either or both may actually output a signal. Even if both video high and video low do output a signal they will likely be of different quality; on my VIC-20 one output is more blurry than the other. This means that certain video cables designed for the VIC-20 may not even work for you or may not give the best signal, not that composite gives the best clear image anyway but certainly better than RF.

Please see this site for the video pinout:

http://www.hardwarebook.info/VIC-20_Video

A Commodore 64 A/V cable will possibly work on the VIC-20 but best to double check the connections first.

Poor video

While not as bad as RF, the composite output of the VIC-20 is very poor and noisy, as can be seen by the many screenshots on this page. As some VIC-20 computers output two slightly different composite signals it's worth trying both of them. See the 'No video' section for more information.

S-video gives a much clear output but is not a video output built in to the VIC-20, however, you can modify the computer to output it. There are instructions concerning the modification at:

http://sleepingelephant.com/denial/wiki/index.php?title=S-Video_output

There is also a YouTube video showing the modification being performed:

New Software

As with other microcomputers, the VIC-20 still has a dedicated fanbase and new software is still being produced for the system, which we'll look at in this section.

The Keep runs on an unexpanded VIC-20 and is very impressive in that a 3D-like effect has been created on a computer with only 5KB of RAM.

By the same YouTube user a beta version of a port of Doom:

Resources

Many useful links for VIC-20 information can be found at this site:

http://www.zimmers.net/anonftp/pub/cbm/vic20/manuals/index.html

'A Beginner's Guide to Real Programming Discover Your VIC-20' book:

http://www.1000bit.it/support/manuali/commodore/vic20/A_Beginners_Guide_to_Real_Programming_Discover_your_VIC-20.pdf

'Personal Computing on the VIC-20 a friendly computer guide' book:

http://cini.classiccmp.org/pdf/Commodore/VIC-20%20User's%20Manual.pdf

All content of this and related pages is copyright (c) James S. 2007-2022