We love retro computing. Especially the Commodore Amiga is great device with lots of games. Each of them can be enjoyed on an emulator, but I prefer real hardware. Unfortunatly, 30 years old joysticks tend to malfunction. Furthermore, it is more comfortable to use a gamepad. Therefore, I was searching for a new gamepad which can be connected to my Amiga. I had something in mind like a CD32 gamepad replica but did not find anything comparable. Instead, I saw lots of new Sega Genesis gamepads on popular online market places and bought one of them. It did not work as expected and I had to build a programmable Arduino based adapter (with some nice additional features:). The results are described in this blog post.
Sega Genesis gamepads and Commodore Amigas game ports use DE-9 connectors. Furtheremore, they are almost pin compatible. I did not dive deeper into the schematics, simply trusted this information and plugged my new Genesis controller into my Amiga. Later, I found out this is rather carelessly because a C64 (which is also almost pin compatible;) could have been damaged. My Amiga seemed ok but the gamepad did not work properly. It was possible to play games but after seconds or minutes buttons like "Up" or "Down" stopped working. Therefore, it was necessary to verify the Genesis and Amiga pin layouts. A good description can be found in the Amiga Hardware Reference Manual and this blog entry. Results look like this:
|Pin||Sega Gamepad Select=HIGH||Sega Gamepad Select=LOW||Amiga Joystick Port|
|1||Up (OUT)||-||Up (IN)|
|2||Down (OUT)||-||Down (IN)|
|3||Left (OUT)||Gnd||Left (IN)|
|4||Right (OUT)||Gnd||Right (IN)|
|5||+5V (IN)||+5V (IN)||-|
|6||B (OUT)||A (OUT)||Button-1 (IN)|
|7||Select Signal (IN)||Select Signal (IN)||+5V (OUT)|
|9||C (OUT)||Start (OUT)||Button-2 (IN)|
Sega Genesis Gamepad: Classic Genesis controllers come with three fire buttons (A, B, C), Start and a four directional D-pad. Including Vcc and Gnd, 10 pins would have been necessary. To overcome this problem, Sega added a Select signal and a multiplexer. Depending on the Select state (High or Low), certain gamepad elements write their output to the corresponding output pins. Left and Right are pulled to Ground when Select is set to low. This allows a console to verify whether a gamepad is connected because a user could not press left and right simultaneously. Sega also produced gamepads with six fire buttons. In this case, the controller contains a state machine which is controlled by the select signal as well. Again, read here for details.
Amiga Joystick Port: Compared to the Genesis, Amiga Joysticks are simple. Left, right, up, down and one or two fire buttons are directly connected to the game port pins. One important aspect is the direction: Software can configure whether pin 5, 6 and 9 are input or output signals. A classic joystick needs a game port with input pins only. More complex devices like CD32 gamepads (which are not in the scope of this article) contain a shift register and the Amiga has to output some kind of clock signal for controlling them.
My Sega gamepad replica is a six button device. If you take a look at the table above, this leads to two problems:
Reconsidering my problems from above (up and down did not work anymore after a certain amount of time), the gamepad state machine is not working correctly. Maybe because some games configure pin 5 as an input pin, maybe for some reason I am not aware of. Therefore, I decided to build my own arduino based genesis to amiga adapter. This approach has the following advantages:
The shield sits on top of the Arduino. Two DE-9 connectors are soldered on the shields prototyping area. I have cut two holes in the plastic case and laid the DE-9 connectors into them. Four screws stabilize the whole design. The software is available on Github. I soldered the genesis gamepad pins to A0, A1, A2, A3, A4, A5 and 7 of the Arduino. The Amiga is connected with digital 0, 1, 2, 3, 4, 5 and 6 (besides Vcc and Gnd). Basically, you can chose every programmable Arduino port. I am using the previously described pins because the soldering process was more comfortable this way ;).
My Arduino software has three config options which can be activated during compile time:
My Arduino sketch performs the following algorithm: The Sega gamepad is read 60 times per seconds. This is necessary because an Amiga game checks the joystick buttons 50 times (PAL) or 60 times (NTSC) per second as well. Each iteration, the select signal is used to execute the gamepad statemachine. The results are written to the Amiga game port. I have implemented the following features:
The final result can be seen on the following image. The Genesis to Amiga dapater is on the left side and looks a little bit like the AC adapter on the right: