Sunday, January 6, 2019

Meet Commodore's VIC(-20), the Friendly Computer




When Commodore made the PET-2001, they made a computer that found some success in the market, especially in Europe.  The PET turned into a series, but it was an all-in-one PC that came with a monochrome monitor and was rather an expensive product.  Commodore wanted to expand to more of a mass-market, and they designed the Commodore VIC-20, the first personal computer to sell for less than $300.  The VIC was very successful when it was released in 1981, becoming the first computer to sell over one million systems.  Its low price and feature set (color graphics, 4-channel sound) helped it to outsell its competitors.  But it days in the limelight were short-lived due to the arrival of its successor, the Commodore 64.  Having acquired a VIC-20, let's take a look at some of the practical issues with using it.




The VIC-20 vs. the C64

If you have ever tinkered with a Commodore 64, then using the VIC-20 will be much easier.  The VIC-20 uses a 6502 CPU running at 1.02MHz (.985MHz for PAL) and has 5KB of SRAM built in for system RAM and also has 512x4 SRAM nybbles for Color RAM.  There is an 8KB BASIC ROM, 4KB Character Generator ROM, and an 8KB KERNAL ROM.  The video and audio is provided by the Video Interface Chip VIC-6560 (6561 for PAL) chip.  Interfacing is done via a pair of 6522 Versatile Interface Adapter VIA chips.  The keyboard uses the same 66-key keyboard that the C64 uses, although there may be some cosmetic differences.  There is one 9-pin joystick port compatible with one button Atari joysticks and (to an extent paddles), a two-prong plug for an external transformer (or DIN for a power supply in later motherboard revisions), an Expansion (Cartridge) Port, a Audio/Video Port, a Serial Port, a Cassette Port and a User Port.

The Commodore 64 uses a 6510 CPU running at 1.02MHz (.985MHz for PAL) and has 64KB of DRAM.  The 6510 is a 6502 with a pair of I/O registers.  There is an 8KB BASIC ROM, 4KB Character Generator ROM, and an 8KB KERNAL ROM. The video is provided by the VIC-II 6566 (6567 for PAL) and the audio is provided by the Sound Interface Device 6581 SID chip.  Interfacing is done by a pair of 6526 Complex Interface Adapter CIA chips.  Unlike the VIC-20, which uses ordinary TTL logic chips for interfacing the various chips in the system, the C64 uses a custom Programmable Logic Array to handle chip enables and bankswitching.  The C64 has two Atari-style 9-pin one-button joystick ports (with paddle support), a DIN plug for an external power supply, Expansion (Cartridge) Port, a Audio/Video Port, a Serial Port, a Cassette Port and a User Port.

So between the two systems, the Joystick Port(s) are fully compatible, the Cassette Ports can use the C2N 1530 Datasette, and the Serial Ports can use a CBM-1541 Disk Drive or Commodore Printers.  The VIC-20 can use the CBM-1540 Disk Drive but the C64 cannot without modification to the drive.  The User Port may look identical on both systems, but they use their own peripherals for the most part.  The User Port on the VIC-20 was mainly limited to modems, RS-232 serial interfaces and parallel printer adapters.  The Expansion Ports on each system use different pin spacing and signaling (even though the number of pin contacts are the same).  A VIC-20 with the DIN power connector can use a C64 power supply, but the C64 requires more power than many variations of the official VIC-20 power supplies are able to give, so do not use a VIC-20 power supply in a C64 unless you know for certain that the power supply can meet the C64's power needs.

In several ways, the early VIC-20 is more reliable than the C64.  The C64 has some chips that run hot and like to fail, namely the SID and the PLA.  The original VIC-II is a ceramic chip with a metal heat spreader attached to the RF shield via thermal grease, the VIC is a plastic chip and does not make contact with its RF shield.  The original C64 Power Supplies are plastic and epoxy-encased time bombs.  The early VIC-20's external transformer is just that and unlikely to fail, DC conversion goes on inside the computer and its fuse can be replaced after opening the plastic case.  The joystick attached to the VIC-20's joystick port will not cause errant keyboard characters to appear to be pressed in BASIC, unlike the C64.

The VIC-20 is easier to service in many ways compared to the C64.  The main chips should be socketed in the (older) VIC-20, most of the time they are soldered in the C64.  The 6502 and 6522s in the VIC-20 had many uses outside of the VIC-20 and should be easier to source than the 6510 and 6526s not found in many systems outside the C64.  The RF shield underneath my VIC-20 appears to be attached to the PCB via copper tape, on the C64 it is often soldered to the board in several places.

