Author Archives: James Abbatiello

Why is my TI-99/4A in Black and White?

by James Abbatiello

My first computer was a Texas Instruments TI-99/4A. Longtime readers may remember a previous article where we implemented TI-99/4A BASIC as a Scripting Language for modern computers. Recently I got nostalgic for the actual hardware so I got my 99 out of the closet where it had been for a decade or more. I hooked it up to the TV and turned it on. I was expecting to see something like this:TI-99/4a title screen

Instead I was greeted by this:

Well, that’s not right! It is in black and white. And what’s with all these vertical black lines? Clearly something’s wrong but what could it be?

New Meets Old

At first I suspected that it was my TV, which is a fairly new LCD. Old computers or game consoles sometimes played a bit fast and loose with the NTSC standard and it seemed unlikely that a new TV would ever have been tested with something as old as a TI-99/4A. Perhaps the TV just couldn’t interpret output from the 99. So I tried with a CRT TV:

Well the black bars are gone (or at least not as apparent) but it is still in black and white. Something must be wrong with the computer itself.

All About Video Signals

The output from the back of the computer is a composite video signal but using a 5-pin DIN connector (that also carries audio and power) instead of the usual RCA jack. Back when this computer was new that signal would usually to go an RF modulator which was then connected to a TV via a 300-ohm connector. Nowadays you can still do the same thing but since most TVs don’t have screw terminals on the back anymore it can be more convenient to take the composite video signal and hook it directly into the composite input on the TV. All that is required is a simple adapter cable that can be created yourself or purchased online.

I thought that perhaps the video circuitry was generating separate Luminance (Y) and Chrominance (C) signals and then combining them into the final composite output. If this were the case then it would suggest something was wrong in the C amplifier or the final combining stage. It turns out that this is not the case. The video chip in the TI-99/4A is referred to as the Video Display Processor (VDP) and is a TMS9918A, TMS9928A or TMS9929A depending on the region the computer was originally intended for and the television standard in use there (e.g. NTSC or PAL). My computer was made for the US market and outputs NTSC signals using the TMS9918A. This chip has a single video output pin that supplies composite video directly with the Y and C already mixed. So if something was wrong with just the C generation circuitry then it was something broken inside the VDP and my only recourse would be to try to find a replacement chip.

Mad Scientist Equipment

The VDP still seemed to work correctly in all other respects so I was hopeful that the true problem lay elsewhere. I thought I’d take a look at the signal on an oscilloscope. We’d expect to the see the NTSC colorburst and if it was missing that would explain why no color was showing up on the TVs. Here’s what it looked like:

And here’s a closeup of the interesting portion:

I’m no expert but that looks like a horizontal sync pulse followed by a colorburst to me. But there was still no color on the TV.

The composite video signal that the VDP generates is sent to a simple 2-transistor amplifier and then to the output jack. I didn’t think it was likely but perhaps something in the amplifier had given out and Y was still strong enough to get picked up by the TV but C wasn’t. To test this I took the computer apart and tapped the signal right as it came out of the chip and before it went through the amplifier. It was still black-and-white. This suggested that the problem was not in the amplifier.

The Healing Power of Crystals

At this point I knew that the VDP was mostly working correctly. It generated the right pattern on the screen so it must be able to communicate with both the video RAM and the CPU. That accounts for most of the pins on the VDP, the ones handling digital signals. The remaining pins are mostly for power and the connection to the quartz crystal that provides the timing. I checked the power and that seemed fine. So let’s take a closer look at the crystal:

The crystal is the gray-colored component in the middle. To the right is the VDP, covered in thermal paste. Just behind the crystal is a variable inductor.

A variable inductor: now that’s interesting! It is connected to the crystal and apparently used for fine tuning the frequency. Could the fix be as simple as turning an adjustment screw?

Alas, no. I turned it as far as it would go in both directions with no improvement to the video output. If the frequency was off it was beyond the ability of this adjustment to correct. I don’t have any equipment to allow precision measuring of the actual frequency this crystal was producing, but I do have the internet. A little Googling brought me to this post on the TI-99/4A mailing list. Yes, there’s still an active mailing list for a computer that hasn’t been manufactured in almost 30 years!

That post describes the symptoms that I was experiencing and indicated that the solution was to replace the crystal. This was somewhat surprising to me. I’d heard of electrolytic capacitors going bad in old equipment but a quartz crystal? They’re usually quite reliable. But you can’t argue with real-world experience.

