The Game Controller Port, Deconstructed
A couple of weekends ago I found myself in conversation with Jon, my brother-in-law, a vintage game systems collector and proud owner of an Action 52 cartridge, about NES controllers—specifically, how all eight buttons can be crammed down only seven controller pins (a trivial setup would require nine). I just happened to know most of the mechanism already and gave him the surprisingly simple rundown. I got curious about the parts I didn’t know, so here’s a digest of my research.
Each part below has a summary at the beginning; skip the rest unless the specific implementation details interest you.
The Extremely Simple: Atari (and Commodore)
- Number of pins on connector: 9 (DE-9 female)
- Number of switches to encode: 5 (up, down, left, right, fire)
- Mapping strategy: One-to-one (one pin per button)
- Reading strategy: Continuity test using common ground
- Number of pins used:6 = 5 (one per button) + 1 (ground) (not counting analog lines)
Atari and Commodore used exactly the same mechanism with the same pinout, so an Atari controller is effectively a Commodore controller as well, and vice versa.
The Atari joystick uses a standard DE-9 connector. It needs only five signal lines—up, down, left, right, and fire. Since the DE-9 has (naturally) 9 pins, there’s room for a pin for each, and one for ground (six total). No positive supply is necessary because there are no actual electronics involved in switches that are pulled to ground.
Paddle controllers
- Analog inputs to encode: 2 (potentiometers)
- Mapping strategy: One-to-one
- Reading strategy: RC timing network (a primitive ohmmeter and ADC)
- Number of pins used: 3 = 2 (one per potentiometer) + 1 (5V for RC charging)
- Total number of pins used on connector: 9 = 6 digital + 3 analog
For the analog paddle controllers (think Pong), those leftover three pins are used instead. One pin brings in a positive supply of 5V, and the remaining two are analog inputs for potentiometers (the knobs on the paddles)—two to a plug. The guts of the game system use a sort of cheap ADC to read the analog lines: The potentiometer provides the resistance in an RC network, so the paddle is queried by discharging a capacitor and measuring the time it takes to recharge; higher resistance means a slower charge. It’s not extremely fast (relative to other electronics), but it’s really cheap and it’s more than adequate for a game controller. The fire buttons on each paddle trigger the same lines as the regular joystick’s left and right.
The analog lines are not connected on the digital joystick.
Sources: pinouts.ru, Atari 2600 service manual
The Leery Step Forward: Sega Master System
- Number of pins on connector: 9 (DE-9 female)
- Number of switches to encode: 6 (up, down, left, right, I, II)
- Mapping strategy: One-to-one
- Reading strategy: Continuity test using common ground
- Number of pins used: 7 = 6 (up, down, left, right, I, II) + 1 (ground)
The Sega Master System also uses a DE-9 connector. The pinout seems to have been contrived such that, as long as the game only uses button I, an Atari joystick will do just fine! No doubt this was a ploy to capitalize on the existing peripherals market (see Atari and Commodore above), though this would require cooperation from game software; specifically, button II would have to be optional for gameplay.
A dedicated SMS controller would add button II, its signal on pin 9. This is one of the Atari analog pins; SMS and Genesis did not implement analog support.
More Buttons: Sega Genesis (Mega Drive)
- Number of pins on connector: 9 (DE-9 female)
- Number of switches to encode: 8 (up, down, left, right, start, A, B, C)
- Mapping strategy: 2-to-1 multiplexing (one could call it “paging” or “bank switching” here); the system chooses one of up to two meanings each data pin can have at any one time (e.g. buttons A and B share a pin)
- Reading strategy: 74HC logic input, read after page is selected
- Number of pins used: 9 = 2 (ground, 5V) + 1 (select/address) + 6 (up, down, left, right, A/B, start/C)
On the Genesis, there would be just enough pins to encode all 8 buttons one-to-one, but someone must have been simultaneously worried about backward compatibility and future-proofing. Its solution is a 74HC157, a 2-to-1 multiplexer, which is used to allow either of two signals to be read from the same line, depending on the state of a “select” (address) pin. When the select line is low, pins 6 and 9 reflect A and start, respectively. When it’s high, the same pins reflect B and C. The positive supply, which is now necessary due to the multiplexer chip, is on pin 5. This is not where an Atari paddle expects the supply, but an Atari joystick will ignore the pin entirely.
Other than some button renaming and the addition of the select line, the pinout is similar to the SMS. If an SMS controller is used on a Genesis, it would appear that pressing button I would look like pressing both A and B, and pressing button II would look like pressing start and C.
Source: gamesx.com
Even more buttons: Sega six-button
- Number of pins on connector: 9 (DE-9 female)
- Number of switches to encode: 11 (up, down, left, right, start, A, B, C, X, Y, Z)
- Mapping strategy: 3-1 paging: Same as the 2-1 on the Genesis controller, plus a special escape signal on the select line to access a third page
- Reading strategy: 74HC logic input, read after page is selected
- Number of pins used: 9 = 2 (ground, 5V) + 1 (select/address) + 6 (up/Z, down/Y, left/X, right, A/B, start/C)
The 6-button pad for the Genesis, was also backward compatible and expanded on the selection scheme from the 3-button pad. With no room left on the connector (as well as no desire to mess with the motherboard of a platform that has already shipped), a second select bit could not be added.
Instead, the controller has three pages (one more the normal controller), and they are accessed thus: The first two pages are the normal ones and accessed in the same way, by setting the select line to either high or low. The third page is accessed by sending a special attention signal on the select line, a rapid series of three low pulses, which is not likely to show up by accident (i.e. in a game that doesn’t support the extra buttons). Pulses wider than a certain limit are treated as their normal commands.
Outside the context of the six-button controller it’s theoretically possible, if not frequent, for a non-supporting game to pulse the select line in such a way as to throw it to its third page, causing erratic behavior. The creators of the controller covered this by adding a “mode” button. This button manually disables recognition of the third-page signal, de-evolving the controller to a normal 3-button. I had always wondered what the mode button was for, because I don’t recall ever having used it—the backward compatibility just works the vast majority of the time.
The additional logic required to handle the third-page signal apparently made this controller more cost-effective when made with a custom microcontroller instead of cheap, off-the-shelf gates like the 74HC157. Unfortunately, such a design decision makes it harder for the casual hobbyist to figure out what’s going on in the circuit. The writeup referenced below was possible largely due to the author’s possession of an oscilloscope.
Source: writeup on the Sega 6-button
Fewer pins, major expandability: Nintendo (gamepad)
- Number of pins on connector: 7 (proprietary female)
- Number of switches to encode: 8 (up, down, left, right, select, start, A, B)
- Mapping strategy: 1 serial data pin for all buttons (normally)
- Reading strategy: 74HC logic input, read from a parallel-in shift register latched and clocked by the system
- Number of pins used: 5 (normally) (5V, ground, clock, latch, data)
By comparison with Sega, Nintendo didn’t seem to be too concerned with backward compatibility. They instead used a design that helps to minimize the number of wires going between the controller and the system: Synchronous serial communication. The communication itself is based on the CD4021 parallel-load shift register, a cheap off-the-shelf IC. The system doesn’t test the switches on the controller directly; it simply commands the controller to do it and then send up the results. Apart from ground and supply, the design uses only three lines:
- The system uses the latch line, called OUT 0 on the Famicom schematic, to tell the controller to take a new sample. The onboard 4021 reads and stores the current values of the buttons.
- The system uses the clock line, called CUP (“clock up”, perhaps?) on the Famicom schematic, to tell the controller to send the next bit. The onboard 4021 sends the next bit in line.
- The controller uses the data line, called D1 on the Famicom schematic, to tell the system the value of a bit it has read.
The read could go something like this:
- Raise CUP (if not already raised).
- Raise OUT 0. The controller takes a sample. Lower OUT 0.
- Lower CUP. Get bit on D1.
- Raise CUP. The register is shifted.
- Repeat the last two steps through 8 bit reads.
This scheme of communication is common to parallel-in shift registers; with minor changes, a 74HC165 could be used instead. (So could a microcontroller, but that’s more or less true for all of these controllers.)
4-player taps
- Number of switches to encode: 32 = 16 per controller port × 2 ports = 8 per controller × 4 controllers
- Mapping strategy: 1 serial data pin for all buttons
- Reading strategy: 74HC logic input, read from a parallel-in shift register latched and clocked by the system
- Number of pins used: 5 (normally) (5V, ground, clock, latch, data)
The Four Score and other similar 4-player taps have a protocol that really demonstrates the extensibility of the basic clock-latch-data methodology. Each controller port on the NES handles two controllers for a total for four. It works exactly like a normal gamepad except that, instead of 8 data bits, there are 24: 8 for player 1 (port 1) or 2 (port 2), 8 for player 3 (port 1) or 4 (port 2), and 8 bits of metadata from the adapter itself. I haven’t seen a schematic to know the guts, but in my opinion the easiest way to implement this would be to latch both controllers on the latch signal, then multiplex the clock and data lines: Clock and data signals go to the first controller until 8 pulses have passed on clock, then go to the second controller for the next 8, and finally go to whatever is supplying that last 8 bits of metadata.
Exotic controllers
The gamepad as described above uses only one data line, D1, but there are two others, D3 and D4 (I’m not sure why “D2” got skipped). All three lines are electrically identical according to the Famicom schematic. As it turns out, D3 and D4 are used in non-traditional game controllers; i.e. stuff that doesn’t look or act like a plain gamepad. It also appears that in most cases, normal and special are mutually exclusive: A controller will use D1 for data, or it will use D3 and D4 for data, but never both. There doesn’t seem to be anything preventing their use together, and I imagine the habit of not doing so was to prevent a special controller being erroneously detected as a gamepad.
Zapper
- Number of inputs to encode: 2 (trigger, light sensor)
- Mapping strategy: One-to-one
- Reading strategy: 74HC logic input, asynchronous
- Number of pins used: 4 = 2 (5V, ground) + 2 (trigger, light sensor)
The Zapper, from an interface perspective, is a lot simpler than a normal gamepad. It has two digital outputs, and they are both direct rather than being serialized. When the trigger is pressed, D4 is pulled low. When the light sensor detects dark rather than light, D3 is pulled low.
As you may or may not know, games that use the Zapper work thus: When a trigger pull is detected, the system turns the whole screen black except for a white square marking the target, then takes a reading from the light sensor. If the sensor reads dark, it’s a miss; otherwise, it’s a hit. (This is why aiming the gun at a light rather than the screen sometimes works.) If there are multiple targets, they are checked one at a time. In games with a lot of targets, like Hogan’s Alley, the target check causes a noticeably longer flicker.
Power Pad
- Number of switches to encode: 12
- Mapping strategy: 2 serial data pins, one for 8 switches and the other for 4
- Reading strategy: 74HC logic input, read simultaneously from two parallel-in shift registers latched and clocked by the system
- Number of pins used: 6 (5V, ground, clock, latch, 2 data lines)
The Power Pad uses a very similar scheme to the gamepad, except that two shift registers are run side-by-side (not chained) and the data comes out on D3 and D4. The register on D3 handles 8 switches; the register on D4 handles the last 4 (padding its output with zeros). The clock and latch signals are the same as with the gamepad.
Arkanoid paddle (from remake schematic)
- Number of switches to encode: 1 (fire/start)
- Number of analog inputs: 1 (potentiometer)
- Mapping strategy: Fire button direct, analog control as 8 bits of serial data (ADC on the controller itself)
- Reading strategy: 74HC logic input, asynchronous (fire)/read from a parallel-in shift register latched and clocked by the system (potentiometer)
- Number of pins used: 6 (5V, ground, clock, latch, fire, analog data)
The paddle controller for the game Arkanoid, from what I’ve read, is something of a rarity, but as the NES goes there aren’t a lot of examples of analog controllers. The paddle controller has a start/fire button that pulls down D3. The schematic of an attempted remake suggests that the analog-digital conversion is done on the controller itself (compare the Atari paddle controllers, which connect to a simple ADC in the computer itself) using an 8-bit ADC. The output of the ADC is loaded up into a shift register and clocked out on D4 using the normal clock and latch lines.
Arkanoid paddle: Eight register lines come from an ADC. They’re clocked similarly to the normal gamepad, but the data comes out on D4 instead of D1. The start/fire button pulls down D3. D1 is left disconnected.
Sources: Nearly all of the Parodius page on NES dev, a Chilean remake of the Arkanoid paddle
Omissions
- The Commodore proportional mouse, an intriguing abuse of the analog lines
- PC joy/MIDI port, which is way heavier on the analog than these systems
- PlayStation controller port, which is shift-register-based much like the NES [Edit: Added in this later post]
- SNES, whose port is electrically the same as the NES port (5V, ground, clock, latch, three data lines) but whose controller chains two 8-bit shift registers chained in series as a 16-bit to accommodate the 4 new buttons.
- Anything recent, including USB, since technological advances have led to higher complexity, with most tasks handled by microcontroller instead of discrete logic
- Power Glove, because (a) it’s so bad, (b) I wasn’t able to quickly locate any implementation data.
- R.O.B., because it doesn’t actually plug into the system—it receives commands encoded into a flickering screen.
- Who knows what else…