The BASIC used in the C64 and VIC-20 and some of the PET 2001s is Commodore BASIC 2.0, a development of Microsoft BASIC.  BASIC functions as both a programming language and the shell for a rudimentary operating system for entering commands to load, save and boot programs.  This BASIC lacks any commands for advanced graphics and sound, so users learned the memory addresses in which they had to PEEK and POKE memory values.  Unexpanded, the VIC-20 has 3583 bytes available to BASIC on bootup while the C64 has over ten times that amount, 38911 bytes free.   While a ROM cartridge can provide more sophisticated graphics and sound commands, none became so ubiquitous for the VIC-20 or C64 that BASIC programs for these systems required more than the commands available in BASIC 2.0.  Unfortunately, another user of that program will need that cartridge expansion, which made BASIC ROM expansions less than ubiquitous. 

Get Used to this Screen
The KERNAL ROM provides the low-level routines needed to interact with peripherals, not unlike a BIOS and is very similar between the VIC-20 and C64.  The KERNAL interacts with various "devices".  Device 0 is the keyboard, device 1 the datasette, device 2 an RS232 interface, device 3 is the screen, devices 4-7 are intended for printers and 8-11 for disk drives.  When you type in LOAD, the computer assumes that means LOAD [Device] 1 and knows that to mean you want to load from the datasette,  You need to type in LOAD [Device] 8 to get the computer to access a disk drive.

Graphics and Sound

The graphics capabilities of the VIC-20 may be the subject of misinformation.  The default resolution of the VIC-20 is 176x192, but it can be increased to 216x192.  The VIC-20 defaults to using the patterns contained in its Character ROM and many games use these patterns exclusively.  With each 8x8 tile able to show one foreground and one background color from a selection of 8 or 16, the VIC appears to show low-resolution ASCII text-graphics.  However, all pixels can be addressable in the tile format by a programmer using custom tiles.  This requires more memory than is available to unexpanded BASIC for a full screen of user-definable graphics.  It can use programmer-defined tiles, but it has no sprites and no hardware tile transparency.  That is why you see black boxes around characters in games like Q-Bert and Frogger.  It also has a low resolution mode which halves the horizontal resolution but allows four colors per tile.

The audio sounds similar to the TI SN76489, and it is comprised of three square wave generators and a noise generator, the audio is more limited.  Each square wave channel has a 7-bit frequency divider, but each channel uses a different base frequency so that channel 1 produces the lowest pitched sounds and channel 3 produces the highest pitched sounds.  There is considerable overlap in the frequencies output by each channel.  Each channel can produce sounds in three octaves for five octaves total.  By contrast, each square wave generator on the SN76489 can output a range of 10 octaves.

Memory Expansions

Memory is a rather important subject for the VIC-20 for the end user to master, an issue not really shared by the C64.  The C64 is not really designed to handle more than its 64KB of RAM, but the VIC-20 was designed to be expandable up to 40KB of user memory (5K + 3K + 32K).  Unlike the C64, the VIC-20 has no built-in bankswitching, so only one type of memory device can be assigned to a set of memory locations at one time.  Cartridges provide their own memory in the form of ROM.  Tape software will often require a memory upgrade.  Commodore made Cartridge memory upgrades in the 3K, 8K and 16K varieties while third parties have contributed 24K, 32K and 35K upgrades.

This is what the VIC-20's 64KB memory map looks like :

-------------------------------------------------------- 0000
Internal RAM 1K (Block 0)
-------------------------------------------------------- 0400
Available for Expansion RAM 3K (Block 0 Cont.)
-------------------------------------------------------- 1000
Internal RAM 4K (Block 0 Cont.)
-------------------------------------------------------- 2000
Available for Expansion ROM or RAM 8K (Block 1)
-------------------------------------------------------- 4000
Available for Expansion ROM or RAM 8K (Block 2)
-------------------------------------------------------- 6000
Available for Expansion ROM or RAM 8K (Block 3)
-------------------------------------------------------- 8000
Character ROM 4K (Block 4)
-------------------------------------------------------- 9000
VIC Graphics & Sound and VIAs I/O 4K (Block 4 Cont.)
-------------------------------------------------------- A000
Available for Expansion ROM or RAM 8K (Block 5)
-------------------------------------------------------- C000
BASIC ROM 8K (Block 6)
-------------------------------------------------------- E000
KERNAL ROM 8K (Block 7)
-------------------------------------------------------- FFFF