The VDP takes the frequency of this crystal (10.738635 MHz) and divides it by 3 to produce the NTSC colorburst frequency (3.579545 MHz). If the frequency of the crystal was off then the generated colorburst would also be off and the TV wouldn’t be able to sync to it. Without seeing a valid colorburst the TV isn’t going to produce any color. That would certainly explain our symptoms!

So after deciding to replace this crystal we have to actually find a replacement part. We want a crystal that runs at exactly 10.738635 MHz. We also need it rated for the proper “load capacitance”. Running a crystal with the wrong capacitance will shift the frequency from the rated frequency. That would be bad since our entire goal is to get the frequency back to the ideal. The original crystal was rated for a load capacitance of 32pF (you can just make out the 32 in the above picture although it is partially obscured by the blue wire). So we want a replacement crystal that’s also rated for 32pF.

Let’s go internet shopping for 10.738635 MHz crystals. Jameco doesn’t carry any. Digikey has some but didn’t have any in stock with a 32pF load capacitance. Luckily Mouser came through for me! A few days later and I had a replacement crystal:

And after a little surgery on the motherboard:

Now for the moment of truth:

Success! Now to play some Parsec!

Bonus Oscilloscope Image

If you’re wondering what the colorburst looks like with the new crystal then wonder no longer.

Looks pretty similar to my eyes but apparently it makes a world of difference to a TV.

TI-99/4A BASIC as a Scripting Language

It is a good time for statically recompiled versions of BASIC from old computers.  First there was Apple I BASIC.  Then came Commodore BASIC.  Now, due to overwhelming demand, we’re proud to release TI-99/4A BASIC. For those unfamiliar the TI-99/4A was a home computer by Texas Instruments released in 1981. Unusually for the time it had a 16-bit CPU: the TMS9900.

Download the program from the project page on SourceForge. Binaries for Windows and Mac OS X are available and the source should compile on most POSIX-like systems. If you port it to a new platform please drop us a line; we’d love hear about it.

It supports the same interfaces as the previous projects.  You can use it interactively in direct mode:

$ tibasic
TI BASIC READY
>print 4*atn(1)
 3.141592654

>bye

Or you can write a line-numbered program:

$ tibasic
>10 FOR I=1 TO 10
>20 PRINT TAB(I);"Hello, world!"
>30 NEXT I
>RUN
Hello, world!
 Hello, world!
  Hello, world!
   Hello, world!
    Hello, world!
     Hello, world!
      Hello, world!
       Hello, world!
        Hello, world!
         Hello, world!

** DONE **

>BYE

You can also run programs from a file:

$ cat name.bas
10 INPUT "What is your name? ":N$
20 PRINT "Hello, ";N$;"!"

$ tibasic.exe name.bas
What is your name? James
Hello, James!

There are a few sample programs available on the homepage that you can run in this manner.

How it works

This program works much like the already mentioned Commodore BASIC project. The original program is statically recompiled to produce a new native binary. The recompiler is the work of Michael Steil and the  support for the TI-99/4A is by James Abbatiello.

The output of the recompiler is tibasic.c which is platform independent. The support functions are in runtime_functions.c and it is this file that you would edit to port to a new system or to add new features.

There are a couple quirks of the TI-99/4A which made this a bit trickier to support than the C64 version:

  • The BASIC interpreter was not written in assembly language as you might expect. Instead it was programmed in something called Graphics Programming Language (GPL). GPL was much like an assembly language with some high-level primitives for commonly needed functions. A program written in GPL would be assembled to bytecode and then run on an interpreter that was written in TMS9900 assembly language. This made BASIC programs on the machine rather slow. The CPU would execute the GPL interpreter. The GPL interpreter would run the BASIC interpreter. Finally, the BASIC interpreter would run your program. Only the TMS9900 code is statically recompiled in this program. The GPL still runs interpreted just as it did on the original machine. While it would theoretically be possible to statically recompile the GPL code as well this would be significantly more difficult since GPL was never officially documented by TI. The only definitive reference is the original interpreter.
  • C64 BASIC outputs characters to the screen via one function (CHROUT) which was easy to trap. TI-99/4A BASIC outputs to the screen with direct writes to video memory from multiple different places in the code. This requires some ugly hacks to get anything approximating reasonable on stdout.

Limitations

The Cassette, Disk, and Sound devices are not currently emulated. Contributions in these areas are most welcome.

Links