About This Software

I got to use my first computer in 1980. It was a TSR-80 Model I, and responsible for me wanting a computer of my own, but Radio Shack sold TRS-80 Model I setups for about $600.00, which was way too expensive for me. About a year later, I saw my first Commodore VIC-20. The VIC-20 retailed for $300, and could be purchased for about 20% off at the local discount eletronic store. Saving all of my gift money that year, I bought a VIC-20.

The only software that came with the VIC-20 was a version of Microsoft BASIC in it's ROM. Any other VIC-20 software had to be typed in and saved to a cassette tape (If you don't know what a cassette tape is, you'll have to look it up yourself). Fortunately the VIC-20 came with a book, "Personal Computing on the VIC-20 A Friendly Computer Guide". That book included source code for a game written by Duane Later, Tank-V-UFO. My mom helped me type in that source from the book, and after debugging the typos, I had a working copy of a game that I must have played for hundreds of hours. It wasn't good enough to play the game as-is, I had some tweaked versions that I played too.

This Tank-V-UFO, is not the original VIC-20 version, but it was definitely inspired by the original. The game play is similar to that of the original, where "similar" is based on my memory and YouTube videos. The source code for this game is not derived from the VIC-20 source code. It is written in C and relies heavily upon the ncursesw and portaudio libraries.

Original VIC-20 Game

My ncurses Version

If you just want my source code, click here for information on downloading it.

The rest of this page discusses some of what went in to writing the software and how to build an executable from the source.

Design Decisions

First and foremost, I wanted to make something that felt like playing the original, but wasn't necessarily and exact duplicate. To me that meant keyboard controls and character based animation. Character based animation is way easier with ncurses, so using ncurses seemed like a no brainer to me. No brainer decisions are about the only kind of decision that I can make.

For keyboard controls, I used the "Z-LEFT,C-RIGHT,B-FIRE" of the original game. From what I can tell, the original game ended when the first one scored 15 kills. My attention span seems shorter than it used to be, so my game ends when Q is pressed. If you don't press Q, the game won't end.

The VIC-20 connected to a TV and volume control was the TV's volume control. The + and − keys adjust the volume on my version.

The VIC-20 had a pretty unique character set. Many of the characters used in the original game aren't part of the ASCII character set. Rather than using bitmaps to replicate the VIC-20 characters, I decide to use Unicode symbols that looked close enough to me. To access the Unicode character set, I had to use the wide version of ncurses, ncursesw.

The VIC-20 display is only 22 columns wide, playing the game using the full 80 columns of a typical terminal emulator feels way different. There's too much waiting for the UFO to get back in place. So the playing field for my version is 23 rows and 22 columns, just like the VIC-20 display.

The real game seems to change colors all the time. I couldn't figure how it worked, so I chose a set of colors that were easy on my eyes and stuck with them. You might notice the similarity to this web page.

I'm pretty sure that the original game just used basic loops for timing. All of the VIC-20s have the same CPU running at the same speed, so loops on one VIC-20 take the same amount of time as loops on all other VIC-20s. The same doesn't hold true for modern PCs, so I poll() on a timerfd for my timing. I tried a bunch of different timing intervals and 200ms seemed about right.

I have no clue how the UFO decides when to fire in the original game. If a UFO shot isn't currently falling, and the UFO can shoot without it going off screen, I give it a 1:3 chance of shooting. I tried a few values and decided that was good enough.

It seems like there are times in the original game where one movement is stopped in order to produce an animation effect or a sound effect. I didn't want to duplicate that. I always use the same movement sequence: UFO, tank, UFO shot, tank shot. Because of that some things, like explosions aren't quite the same.

The VIC-20 also had it's own tone generator and white noise generator for sound effects. Having the exact same sounds weren't important to me, so I used the sfMaker website to get something good enough. If exact sounds are important to you, you can always sample one of the YouTube videos of the game. Though be forewarned that the videos don't all sound the same.

Oh, then there's the fact that I wrote everything in C, because that's just what I started with. Looking at where I ended up, C++ might have been a better choice, but it's too late now.

I'm sure there are other decisions that I left out. If you feel like finding out why I made those decisions, you can e-mail me at mdipperstein@gmail.com and ask what I was thinking. If you're lucky I might remember. Of course, you're free to do whatever you want with my code as long as you don't violate the GPL.

Building The Software

It should be possible to build this software with Visual Studio, XCode, or just about any other IDE if you have an ANSI C compiler, the required libraries, and your OS supports timerfds and poll. As far as I know, that means you're on Linux or something like Cygwin. I'm old fashioned and used a command line and the GNU Tools to build my code.

To build these files with GNU make, gcc, and pkg-config:

  1. Download the source code
  2. Open a terminal
  3. Change directory to the directory containing the downloaded source
  4. Enter the command make from the command line

**NOTE:** The ncursesw library and the the portaudio library are required to build this code. pkg-config must be configured for both libraries.

That's all there is.

Actual Software

This is probably the only part of this web page that anyone would care about. I am releasing my Tank-V-UFO Tribute under version 3 of the GPL. The source code repository is available on GitHub. I recommend that you checkout the latest revision of the master branch, unless you're looking for something specific.

Repository Location https://github.com/michaeldipperstein/tankvufo

Last updated on April 21, 2021