In a previous article, I wrote about my experience revisiting the first computer brought into my home back in my youth – the Texas Instruments TI-99/4A. In that piece, I mentioned that I recently made a custom joystick adapter for my TI-99/4A so I could play games with an Atari joystick. In this article, I’m going to dig more into that experience and walk through my moments of discovery.
Two Joysticks, One Port
I don’t remember ever having a joystick with my TI-99/4A. On the outside, they’re similar to other single-button joysticks of the era – a single stick protruding from the top, with a single button you can smash to fire your weapon at oncoming enemy spacecraft and alien hordes.
One thing that makes these joysticks unique, however, is that there’s two of them … but only one joystick port on the computer. Texas Instruments provided a 2-player experience by wiring two separate joysticks into this one port. In order for that to work, that means that both joysticks are sharing some of the same pins.
Having two joysticks was a great idea. I, for one, would’ve loved playing two player games with my friends, had I owned a pair of these joysticks. The Commodore VIC-20 (which was the TI-99/4A’s main competitor at the time) also only had one joystick port, but it didn’t have a “2-in-1” style joystick like the TI-99/4A had.
The one major advantage of the VIC-20’s joystick design, however, was that Commodore made the wise decision to use the same joystick pin wiring that Atari used in the Atari VCS/2600. At the time the TI-99/4A was released (1981), the Atari VCS had been around for a few years and had sold over 3.5 million units. This meant that many families already had VIC-20 compatible joysticks in their homes.
On the other hand, Texas Instruments chose a different wiring configuration for the TI-99/4A joysticks. The joysticks effectively functioned the same – pushing the button or tilting the stick closes a mechanical switch, which signals to the system that a button was pressed. But the main difference was that the pins for each of the buttons were different. Here’s a diagram for side-by-side comparison:
When I first decided to take on the task of building an Atari adapter, I thought this would be a simple pin-remapping exercise. And in some respects, it was. But as you’ll see when you read further, having multiple joysticks connected to a single port complicated things a bit. To add to that, there’s conflicting information going around the TI community around the proper design of these adapters. Because of that, much of my research involved understanding the impact of the different circuit designs that have been floating around and determining which one is the right approach.
I’m Not the First
Before I jump in, I just want to say that I’m by far not the first person to have done this. Not only are there modern designs for these adapters, but 3rd parties also made and sold Atari-to-TI99/4A joystick adapters back in the 1980s. These, of course, are no longer being made, but you can order a modern variation if you don’t want to build your own. Here are a couple of different options that I found, which won’t cause you to rob the piggy bank:
- If you want a pre-assembled adapter that you can just plug in and use right now, check out the TexElec joystick adapter, which is only $15. There’s even a 3D-printed case that you can get for another $20.
- If you want a simple, single-player adapter board and don’t mind assembling it yourself, you can order this PCB and solder on your own DB9 connectors.
I very well could’ve purchased one of these. However, since I already had all the necessary parts on hand, I decided to build instead of buy this time around.
If I wanted to only use one joystick, then the design of this adapter would be a straight-forward pin remapping. In that case, the pins on the Atari joystick would just need to be connected to the correct pins on the TI-99/4A joystick port, which doesn’t happen in the default pin layout. In fact, this is what I found many people online doing.
Of course, if you want two joysticks for a multiplayer game, there’s a little more to it. The diagram below is from the August 1983 edition of COMPUTE! Magazine (issue #39). Here, a reader named Gary Cook wrote in and shared the following diagram with fellow TI-99/4A enthusiasts.
You’ll notice in Gary’s diagram that the TI-99/4A joystick port has pins identified for the player 1 and player 2 joysticks, which are labeled “STICK A GND” (pin 7) and “STICK B GND” (pin 2). Those are wired up to the Common pin on their respective Atari joystick. As you can see, the editors stated that they “built it here and it worked perfectly”. However, if they had played certain games with this adapter, they would’ve been in for a surprise.
If you spend some time reading through the discussions in the TI-99/4A communities, you’ll see that some people have suggested adding diodes into this diagram. Still, there are folks that say they aren’t necessary. And to add to the confusion, the adapters all seem to be working fine with or without diodes. So, which is it?
The Diode Dilemma
Diodes are one-way electrical gates; they allow current to flow in one direction, but block current from flowing in the opposite direction. Often, they’re used to protect components in a circuit when there’s a possibility of current traveling back into a component and damaging it.
I wanted to solve this mystery and come to a solid understanding of whether or not diodes were really needed in the joystick adapter, and what the implications were if they weren’t included. To go there, I needed to better understand how joystick input actually works in the TI-99/4A.
I discovered that at a high-level, it’s rather simple. When the button is pressed or stick tilted, a mechanical switch is closed. This completes a circuit between a common wire and the wire connected to the switch. This, in turn, signals the joystick event to the computer. But as with anything, when you start digging, you find that things are bit more complicated than that. So, I went on an expedition.
Low-Level Joystick Operation
I spent some time becoming familiar with the various TI-99/4A schematics that I unearthed online. The schematic below is from the TI-99/4A Peripheral Expansion Technical Reference document. The joystick port and keyboard connector pins are drawn on the right-side of the diagram. The keyboard, which is represented by the 15 pins in the lower right, is actually a matrix of 6 columns x 8 rows. To detect a key press, each column is continuously scanned for a connection with one of the rows.
Notice that five of the wires in the joystick port are tied into five of the rows of the keyboard (1, 2, 4, 5, and 7). These five wires are connected to each of the mechanical switches in the joystick (Up, Down, Left, Right, and Fire). And since both joysticks use the same joystick port, these joystick wires are shared between both the player 1 and player 2 joysticks.
To detect whether a keyboard or joystick switch is closed, each of the 8 keyboard rows (plus one more row for the Alpha Lock button) is connected to a different input pin on the TMS9901 system interface chip inside the computer. In the schematic snippet below, the TMS9901 is the chip on the left of the diagram, and the input pins are labelled (INT6 – INT10). The joysticks use only five of these pins; INT3 – INT7.
When none of the joystick switches are closed (the stick is centered and the fire button is not pressed), the interrupt pins on the TMS9901 are pulled up to 5v, as I’ve labeled in the below diagram. These interrupts are active low, as described in this TMS9901 technical document from 1978. So, while the signal is pulled high, nothing happens. However, when the input transitions to a logic low, the interrupt is triggered.
This transition from high to low occurs when a joystick switch is closed. Remember what I mentioned earlier, though – the switches on both joysticks share the same wires, which connect to the same interrupts. So how does the computer know which joystick triggered the interrupt?
To solve this mystery, take another look at the joystick port in the schematic below. There are two pins at the top, labeled pin 7 and pin 2. Each of these pins are connected to a different joystick – pin 7 for player 1 and pin 2 for player 2. These serve as each joystick’s “common pin”. Notice that each pin is connected to the emitter of a transistor (labelled Q300 and Q301). These transistors will either put a high or low signal on pins 7 and 2, depending on the signal entering the transistors’ base pin.
This is where things get a little more complicated. There’s a 74LS138 decoder chip (far left in the below diagram) connected to the base of each transistor. This chip is what “polls” each of the joysticks. Ordinarily, this chip is putting a high signal into the transistor base pin, which opens the gate and results in the joystick common pin getting set to high.
However, many times per second, this chip pulls down the base of each joystick transistor (one at a time, never both at the same time), and that puts a low signal on the joystick common pin. If that transistor is outputting low at the same time that the user presses fire or moves the stick, then the common pin is connected to the switch that was closed in the joystick, and the signal going into the interrupt pin on the TMS9901 sinks goes back through the joystick and into the -5v rail. The red arrow in the diagram below illustrates this process.
As a result, the input pins on the TMS9901 will transition to low and this triggers the interrupt. To determine which joystick triggered it, the CPU just needs to check which joystick was being pulsed low by the 74LS138 at the time.
So, What About Diodes?
Everything may sound good so far, however, there’s a problem. If both players press the same joystick button at the same time, the joystick being polled will sink the TMS9901 pull-up, while the other joystick continues to put a high signal on the line! This effectively cancels out the player’s button press. This is why I stated earlier that the editors of COMPUTE! magazine would’ve been in for a surprise if they played certain games. In particular, if they played any simultaneous (non-turn-based) two-player games, they would’ve discovered the flaw in Gary’s design.
By using diodes on each joystick, you can prevent the signal from the transistor’s emitter from leaking back into the TMS9901 interrupt pins.
So why are people saying that their joystick adapters work fine without diodes? The simple answer is that they’re not playing any games that require both joysticks to be used simultaneously! Many of the TI-99/4A games are turn-based, and you’re simply not going to encounter this situation with those games unless your opponent is pressing buttons when it’s not his turn. I’m not sure how many there are, but the one game that I own which is two-player simultaneous is Indoor Soccer. And honestly, there’s a good reason why a lot of people don’t own this game.
Where to Place the Diodes
There’s one more question left to answer. One thing I was a little baffled about was why all the designs I found online all place diodes on each of the switch lines (5 diodes per joystick, for a total of 10), instead of just placing 1 diode on each of the joystick common pins. Since the sink source is coming from the same common pin for all joystick switches, it would make sense to just place a diode there.
I knew I was missing something, so I used simulation software to mockup a test circuit with two joysticks with two buttons each. I simulated the joystick polling event by manually closing a switch to ground. The software I used doesn’t have a TMS9901 simulator, so I used an Arduino simulator to validate the inputs by running some serial output code to display the status of the test pins (pins 8 and 9 on the Arduino in the following schematic).
To start with, I turned off polling on both joysticks, and kept the buttons open, simulating the scenario of no joystick button being pressed. The result was what I expected – a logic high on the input pins for both buttons. This is indicated by the serial console at the bottom left reporting back two 1s. The leftmost digit is the logic level on pin 8 and the rightmost digit is for pin 7.
For my first test, I added one diode to each joystick at the common pin (marked with the blue arrows below). I then activated polling on joystick 1, and simulated a button press on both joysticks at the same time. As you can see in the following results, the diode for joystick 2 prevents the current leakage from the common pin, and the serial monitor shows a logic low on pin 8. This validated that the diode ensures both joysticks don’t interfere with one another.
And then I spotted the issue. With one button pressed, everything works fine. However, I realized that if I pressed both buttons on both joysticks at the same time, a short is created! I ran this scenario in the simulation, and sure enough that’s what happened:
When I realized this, it became clear that the diodes needed to be placed on each of the switch wires, to prevent a short from occurring in the scenario where each joystick is closing two or more of the same switches at the same time. I think this is very likely in an asynchronous two-player game, where each player might be pressing Up and Fire at the same, for example.
I updated the test circuit with diodes on each of the switch wires, and re-ran the simulation with the same two-button scenario. That solved both the joystick interference problem, as well as the shorting issue. You can see in the serial console output that both pins are reporting a 0, which is a logic low.
The Diode Conclusion
I know it was a bit technical, but if you followed along with my analysis, you would see that all 10 diodes are necessary for two reasons. First, to prevent the joysticks from interfering with each other’s button presses. And second, to prevent a short circuit in the scenario that both joysticks are pressing two or more of the same buttons at the same time.
With that said, here’s the final schematic of the joystick adapter:
Getting Some Boards Made
Once everything was tested and working, I drafted a board in KiCad and put in an order from JLCPCB. As is usually the case, I only needed one board, but the minimum order quantity is 5, so there are a few extras left over. A few days later, the boards arrived in the mail. Assembly only took a few minutes, as the only components are 10 diodes and 3 through-hole DE9 connectors.
I didn’t spend much time designing a well-thought-out PCB, so the board is a bit bulkier than it needs to be. If I had put some more thought into it, I would have trimmed it down a bit and designed a nice 3D-printed case for it. However, it works well, and I’ve been getting lots of use out of it.
Overall, building an Atari-style joystick adapter for the TI-99/4A is a small and easy project that anyone can do in an afternoon. Throughout this article, I explained how these adapters work and examined why diodes are important to include in the right places. I also sketched out a rough PCB layout, purchased some boards, and did a quick assembly.
Perhaps at some point, I’ll revisit the design and make a smaller and less obtrusive board that’s properly enclosed. For now, though, I’ll enjoy exploding the oncoming alien horde in TI Invaders with my modern, after-market Atari-style joystick.