VIC-20 as terminal

Over a lazy Sunday afternoon, while the family was napping, I put into place an idea that formed in my head mere hours earlier: turn my Commodore VIC-20 into a simple terminal for a *nix box.

I was musing on ways to connect my VIC to other systems, and had recently been playing with Chris Baird’s great little hack of transferring files via serial port from a PC using a simple, 25-line BASIC program.  That got me wondering what other ways you could utilize the serial port.

I know that there have been bluetooth VIC-20s, but I didn’t recall to mind anyone just creating a simple terminal.  So I decided to give it a whirl.

First, the trusty VIC.  I’ve had this VIC for as long as I can remember; I believe my dad bought it new in the mid-80s.  We had several machines at home, including an Apple IIe and an IBM XT clone, but this one always felt like “mine.”  Probably because we had no carts or disk drives for it, so you had to hand-type everything.

That "M" key broke off in about 1992.  It was dutifully placed somewhere safe for later reattachment.  Naturally, it hasn't been seen since.
That “M” key broke off in about 1992. It was dutifully placed somewhere safe for later reattachment. Naturally, it hasn’t been seen since.

It sat in storage for many years until I pulled it out again and started to tinker.  First order of business was an internal memory upgrade (more on that in another post).  Then I built a custom RS-232 cable for the user port (lots of instructions out there; basically connect GND to pin A, TX to pins B&C, and RX to pin M).

Enough pre-amble, let’s get to the matter at hand.  I was able to read and write to the port using these simple 8 lines of poorly written CBM BASIC:

10 OPEN2,2,3,CHR$(8)+CHR$(0)
20 L$=""
21 A$=""
30 GET#2,L$
45 GET A$
46 IF LEN(A$)<>0 THEN PRINT#2,A$;
60 GOTO 20

I never said it was good code.  I conjured that up from memory and Google.  At any rate, it does the trick.  But there’s more that needs doing.

On my OpenSUSE 13.1 laptop, I had to set up a tty to listen on the port (/dev/ttyUSB0 in this case).  But I had to have some specific settings.  Here’s what I used for my tty:

/sbin/agetty -L 1200 -U ttyUSB0 -a TEST

This sets the tty up as a local port, running at a blistering 1200 baud.  The -U is crucial — it sets the system up to expect an uppercase-only terminal, since the VIC-20 works in PETSCII instead of ASCII.  ttyUSB0 is the physical port, and the -a TEST line automatically logs in as the user TEST.

I had to set up the auto-login, because (likely due to the PETSCII vs ASCII thing) I wasn’t able to log in, despite making a successful connection.

Success!  Able to get connected to the Linux machine's tty
Success! Able to get connected to the Linux machine’s tty

I also found the following to be extremely helpful in actually using the terminal:

stty -F /dev/ttyUSB0 iuclc olcuc

This essentially sets the com port up to translate uppercase to lowercase on input, and translate it back to uppercase on output.  Unfortunately, I couldn’t get it to stick for more than one command at a time, and haven’t investigated why that is.  If anyone knows, drop me a line.

I’ve received a few good suggestions for improving this, and I might just tinker with it.  But even if I don’t, I’m pretty happy that in just 8 lines I was able to get something somewhat usable.  Still, though, Dad has an Alpha Micro in the closet that needs serial terminals to access…

Long live the VIC!

3 thoughts on “VIC-20 as terminal

  1. Trying to recall distant memories of dealing with TTYs on *NIX systems, I recall that stty settings are not preserved on terminals that are not logged in. The hack solution I used was to have a daemon running (a simple ‘C’ program) that would simply open the terminal device, fork the stty command and then sleep forever, holding the device open.

    Bear in mind this was in the early 1990s, on UNIX/XENIX systems!

    1. Interesting approach. I may have to try that out; and I do actually have a Sun Sparcstation IPX in the garage, though it has a later version of OpenBSD on it at the moment (4.8 I think). But I could re-load SunOS and see what I can see.

      My other thought is to build a Python ‘interpreter’ of sorts that takes the PETSCII codes and translates them to proper ASCII codes.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.