RC2025 – Part 2 – Designing a PCB for bit-banging a NES controller

In the first part of my RetroChallenge, I ended by saying I was planning to bit-bang the data from the NES controller into my RC2014.

Now it’s time to design a PCB to let me connect the NES controller to the RC2014.

I’m going to use Z80 IO, but I’m not sure what address yet. I’m going to use a 74HCT688 8-bit comparator to allow myself the ability to select a specific IO port on the Z80. I will use a DIP switch with pull-down resistors so I can change the IO port at will without having to get a new PCB made. The /IORQ line from the Z80 will be used to enable the 74HCT688.

I need to send Clock and Latch signals to the NES controller, so I need a way to output data on the Z80 IO port. I will use a 74HCT374 to do this. This will allow me to buffer the data lines from Z80. I will enable output by using a 74HCT02 and NORing the output from the 74HCT688 and the Z80 /WR line.

For reading data back to the Z80, I will use a 74HCT245. This will let me put data onto the databus when the correct IO Port is being read. I will use the 74HCT02 to NOR the output of 74HCT688 and the Z80 /RD line to enable the chip. However, this needs to be inverted to work, so I will just use another NOR gate as a NOT gate to do this.

I will add LEDs on the input and output lines to the NES controller socket to help with any debugging I may need to do. I will also add plenty of test points to see what is going on during debugging. As there are plenty of unused input and output pins, I will expose these on headers for possible future use.

Bit-banging PCB for the NES controller on an RC2014

I have decided to use the following pins to talk to the NES controller.

PINREAD / WRITENES
D0READDATA
D0WRITECLOCK
D1WRITELATCH

Laying out the PCB

I have laid out the PCB using Spencer Owen’s guidelines for RC2014 modules.

The spare output pins have been placed at the top for easy access. The NES controller socket has been placed on the right-hand side, along with the test points for it. The indicator LEDs have been placed above this for visibility.

I have added a ground plane to the back of the PCB, and let EasyEDA handle the routing for me.

PCB layout for the NES controller module

You may have noticed that the diagram is for revision 1.1 of the circuit. 1.0 was essentially the same, but I had the output enable on the 74HCT374 connected to the Z80 /RST line. The idea being I only want this to present data on the bus if the Z80 wasn’t being reset. This pin is only low on reset, so data was never being presented. I just tied this to GND in revision 1.1.

Unfortunately, revision 1.0 is the version I sent off to be manufactured, so it will need a bodge when I come to solder up the PCB. The trace from /RST will need to be cut, and OE will need to be wired to GND.

RC2025 – Part 1 – How does the NES controller send data?

For this year’s RetroChallenge, I am hoping to interface an NES / Famicon controller to my RC2014 computer.

The NES controller has 8 buttons: Up, Down, Left, Right, Select, Start, A, and B.

The cable only has 7 pins, so how can it send up to 8 button presses using 7 wires?

Well, the NES controller only actually uses 5 of those wires. Two of those wires are GND and +5V. The other three are Latch, Clock, and Data.

A diagram of the NES controller port showing pin outs.

Inside the controller, there is a 4021 shift register. When the Latch is pulsed from high to low, the 4021 captures the state of the buttons in 8 bits. The first capture bit will then be placed on the Data line. When Clock is pulsed from high to low, the 4021 will then shift the internal data one place forward, and the next bit will be placed on the Data line. When the next Clock pulse arrives, the next bit is sent, and so on. This needs to happen 8 times until all 8 bits have been sent. A low bit on the Data line means the button has been pressed; otherwise, the bit will remain high.

The bits are sent in the following order.

BitButton
0A
1B
2Select
3Start
4Up
5Down
6Left
7Right

Using software bit-banging, I should be able to send the Latch and Clock signals, and reassemble the received 8 bits back into a single byte.

RC2025 – Taking part in RetroChallenge 2025

After taking part in the very enjoyable RetroChallenge in 2024, I’ve decided to take part again in 2025.

Last year, I worked on a rotary encoder module for the RC2014 computer.

This year, my plan is to interface a classic Nintento Entertainment System joypad to my RC2014.

There is already a module for reading Atari-style joysticks, but I don’t think there is anything for a NES controller.

There are 8 buttons on the NES controller, but the connector has only 7 pins. This means that there is something interesting going on, and it’s not just each button shorting one pin.