Gamepad ProtocolRecall the gamepad pinout ( Pinouts ), the Genesis / Megadrive gamepads (3 button and 6 button) use a standard DB-9 connector. Looking into the connector, the signals are as follows:
Gamepad VoltageThe 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 GamepadThe 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.
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. The 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:
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. |






