Sega Mega Drive to Atari/Kempston adapter

Converter for Sega Mega Drive controller to the 9-pin joystick standard using a Microchip microcontroller. Origina project by Eyvind Bernhardsen.
This adapter is compatible with most computers that use the Atari 9-pin joystick connector, supporting most of the features of Sega Mega Drive controllers, which use the same connector with a slightly different pinout. The Mega Drive was known as Genesis in the US.

Features of this adapter

The adapter uses a microcontroller to convert Mega Drive controller signals and map its four buttons to the three inputs available on an 8-bit Atari.
The B button on the controller is mapped to the normal joystick button. Buttons A and C are connected to pins 5 and 9 on the joystick port; these can be read as extra joystick buttons by the computer. Most games that only support one extra button use the C button (pin 9).
“A is Up” toggle
The start button has no natural mapping since the Atari can only read three buttons, but a common complaint in platform games on the Atari (and later the Amiga) was that they often used joystick Up to jump because of the lack of extra joystick buttons.
A dedicated Up button would solve this problem, but the Start button is not usually in a good location to be used as a jump button. The adapter therefore supports this feature indirectly: holding the Start button down for a second maps the A button to Up.
Since the joystick button often starts games, a short press of the Start button is mapped to joystick button 1. This allows Start to both serve its normal function (in supported games) and switch the A button between modes.
Autodetection (Atari 8-bit machines only)
Because of the way the paddle circuits are used to read the second and third button inputs, 8-bit Atari read an unconnected second or third button input as if the button is being held down.
This allows games running on the computer to detect the presence of a multibutton controller by assuming that a button does not exist until it has been seen to be released. The adapter supports this autodetection by leaving its button outputs open unless a Mega Drive controller is detected or the corresponding button input is pulled low.
To activate the second button when a Mega Drive controller is not connected, pin 9 on the controller input must be pulled low before the adapter starts driving the second button output. This means that the second button must be pressed once before it can be detected by the computer.
The third button output is open unless a Mega Drive controller is detected since there is no other source for a third button input.

Computer compatibility

-8-bit Atari computers
-8-bit Commodore computers
The C64, C128, and VIC-20 can also read the second and third buttons. The extra buttons on these machines are active high, which is opposite to Atari and Sega.

Pulling the C64 switch inverts the outputs for the extra buttons, allowing them to be read correctly by the 8-bit Commodores.
Turn switch to C64. Because the joystick inputs of the 8-bit Commodores are somewhat
sensitive, all of the pins are normally open (floating). The extra button pins are pulled high when active, all other signals are pulled low when active.

-Amiga
Unlike the 8-bit Commodores the extra buttons on the Amiga are active low, and unlike all the 8-bit computers they are digital inputs instead of repurposed paddle circuits. The Atari mode supports both Atari and Amiga by driving the pins for buttons two and three both high and low.

-Atari ST (untested)
Button two registers as the second mouse button / port 1 joystick button if the adapter is plugged into port 0. The ST does not support additional joystick buttons on port 1.

Controller compatibility

-Sega controllers

The adapter is compatible with three- and six-button Mega Drive controllers. On six-button controllers, buttons X, Y, and Z act as autofire versions of A, B, and C.

Sega Master System controllers are theoretically supported, including the second button, but this is untested.

-8BitDo Retro Receiver

The adapter is extensively tested with the 8BitDo Retro Receiver for SEGA. It’s
a nifty way to use wireless controllers on old hardware.

Other joysticks or controllers

Don`t use this adapter with other joystick it may damage your computer or the
adapter.

Atari 7800 controller, Commodore multi-button joysticks, paddles, steering wheels, etc.

These devices will not work and should not be plugged in to the adapter.