Retro-Repair Adventures, Part 3

Shawn Delahunty's picture
"Doing the Shatner...""Doing the Shatner..."

Secrets of the Machine - A Roadmap on Paper...

Hello everyone! I hope that your Summer is beginning well, and that nice weather showed up with it for Memorial Day. In this third installment of "The Retro Repair Adventures", we're going to take a closer look at the truly AMAZING documentation which came with the VIC-20 right out of the box. Then I'll take you through some of the other programming books gifted to me on that fateful Christmas, so long ago. I will also explain in further detail how this documentation enabled me to effect a repair for the "glitchy characters" which my ailing VIC-20 displayed in the last episode.
This is a long one, so warm up your propeller-beanies, strap on your Steampunk geek-goggles, and read on!

Retro-Repair Adventures:

Back in the first installment of this series, I regaled you with the story of how I acquired my much-beloved VIC-20. I also hinted at the first steps with my VIC-20; steps that set me on the 'Engineering Path'--a journey which still keeps me gainfully employed today. As good as the machine was though, none of those early steps in programming and design would have taken me anywhere, or would have even been possible, had it not been for the effort that Commodore put into the documentation for the VIC-20.

They Don't Print 'Em Like They Used To....

Out of the box, my VIC-20 came with a small "User's Guide"; a spiral-bound, high-gloss thing. (Everything Commodore put out for the VIC was printed in this manner; big, cartoony, colorful, and high-gloss. I suppose they were constantly trying to remind you that, "This was the Wonder Color Computer of the 1980's!") In comparison to the sad little 1-page pamphlets and 3-page CD-only PDFs that might come bundled with a modern PC, this booklet looks like The Library of Congress.