A ROM cartridge is typically 4KB, 8KB or 16KB in size and will occupy one or more of those addressing slots reserved for Expansion devices.  There is only one Expansion Port, so it will usually be occupied by a ROM cartridge or a RAM Expansion cartridge.  There were Slot Expanders made available so the Expansion Port could accept six Cartridges, but ROMs do not work properly when RAM is in the locations where the ROM wants to be and vice versa.  You cannot run more than one Cartridge ROM at a time.  Most game cartridges boot up immediately and you will not see the BASIC screen.  The five Scott Adams' Adventure cartridges will not boot into the game unless you type SYS 32592 into BASIC (helpfully the command is given on the cartridge label).  A few other cartridges, mostly non-games, also have a SYS entry requirement before they will do their thing.

The VIC-20 is one the last home computers released in the United States which used cassette tape for distributing software to any substantial degree.  Computers like the Apple II and Atari 400 and 800 had used cassettes as a major storage medium in their early days, but floppy disk-based distribution for software for these machines took over cassette releases (or cartridge releases for the Atari).  The VIC-20 did have the CBM-1540 disk drive released specifically for it, but the very few software programs and were officially released on disk during the machine's lifetime (1981-85).

Many, many games were released on cassette tape.  A good deal of tape software requires a RAM expansion.  The software's box or manual or the archive in which you found it will tell you how much RAM is required.  If the software does not require a RAM expansion and appears not to work correctly, remove the RAM expansion from your system and try again.  Adding RAM expansions changes the location of the memory available to BASIC, and if the program was not written with that contingency in mind, it will not work properly.  Software requiring the 3KB RAM Expansion must have a cartridge that can fill the 3KB hole left in Block 0 as shown above.  Software requiring 8KB or more RAM should be upwards compatible with Expansions which provide more RAM.  The Commodore 8KB RAM Expansion has dipswitches which allow you to designate which Block, 1, 2, 3 & 5, in which it will be located.  Unfortunately, to get access to those switches requires opening up the cartridge, which is rather difficult to manage without breaking plastic.  The Commodore 16KB RAM Expansion does not allow for relocation, it resides at Blocks 1 & 2.

If your VIC-20 recognizes your memory expansion, the number of BASIC bytes free will increase.  The machine will also take a few more seconds to display the BASIC screen.  For the 3KB Expansion, it will show 6656 bytes free (or 6519 bytes free if using the Super Expander Cartridge), 8KB gives 11775 bytes free, 16KB gives 19967 bytes free, 24KB or more shows 28159 bytes free.  If you plug in an expansion and still see only 3583 bytes free, the system is not recognizing the expansion.  I would suggest turning the system off and wiggling the cartridge in the slot or removing and reinserting it and cleaning the slot.

Maintenance & Safety Tips

You should also clean your Expansion Slots after receiving your system or a period of extended inactivity.  I take a plastic card, wrap a piece of paper around the edge, apply 99.9% Isoprophyl Alcohol to the paper and insert the paper-covered card into the system and remove it several times.  You should see some impression from the contact pins.  Make sure you get all the pins, left and right.   Once you have finished with the wet paper, do it again with dry paper.  Repeat until you see no more dirt and the contacts barely leave an impression on the paper.  This method works for just about any cartridge or expansion slot.  Use a Q-tip and alcohol and clean the contacts of the Cassette Port and the User Port if you intend to use those.  When you have used a wet tip, follow up with a dry tip until you see no more dirt come off the tip.  99.9% Isoprophyl Alcohol is not something you typically find in a store, Amazon has it for a reasonable price here : https://www.amazon.com/MG-Chemicals-Isopropyl-Alcohol-Cleaner/dp/B0797BZDM5  If your computer has scuff marks, denatured ethyl alcohol is a better cleaner than isoprophyl alcohol.A

VIC-20 cartridges have contacts with cut-outs for a keyed slot, but Expansion Slot is not keyed.  This does not matter for cartridges enclosed in a shell because the shell's shape presents incorrect insertion.  The cartridge label always faces up. If you only have a bare PCB to work with, the chip/component side always faces up.  The card edges for the Cassette Port and User Port have cutouts in them for a keyed connector.

The 1530 C2N Datasette has a connector which can only be inserted one way.  Mine came with a separate grounding wire coming out of the connector's housing, but the manual does not discuss the purpose of the wire.  Often peripherals like printers during the 1980s would have a grounding wire to connect to the attached PC to prevent ground loops. There is no obvious place on a VIC-20 or C64 to attach the grounding wire, so it may be more useful with PET computers.  The only to record and playback to and from a tape using the Datasette is via the VIC-20, the Datasette cannot be used as an ordinary cassette deck. It has no audio input or output jacks.

