Game controllers have been around since the beginning of the video game era, starting
with paddles, which were simple controllers for use with games like Pong.
Later on, we got joysticks, and eventually flat game controllers like these.
In this episode, we’re going to take a look at how all of these controllers actually work.
And while it may seem like a no-brainer, the reality is many of these controllers work
on an entirely difference principle.
One of the earliest joysticks was the one used for the Atari 2600.
Atari used a 9-pin connector for both their joysticks and paddles.
The 2600 had two joystick ports.
However, the connector design would go on to be used in a variety of other machines
by Atari such as their 400 and 800 line of home computers, which actually had 4 joystick
ports on the front.
However, Atari would later reduce that number to 2 on the following machines like the 800XL,
and the XE based systems.
Commodore also adopted the Atari joystick style with the introduction of the VIC-20,
which had a single joystick port.
But, they continued with the same port for the Commodore 64, which added a second joystick
port.
Commodore continued to use this port design all the way through the Amiga series.
Many third party joysticks popped up during the 1980s that used this common design.
Electrically speaking, these joysticks are very simple.
The port itself has a ground pin, and a separate pin for up, down, left, and right, along with
the trigger button.
Inside the joystick there are simple a series of switches for each direction.
So, if the user were to move the joystick to the right, for example, it would simply
ground the pin for right, and the computer or game console would know that the joystick
was moved in that direction.
You can see this working by attaching a multi-meter to the joystick and when you move the stick,
you can hear that the connection has been made.
These signals are entirely digital in nature.
Now, what I mean by that is there’s no way for the computer or game console to know how
hard or how far you’re moving the joystick, despite what many enthusiastic kids thought
at the time.
Reading the joystick on a Commodore is as as simple as reading memory address 56320
for joystick port 2.
And you can see, as I move the joystick, the number in this memory location will change.
Now, we’re looking at this in decimal, but if I were to rewrite the program to show you
this in binary, it would look like this.
And so you can see that each direction will control a single bit on that memory address.
Of course, only 5 of the bits of this register are used for the joystick, so, to make it
less confusing, I’ll show it again only using those 5 bits.
However, for games that required that sort of analog precision, there were the paddles.
So, on that same 9 pin connector, there were two more pins for Paddle A and Paddle B, along
with a 5 volt power source.
The power was routed through a potentiometer, and the computer would check the voltage level
to see what position the paddle is in.
You can read a paddle easily by connecting a multi meter.
As I turn the paddle, you will see the resistance value changing on the meter.
The same is true with the computer.
There are two memory addresses on the C64, one for each paddle.
These return an 8-bit value for the position of the paddle.
I can write a similar little program to keep reading the paddle registers and you can see
the number changing.
So in one direction, the paddle should read a zero, and on the opposite extreme it should
be a 255.
The Sega Master system used a very similar design to the Atari and Commodore joystick
system.
And they were even cross-compatible to a certain extent.
The Master System dropped the paddle lines and instead used Pin 9 for an additional button.
The Genesis ended up adding one more button here.
One problem this caused is when people tried to use their Genesis controllers on their
Commodore or Atari systems, the select button is wired up where the +5v would be on those
machines, so when you press it, you are causing a direct short between +5V and Ground, and
it will absolutely fry your machine.
Now, let’s take a look at the joystick port used on MS-DOS machines from the 1980s all
the way through the late 1990s.
These computers used a 15 pin connector, but you might be wondering why they needed so
many pins.
Well, believe it or not this single connector was designed for two joysticks.
So all of the pins up here are for joystick one, and all the pins on the bottom are for
joystick two.
So, if you wanted to use two joysticks at a time, you would need a little Y-splitter
cable like this, which would break out the correct pins for each joystick.
However, this design was advantageous for more advanced joysticks like flight sticks,
for example, because they could take advantage of extra controls which would normally have
been used for the second joystick.
But you may notice I don’t have any pins on this labelled as up, down, left and right.
Instead, there are two buttons, and then two different axis.
So, the way this works is that these Axis controls work pretty much like paddles worked
on the old Atari systems.
These are analog, and thus the computer could sense not only which direction you were moving
the joystick, but also exactly how far you moved it.
This was handy for racing games or flight simulators where you needed more delicate
control.
It would technically be possible, with some hacking, to wire in a joystick like this to
a Commodore 64, since it does have two analog inputs on the joystick port.
So, as usual I wrote a little proof of concept program in BASIC on the C64 and it works fine.
The trouble is, virtually no software would make use of it since all of the software was
designed to work with the standard digital controllers.
OK, now let’s take a look at the controller port on the Nintendo Entertainment System.
You’ll notice there are essentially 8 buttons on the NES controller, so you’d think you
would need at least 9 pins on the controller, right?
Yet, there are only 7 pins.
You get ground, and +5 volts, which is pretty standard.
But then you have clock, latch, and data.
And these are all the pins used by the controller itself.
There are two more pins which are the light sensor and trigger for the zapper gun, but
these pins are not used by the controller.
So how the heck does this clock, latch and data work?
Nintendo took a different approach to their controllers.
They included a standard 4021 8-bit shift register inside each controller.
Between the buttons and the direction pad there are 8 different switches, and each one
is connected to the shift register.
The shift register is then connected to the console through these 3 lines we just discussed.
But how does a shift register work?
Well, let me explain it in a way that will hopefully make sense.
If we look inside the shift register, there are 8 input lines and a buffer on the data
line.
Now, as the user presses buttons on the controller it will pulse on the different input lines,
but the chip will actually ignore all of this until it receives a pulse from the NES console
on the latch line.
When this pulse is received, the shift register will capture the state of the input pins and
place them on the data buffer.
At this point, the data line will be high or low based on what is in bit zero’s position.
So the NES can already read the state of that one.
But how do we get the rest of them?
Well, that’s where the clock like comes in.
The NES will send a pulse on the clock line, and that will cause the shift register to
shift all the bits over by one.
Hence, that is why it is called a shift-register.
The NES will continue to pulse the clock line until all 8 bits have been read.
And so, that’s how that works in a nutshell.
Interesting tidbit is that the Super Nintendo actually works exactly the same way, but it
has more buttons so it uses a larger shift register.
OK, so I want to hook up my Nintendo controller to my Commodore 64, but I’m going to need
to create some kind of adapter.
Now, rather than using the joystick ports, I think the easiest place to hook this up
is actually going to be here in the User port.
Now, in order to kind of create some kind of adapter, I don’t want to have to cut
the end off of my Nintendo controller.
So, what I’m going to do is I’ve got this extension cable that’s male on one end,
female on the other.
What I’m going to do is cut this up.
OK, so I’ll just strip this cable back.
Now, you can see there are exactly 5 wires here.
Which means, this extension cable would not work with the zapper gun.
Regardless, I’m going to need to figure out which wire goes to which pin.
And the way I’ll do that is by using my multi-meter in continuity mode.
Then I’ll just stick one end here in the ground pin to start with and then see which
wire makes it go beep.
OK, there we go.
It appears the white cable is ground.
So I’ll just write this down so I can keep track of it.
OK, so now I’ve got all the different lines sorted out.
And now, I need to figure out what to connect them to.
So, I’ve got these user port things that I put my own labels on.
So, obviously we know where ground can go.
And over here we have a plus 5 volts already on the user port, so we know where that’s
going to go.
But the other three, the clock, data, and latch, we pretty much have to make up ourself
where they’re going to go.
So, I’m going to put them on PB zero, one and two.
Because I can actually control PB zero through PB seven with a single byte register on the
C64.
So, I got busy and started soldering these wires.
Now, I think this goes without saying, but this is just a proof of concept and this will
never work with existing C64 games.
But I just wanted to prove that it could be done.
And so here’s my finished little adapter.
Time to plug it in.
Next I’ll plug in the NES controller to the other side.
And here goes the smoke test to see if I wired something up wrong.
And nothing smoked or otherwise blew up, so I think we’re good there.
OK, in order to demonstrate this, I wrote a little program in BASIC to read the controller
and show on screen which button was pressed.
And because it is in BASIC, it’s a little slow to respond.
But as you can see when I press the A button, the corresponding button lights up on the
test program.
And the B button.
And you can see that all 4 directions are working.
And let’s not forget the start and select buttons.
Oh, and by the way you can press more than one button at a time, and it will still work.
In fact, I’ll try to press all 4 of them here.
Yep..
There we go.
Of course, you can only physically push one of the direction buttons at a time.
The Coleco controllers also did some interesting tricks in order to add the number pad in while
still maintaining the original interface.
Now, all the modern controllers for Playstation and Xbox and PC, they all use USB and they
work on an entirely different principle from all of the controllers I’ve already shown,
but that is a topic for another time.
For those who are interested in downloading the actual BASIC program I used as the example
for the Nintendo and the PC controllers, there is a link down in the description field.
And, so that about wraps it up.
So, as always, thanks for watching!