I/O port pinout

Mega Drive I/O port pinout

The port takes DE-9 shaped connectors. The numbering (looking at the port) is (top row) 1, 2, 3, 4, 5, (bottom row) 6, 7, 8, 9. The pin assignment is: 1: data0, 2: data1, 3: data2, 4: data3, 5: VCC, 6: TL, 7: TH, 8: ground, 9: TR.

Master System peripherals use the same pinout, so you can plug them as-is and use them in your homebrew. Take into mind that often they aren't easy to automatically detect (when it's even possible), so consider supporting a Mega Drive counterpart when possible.

A lot of older systems (mostly computers) used joysticks over DE-9 ports. The pinout is usually not compatible with those, and you should look into an adapter to make sure you don't fry anything (in particular, the pins for VCC and GND are all over the place).

Saturn I/O port pinout

The Saturn I/O ports lay out 9 connections in a row (on the lower side for the port, on the upper side for the plug). Pins are numbered 1 to 9 from left to right (looking at the port). Pin assignments: 1: VCC, 2: data1, 3: data0, 4: TH, 5: TR, 6: TL, 7: data3, 8: data2, 9: ground.

Saturn's I/O ports have the same lines as the Mega Drive ones, but the plugs have a different shape. You can make a passive adapter that simply rewires the connections in order to use Saturn peripherals in your Mega Drive homebrew (and vice versa). Note that Mega Drive and Saturn peripherals are not compatible with each other and you have to explicitly include code to handle them.

A lot of sites seem to give the pins names based on their use with a Saturn controller rather than their I/O names, the following table indicates the corresponding names (note that +5V refers to the TL pin which is held high, not the actual power line):

Common nameMega Drive style name