If you have an early VIC-20 with the external transformer brick, that transformer uses electricity whenever it is plugged into the wall socket.  Remove it when not in use.  The IBM PCjr. also uses an external transformer brick and it should be unplugged to save electricity.  The joystick and the video cables are the only thing that can be unplugged while the machine is turned on.  A heatsinks should be applied to the CPU, the KERNAL ROM and especially the VIC, these can get hot.  A VIC heatsink should make contact with the metal RF shield surrounding the video section for maximum heat dissipation.

Working with the Keyboard

The Keyboard behaves very similarly to the C64's keyboard.  The shift, control and C= all produce different characters when held down as a letter or number or punctuation key is typed out on a BASIC command line.  Shift will show the right character underneath a letter and C=will show the left character.  For the number and punctuation keys, Shift or Control shows the upper symbol.  Shift will also do a CRSR Up and CRSR Left as well as activate the F2, F4, F6 and F8 keys.  You change the current text color by pressing Ctrl 1-8.  You can enable and disable reverse video with Ctrl 9-0.  When you press Shift and C=, the upper case letters will turn to lower case letters.  This allows you to type in lower case and reserve upper case letters to the Shift key, but only the graphics characters shown on the left side of the keys will be available with the C= key.  Run/Stop saves you from having to type in RUN in BASIC and can also break out of a BASIC program or a bad LOAD.  Shift and Run/Stop is a shortcut for the LOAD command, and Restore and Run/Stop acts like a warm reset.

The Keyboard's key assembly is extremely simple.  The key attaches to a shaft, and on the other end of the shaft is a plunger with a carbon contact on the bottom.  Each key has a spring underneath to push the plunger after the key is released. When the carbon on the end of the plunger makes contact with the contacts of the PCB, the circuit is completed.  If some keys are not as responsive as others, you may need to separate the keyshaft housing from the PCB by removing a bunch of small screws and desoldering the Shift Lock key.  If the PCB contacts look good after cleaning with alcohol but the buttons still register intermittently, then you may need a product like CaiKote 44 to revive the conductivity of the carbon pad. If whole rows fail to respond, then one of the VIA chips need to be replaced.

Gaming on the VIC-20

If you buy a VIC-20 that comes with compete in box, you can expect the system unit, the power transformer/supply, the RF modulator and an RF switch box and the spiral-bound user manual "Personal Computing on the VIC-20, a friendly computer guide."  In my opinion, in order to have a really useful VIC-20 gaming experience, you will need the system unit, the power supply, a 16KB RAM Expansion Cart, an A/V cable, an Atari-style joystick and a Datasette and whatever cartridges you can find.

Commodore 64 composite video cables will work fine, as will PC Engine stereo AV cables.  If you have the PC Engine cables you connect the PC Engine's right audio (white RCA) to the video (yellow) and the PC Engine's video (yellow RCA) to the audio (white).  The VIC-20 outputs composite video on pins 4 & 5 of the DIN connector.  One pin supposedly provides a stronger signal than the other, but I tried both and noticed no discernible difference in the brightness or color.  On my TVs I see gray as the background color, even though it should be white, unless I boost the brightness to ridiculously high levels.  The VIC-20 has a brightness level adjust potentiometer which can get the levels higher at the cost of some noise in the audio output when the audio is silent.

I only would use a no-electronics joystick or gamepad in a non-Sega system with a 9-pin port.  Sega Genesis gamepads may cause damage to the VIA or CIA responsible for joystick usage in the VIC-20 or C64, but Sega Master System gamepads are safe.  To be safe your controller cannot have any kind of integrated circuit like a multiplexer inside them.  Atari 2600 paddles will work with the VIC-20 or C64, but the true Commodore paddles use 470KOhm potentiometers while the 2600 paddles use 1MOhm paddles  You may find that your Commodore games will accept a much narrower range of paddle movement for input.  You'll will need various sizes of RAM expansion for homebrew games like 8-bit Guy's Planet X-1 (32KB), Robert Hurst's Berzerk MMX (8KB), Kweepa's DOOM (35KB) or Maniac Miner (16KB).

There are several cartridges available today, such as the Mega-Cart and the PenUltimate+ which can provide access to the much of the cartridge library without needing to track down the original cartridges.  These two can also expand your system's RAM up to 35KB in all the necessary configurations.  These cartridges cost around $100 USD, but offer a good deal of the VIC-20s' library.

Many games that came on tape have been reduced to .prg files which can be loaded via a floppy disk drive or even a simple floppy drive emulator like the SD2IEC.  As there was not a lot of floppy software, floppy disk copy protection is not an issue on the VIC-20 unlike its successor the C64.  There are also Datasette emulators that can transfer TAP files to the Cassette Port without hardware.