Now it is undeniably true that nearly all of the 8-bit computers from that bygone era came with far better documentation than any modern PC's do. This is partially because computers were so new at the time; there was little "cultural awareness" of how they functioned, and what you could do with them. Manufacturer's had to introduce their customers to the product (to reassure the customer they'd spent their money wisely, and to encourage them to buy the equally expensive peripheral devices.) The other primary reason for providing higher quality documentation was to simply offset the crudity of the machines themselves--these were extremely "user unfriendly" boxes, no matter what the colorful packaging (or William Shatner) might claim.

VIC-20 User GuideVIC-20 User Guide

At least initially, to get any use whatsoever out of the machines, the user was essentially forced to program the thing. For a long time, pre-packaged software was limited to games, or perhaps 1 or 2 very crude text-editors which masqueraded as "word processors" in those days. Unsurprisingly, the manuals which came with the various brands of 8-bit machines tended to focus on programming, providing lots of little example programs written in the various flavors of BASIC. They also focused on how to hook up peripherals, like cassette-tape players and printers, and how to configure those to work. (This was WAAY before the era of "Plug and Play". This didn't even qualify as "Plug and Pray". This was more like, "Plug, Dig through the manual to configure 15 obscure little switches, Attach the adapter box, Attach the other cable to the computer, Turn it on, Turn on the peripheral, and THEN Pray... that you didn't plug something in wrong, blow up your computer, and burn down your house.")

But the Commodore manuals were different, special; even by the standards of the time. The User's Guide which came included in the box with the VIC-20, not only explained BASIC programming, not only showed you where to plug in joysticks, cassette-tape recorders, disk-drives, and printers, not only showed how to use those peripherals via code examples, but it also provided some pertinent (and honestly, highly technical) details of the machine's innards.

Here are some excerpts:

Chapter Overview AChapter Overview A Chapter Overview BChapter Overview B
Screen / Character mappingScreen / Character mapping Memory Locations / Color MappingMemory Locations / Color Mapping
Math-y Bits + Port WiringMath-y Bits + Port Wiring Port PinoutsPort Pinouts
Appendix ReferencesAppendix References My ScribblingsMy Scribblings

As you can see from the examples, there is a goodly bit of information here. A lot of topics are covered:

  • character graphics layout
  • memory layout and color-code mapping
  • sound output & musical tone generation
  • hardware port pinouts and BASIC access methods
  • programming theory, design, and structure

All of this is presented in a very approachable way, with simple hand-holding steps building on top of one another. Despite it's smallish size, the User's Guide provided sufficient information about the machine layout and BASIC programming, such that a determined kid could write some rather complex software. A little bit of ingenuity, a lot of effort, and a goodly chunk of time was all that was required to create code that could: simulate physics, sample and analyze data (via the joystick and paddle port), control external devices, provide hours of gameplay, analyze and graph complicated math functions, tell stories, generate sound-effects, and so forth.

Digging Deeper... Learning to Become The Ghost In My Machine

In the weeks after Christmas, I devoured the information and code-examples in the User's Guide. I spent countless hours typing in the sample games and programs, and making modifications to experiment with them. This was my first real experience with the addictive power of "The Zone", which comes when deeply immersed in rewarding mental effort. It was also, much to my mother's dismay, my first experience with a serious side-effect of getting into "The Zone": namely, Sleep Deprivation--something which all true programmers come to know well.

The plebian notions of "Day" and "Night" drifted together; they were meaningless designations. Everything was forgotten while I was buried so deeply in the machine; studying, puzzling, experimenting, and forever doodling new ideas. My utter immersion into the machine-world was aided by one simple fact: the weather.

During winter in Pennsylvania, there really is very little to differentiate "Day" from "Night". Both are cold, dark, grey, windy, wet, and generally filled with snow. In fact, to this very day I'm convinced that crappy weather is a prime factor in creating successful software. How many big/famous software development houses have ever existed in Hawaii, Tahiti, or along the sandy shores of the Caribbean? None so far as I know. All the biggest ones are in cold, snowy, rainy, or otherwise adverse climates.

Having exhausted the examples and information in the VIC-20 User's Guide. I next split my attention between two of the other books gifted to me: Compute's First Book of VIC and The VIC-20 Programmer's Reference Guide.

Compute!'s Book of VICCompute!'s Book of VIC Programmer's ReferenceProgrammer's Reference

At that time, Compute! magazine (exclamation point included) was THE resource for information on the 8-bit systems. This particular book served as a collection of those articles and examples, dedicated specifically to the VIC-20. It was from this book that I obtained a great number of sample type-in programs. This book also rounded out my knowledge on the capabilities and limitations of BASIC programming for the VIC-20. It covered topics such as:

  • Handling joystick and paddle-controller inputs.
  • Detailed memory access and custom-configuration of the machine.
  • Examples for controlling tape-units, disk drives, and printers.
  • Methods for getting character and bitmap animation to work.
  • Custom configuration of the MOS-6520 VIC (Video Interface Chip) to allow unusual display modes, bizarre sound outputs, and so on.
  • An introduction to adding simple "helper" Assembly Language routines which you could call from BASIC.
Nearly all the code in the book is written in BASIC, so I could follow along easily. Just as with the simple examples from the User's Guide, I spent a great deal of time fiddling with my own modifications to the example code--and that's where I really began to make progress. Over time, the patterns and methods and "larger-scale" concepts of designing software began to sink in. (For those of you who are rolling your eyes at this statement, particularly given that I'm talking about line-numbered BASIC here, deal with it. I wrote an article last year explaining why I think BASIC is STILL a good choice for learning to program.)

I had written a goodly bit of software before this, on the TRS-80 and Apple ][e machines at school. Now, my output exploded, both at home and at school. I began scribbling down program ideas and code at every opportunity: during study-hall, on the bus, at the dinner table, in the middle of the night, while sitting in the bathroom... (Hey, you've got to do SOMETHING, and crossword puzzles never were my thing.)

Sample code, Sample code, and MORE sample code.Sample code, Sample code, and MORE sample code.

Having wrung out most of the information available in Compute!'s First Book of VIC, it was around this same time that I also began experimenting seriously with Assembly Language. I found the process incredibly frustrating at times, as I had no one to teach me, and no one with whom to bounce ideas around. The Programmer's Reference Guide came to my rescue. The book led me through the complexity of programming Assembly Language, and the bizarre intricacies of doing so on a real machine, with real constraints.

This is the book which really opened my eyes to the possibilities and capabilities of the VIC-20 and computers in general. This is the book that made that 'mysterious, secret knowledge' accessible to me. This is the book, above nearly all others I've ever read, which helped determine the course of my life.

It may surprise you to learn that this amazing book is still incredibly valuable today, and not just to me personally as a 'nostalgia piece' or in general as a 'historical artifact'. Why? Because even now, this book contains the knowledge equivalent to roughly 3 to 4 COMPLETE SEMESTERS of a modern Computer Science / Electrical Engineering degree.

No, I'm not kidding.

Topics this book covers:

  • efficient programming methods
  • CPU architecture
  • communication bus design
  • system architecture
  • digital and analog input control interfacing
  • real-time system responsiveness
  • input hysteresis
  • multi-task switching
  • data-synchronization
  • 'interrupt' handling
  • resource sharing
  • data transmission methods

ALL of these topics are the daily meat and potatoes of a modern systems engineer. And this single book covers them, providing an introduction to each concept, discussing the difficulties and pitfalls, and including sample code and explanatory diagrams.

Assembly Language FlashbackAssembly Language Flashback Detailed Memory MappingDetailed Memory Mapping
Kernel / OS boot-upKernel / OS boot-up Yet more memory mappingsYet more memory mappings
Input DevicesInput Devices System Architecture LayoutSystem Architecture Layout

Interesting Side-Note:

Believe it or not, the venerable old MOS 6502 CPU which powers my VIC-20 is RELEVANT EVEN TODAY. In the realm of "Embedded Systems", modern variations of the 6502 CPU are still being designed into new equipment. (Wikipedia Entry on the MOS 6502 CPU.) This processor, along with the Zilog Z-80 CPU it competed against, not only helped define and shape the world of modern computing and electronics, they both continue to do so. This is an astounding achievement, a credit to their designers' ingenuity and effort.

So my thanks go out to the authors, anonymous and otherwise, who put together those books. I honestly have no idea what I would be doing today, had I not been able to study, learn, and grow my skills with those manuals. Walking dogs or selling 'slightly used' lemons door-to-door more than likely...

Fixing the Flicker... MY VIC-20 LIVES again!

Ok, I know this has been lengthy, but stay with me, we're in the home-stretch here.

Waaay back in Part #2 of this series, there was a little video which showed the sad state of my VIC-20's screen output. How was it possible to diagnose the glitchy, sparkly, display problem? In a word: Documentation, damn fine documentation. The Programmer's Reference Guide came with full-schematics for my VIC-20. These schematics enabled me to track down and fix the video/character-corruption fault.

Full VIC-20 SchematicsFull VIC-20 Schematics

Without dragging you fine folks through too many details, I was able to use the schematic and Programmer's Guide in roughly this fashion:

  • RAM chip gone bad? Doubtful. The test program I wrote showed that everything I wrote to RAM read back just fine.
  • Bad trace on the circuit board? No. I traced through the lines on the schematics which went to the RAM, CPU, and so on, and matched those to the wire traces on the circuit board. An inspection of the board showed everything looked great. (Despite having dumped half a glass of tea into the thing 30 years ago.)
  • Fault in the CPU? Not likely, or the thing would crash, go crazy at random, or never work at all.
  • Problem in the VIC chip? Not likely. It connects to too many other parts of the system, and would likely just crash the machine or kill the display entirely.
  • Video RAM chip problem? Maybe, but the flickering bits didn't correspond to specific colors or sections of the display. The way the 2114 RAM chips are layed out to map memory, any characters in the "glitchy" region would appear scrambled--but only certain characters blinked, and did so all over the screen.
  • Problem with the KERNEL ROM chip? Unlikely. Though it was remotely possible that the crude OS in the VIC 20 was glitching, and overwriting part of the screen memory or something, odds are the VIC simply would fail to boot properly.
  • Problem with the BASIC ROM chip? Nope. The problem showed up in "immediate mode". That is, when the VIC-20 was basically doing nothing; just waiting on user-input and blinking the cursor.
  • Character Bitmap ROM? Ahhh, that would explain some things...
That the blinky-bits fluctuated in the same pixels of a given character, SIMULTANEOUSLY on every appearance of that character on-screen, was telling. More than likely, the VIC-20 character ROM (901460-03) was faulty, or had broken/flaky pins. Opening the machine again, removing that ROM chip, and doing an inspection yielded no cracked or bent pins, and no corrosion or burn-marks on the circuit board. Time to dig up a replacement chip.

Five minutes searching on-line and less than $10 later, a NOS (new old-stock) VIC-20 character ROM was on the way. When it arrived, I plugged the chip into the socket on the motherboard, fired it up, and VOILA!

I have a Dream(cast)...I have a Dream(cast)...

A Quick Peek at Part #4

Thanks for hanging in there everyone! I know this was a long article, but it helps set the stage for next time. In the next and final installment of the Retro-Repair Adventures, you're in for a little treat; I will be revealing, for the first time ANYWHERE, some of my very own early attempts at BASIC game programming. I'll also give you a look at some of my hand-sketched notes for a Defender clone which never made it past the drawing-board stage. With that as a starting point, I'll then explain why the VIC-20 is both very EASY to program, but very DIFFICULT to program well.

See you soon, and happy retro-gaming!


Bill Loguidice
Bill Loguidice's picture
Joined: 12/31/1969
Wow, awesome troubleshooting.

Wow, awesome troubleshooting. Glad it went well with the ROM chip and you didn't have to dive much deeper.

I actually just ordered a third VIC-20 off of eBay (the second original-style model), hoping this one has that elusive combination of low interference video and working keyboard.

Matt Barton
Matt Barton's picture
Joined: 01/16/2006
Awesome job. I can only

Awesome job. I can only marvel at your engineering prowess.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.