FRS' MSX Page

JoyMega Adapter

Using a MegaDrive joypad with 3 or 6 buttons on an MSX.


How does a MegaDrive joystick work:

    The MegaDrive/Genesis joystick work in a way very similar to the MSX ones, this allows a very easy adaptation and even take advantage of all the buttons with a very simple adapter.

    This is the pinout of the MegaDrive joystick connector:
 
1
Up
2
Down
3
Left
4
Right
5
+5 V
6
TL (A/B)
7
TH (Select)
8
Ground
9
TR (Start/C)

    As in the MSX, virtually every pin has a button assigned that sets the respective output to 0 when pressed, but the difference is that on the MegaDrive joystick the buttons A, B, C and Start use shared pins. A multiplexer selects the set of button you want to read. For example, to read the state of the button A, you must set pin 7 to 0 (ground) from the console (MSX in our case) and read the pin 6, to read the status of the B button will set the pin 7 to 1 and read the value of pin 6. Ditto for the Start and C buttons using the pin 9 instead of 6. When the pin 7 for the multiplexer is set to 0 (ground), the pins 1 and 2 will be set to 0 and will not show the status of the directional buttons up and down.

    The 6-button joystick is a bit more complex, and it's very well described at this SegaRetro page. Just remember that the state of the TH pin is inverted on the MSX.

How does the MSX Joystick Port works:

    This is the pinout of the MSX joystick port:
 
1
Up
2
Down
3
Left
4
Right
5
+5V
6
Trigger 1
7
Trigger 2
8
OUT
9
Ground

    The joystick connector pins are connected to the PSG (which not only serves to generate sound) and you can control them using its registers 14 and 15. The PSG is controlled directly through MSX ports A0h, A1h, A2h and or through the BIOS routines for this purpose, see MSX Technical Hand Book or Red Book.

    The bits 0 to 5 of the register 14 controls the inputs of the joystick port, and the bits 6 and 7 are other functions that do not interest us and therefore we'll not use them. Normally the joystick connector pins are not connected and therefore each corresponding bit in the register 14 is set to 1. As we press a button or move the joystick lever the pins are connected to ground and the corresponding bit is set to 0.

    This is the map of the PSG's register 14:
 
 
b0 Pin 1 state
b1 Pin 2 state
b2 Pin 3 state
b3 Pin 4 state
b4 Pin 6 state
b5 Pin 7 state
b6 Keyboard mode
b7 Cassette Input

    The register 15 controls the joystick port output pins, select the port which will be read with the record 14 and also controls the kana LED status, although this does not interest us. The pin 8 and pins 6 and 7 of the joystick port are output pins, but the latter two will not be used because otherwise the triggers status cannot be read. Although this output control register of the joystick port can also be read, of course we will read the same thing we've written. Do it only to mask the value read and thus do not change the bits that do not interest us.

    This is the map of the PSG's register 15:
 
b0 Output port A pin 6
b1 Output port A pin 7
b2 Output port B pin 6
b3 Output port B pin 7
b4 Output port A pin 8
b5 Output port B pin 8
b6 Selection port. 0=A/1=B
b7 Kana LED Status

The adapter, revision-1:

    Well, once we know how both the MegaDrive joystick and the MSX joystick port works, it's very simple to make an adapter. First of all is to match each pin with its respective one, as follows:
 
MSX port MegaDrive Joystick
Pin 7 Pin 9
Pin 8 Pin 7 
Pin 9 Pin 8

    So we will use the pin 8 of the MSX joystick port, which is not normally used, to control the multiplexer.
    Problem: The default is pin 8 to 0, which causes the joystick to show us the state of A and Start buttons but not the state of the directions up and down, and therefore we could not use the joystick as a normal MSX joystick. To fix that we can (and it's what I have done) is to pass the signal of the multiplexer through an inverter. An inverter inverts the signal on its input, meaning that when it receives a 0 it will send a 1 and vice versa, and that will cause that by default the joystick will give the status of all the directional buttons and the buttons A and C as trigger 1 and 2. When you want to access the other joystick buttons just proceed as I explained above, but considering the changed pinout and the NOT in the multiplexer selection.

    As an inverter the74HCT04 integrated was chosen, which is very simple and cheap. Power supply and grounding can bet get from the joystick port itself. It's not recommended to use the 74LS04 chip anymore because of its high power consumption and incompatibility with some Megadrive controllers.

    Note: The schematic is being shown here with the 1N5711 protection diodes that were added on the revision-3, just in case someone decides to build this version.

74HCT04
    So these are the connections:

JoyMega1 Schematic

Note: all unused inputs of the 74HCT04 chip must be connected to GND.


The adapter, revision-3 (aka joyMega3):

This revision replaces the 74HCT04 with a more modern and smaller chip, the NC7ST04M5X. This allow us to have the same funcionality in a much more compact design with lower power consumption.  Two 1N5711 diodes were also added for the pins 6 and 9 of the Megadrive controller, to protect against bus contention if the pins 6 and 7 of the MSX joystick connector are configured for output (i.e., if PAD(0) is used on MSX-BASIC).

Note: The revision-2 (joyMega2) had the same chip as the joyMega3, but didn't have the protection diodes.

Note2: BAT85 diodes can be used as an alternative to the 1N5711

JoyMega2
        Schematic

Testing:

    The adapter and the joypad can be tested with the HID Tester utility, that autodetects and tests a plethora of devices that can be connected to the MSX joystick ports.

Conclusion:

    After all we'll have a joystick with 6 (in fact, 8) usable buttons connected to the MSX and also compatible with the standard because buttons B and C do trigger 1 and 2 respectively. As a curious remark, the joystick is usable without any adapter but only the B button will work as trigger 1 because by chance the pin 8 set to 0 as it is connected to the ground pin. This one is placed on the MSX on the same pin that the MD joystick has its Select pin. No button would work at all if it wasn't for that.

    Please remember that everything I said about the inner workings of the joystick describes it without the adapter. To code for the MSX you must keep in mind that the select pin of the multiplexer is inverted.



Notes:
1) This is a hobbyist project. Build and use it at your own risk
2) There's a new joystick test utility called JoyTest. You can grab it here. The old JoyMega utility was kept in this page for historical reasons.
3) The original JoyMega adapter was designed by Sergio Guerrero Miralles.