In terms of games, what would I recommend?  Certain companies were known to put out consistently good releases for the VIC-20.  Atarisoft, Llamasoft (Jeff Minter) and many of Commodore's own games are good.  Epyx put of some of the best games on tape, and the homebrew software mentioned above and other games recently created is worth checking out.  There is one other game I really like which I will feature shortly in this blog.

Using the Datasette to Load Software from Cassette

Having acquired a physical Datasette but having no tape software, I was able eventually to transfer my own software directly to the Datasette without physical tapes.  I checked to make sure the Datasette was working by saving and then loading s short BASIC program to tape.  Something like this will be enough :

10 PRINT "HELLO WORLD"
20 GOTO 10

The programs audiotap and wavprg are vital to the process.  Find them here : http://wav-prg.sourceforge.net/audiotap.html  Audiotap turns a TAP file into a WAV file which you can record to a tape or play it through your PC's audio hardware.  WAVPRG turns a PRG file into a TAP or WAV file.  I had to check the Inverted Waveform box in both programs because most sound output devices these days invert the waveform on output. The only other option I adjusted was to the output frequency which I set to 48000 because modern sound devices resample lower frequencies to that frequency when outputting the sound.

However, my cassette recorder only has a Microphone Input jack, not a Microphone Input and a Line Input jack.  The Mic In's impedance is very different from a Line In and the Automatic Gain Control plays havoc with a waveform written to tape that is intended for data instead of audio. A vintage cassette recorder would have worked much better I suspect.  So try as I might, audio recorded onto tapes with my cassette recorder would not load regardless of how short the program was.

I obtained a CD to Cassette adapter.  These adapters are great because they do not really need to advance spools of tape.  Instead there is a magnetic head where the tape would be that passes the proper magnetic pulses to the magnetic head on the cassette deck.  A wire sticks out that connects to a line output from a CD player, a PC or a phone.  Even if a Datasette's motors and belts are broken, as long as the magnetic head and the electronics inside still works, you can manage with a CD to Cassette Adapter.  The wire will have a kink in because the Datasette will close on it and it will be a tight fit, but it should work.  Using the 48000Hz sample rate and inverted waveform options, my TAP files loaded fine through the Datasette and CD to Cassette adapter.

With Audiotap, I was able to turn TAP files into WAV files.  From there I found it was most convenient to use my phone instead of my PC to load the cassette programs.  I was able to get reliable results by setting the volume on my phone to one notch above the maximum recommended listening level.  If you don't have a phone, any audio player should work if it can play WAV files.

I use WAVPRG to turn PRG files into TAP files.  PRG files are binary dumps of cartridges and programs with just a two byte header to tell the loader where in memory the data needs to go.  When you use the WAVPRG program and go to the Conversion from PRG, P00 or T64 screen, select  VIC20 NTSC or VIC20 PAL depending on the region of your VIC-20 and do not touch the other settings above that drop-down menu.

If you have the memory expansion capabilities needed by a VIC-20 program, you can load those programs via the Datasette.  Some programs, mainly 16KB games, will require two loads.  Some programs load themselves into non-contiguous blocks of memory and blocks of memory which your memory expansion may not cover. Most cartridges load themselves into Block 5 or Blocks 3 and 5 because they are the least likely Blocks to be used by RAM expansions.  So unless you have a 32KB memory expansion, this avenue really is not open to you.  If it is, when you finish, perform a warm reset with Run/Stop and Restore and your game should run. There are a few cartridge games which will not run in RAM as they are dumped from the cartridge, fortunately there are patched ROMs available for most of them.

Resources

The best repository for VIC-20 documentation and programs can be found here : http://www.zimmers.net/anonftp/pub/cbm/vic20/index.html

This is the gateway to the very useful VIC-20 wiki and the most active forum devoted to the VIC-20 : http://sleepingelephant.com/denial/

Vital repair information can be found here : http://personalpages.tds.net/~rcarlsen/cbm/

2 comments:

  1. Re: audio; there's an analogue 1.6kHz low-pass filter (see R16 and C20) which further affects audible range. The Vic also has a really weird implementation of square wave generation: 8-bit shift registers that at each stage feed the input bit with the complement of the output ANDed with the channel enable. With the net effect that a carefully-timed setup loop can load any other 8-bit digital waveform and then leave that, alternating with its complement, playing indefinitely. Which expands the range of possible sounds substantially.

    ReplyDelete
  2. The Vic-20 was released in 1980 in markets like Japan.

    ReplyDelete