Joypad

Joypad Protocol

GenesisJoypadConnectorThe Genesis / Megadrive gamepads (3 button and 6 button) use a standard DB-9 connector. Looking into the connector, the signals are as follows:

Pin #Signal Name
1D0
2D1
3D2
4D3
5+5V
6D4
7Select (TH)
8GND
9D5

Joypad Voltage

The Sega Genesis / Megadrive outputs a 5V supply to the gamepads. During all my testing, I used 3.3V since this is much more common nowadays. I did not encounter any issues at all using a lower supply voltage.

3 Button Joypad

Sega-Genesis-3Button-JoypadThe 3 Button controller is quite simple to interface to. It requires a Master to toggle the Select line to read all 8 buttons from the 6 data lines. Sega did it this way because, with Select = 5V, the Genesis 3 button gamepad behaves just like a Master System gamepad; therefore maintaining backwards compatibility. The Select line usually idles in the High state.
All gamepad signals are active low, pressed = 0, released = 1. Because it is unlikely that both Left and Right will be pressed at the same time, this state can be used to automatically differentiate a Master System gamepad from a Genesis gamepad.
SignalSelect = 5VSelect = 0V
D0UpUp
D1DownDown
D2Left0
D3Right0
D4BA
D5CStart

The timing to read the gamepad is controlled by the software and is highly variable from game to game. Good practice would be to read the gamepad at every VBLANK – 60 times per second for NTSC and 50 times per second for PAL. The Select signal goes to a 74HC157, refer to its datasheet for specific timing.

6 Button Joypad

Sega-Genesis-6Button-JoypadThe 6 Button gamepad is more complex since Sega engineered it to behave like a 3 Button gamepad (to some extent) for existing software. The 6 Button gamepad adds 4 buttons, X Y Z and Mode. With this controller, the Select signal must be cycled a few times to get the additional button data out of the controller. Typically, a game reading a 6 Button gamepad will do the following:

 

Cycle # 0 1 2 3 4 5 6 7
Signal Select = 5V Select = 0V Select = 5V Select = 0V Select = 5V Select = 0V Select = 5V Select = 0V
D0 Up Up Up Up Up 0 Z
D1 Down Down Down Down Down 0 X
D2 Left 0 Left 0 Left 0 Y
D3 Right 0 Right 0 Right 0 Mode
D4 B A B A B A B A
D5 C Start C Start C Start C Start
To get the extra data from the additional 4 buttons, the Master must cycle the select line from High to Low a total of 3 times. On the third time the Select line is low, the 6 Button controller identifies itself by driving low D0 to D3 which would be an EXTREMELY unlikely state (considering the player would have to press Up Down Left Right all at the same time. Immediately after this, on the third rising edge of Select, the 6 Button controller outputs the additional 4 Button. Most games cycle select one more time, for a total of four, presumably to reset a the 6 Button controller. When everything is done, games idle the Select line in the High state.
The 6 Button gamepad appears to reset itself back to cycle 0 if the game softare doesn’t go through with all of the cycles (such as only attempting to read a 3 Button gamepad). Therefore, you have to cycle through the above states quickly enough to avoid this internal reset. I measured a period of approximately 27us on the Select signal for a 6 button game, but I did not test how long this can be be before an internal reset occurs in the state machine of the 6 Button gamepad. Again, the gamepad should be read at every VBLANK – 60 times per second for NTSC and 50 times per second for PAL.