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 without much circuitry involved.
This is the pinout of the MegaDrive joystick connector:
| ||+5 V|
| ||TL (A/B)|
| ||TH (Select)|
| ||TR (Start/C)|
As in the MSX, virtually every pin ha a button assigned that connects it to ground when pressed, but the difference is that on the MegaDrive joystick the buttons A, B, C and Start uses shared pins. Using a multiplexer the button you want to read can be selected. 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 joystik is a bit more complex, we have 4 more buttons: X, Y, Z and Mode using the same connector, as it should be compatible with the 3-button joystick. To obtain the status of the new buttons have to send a sequence of 3 ones to the multiplexer, so we have to quickly change the state of pin 7 this way: 010101. Doing so will show the status of X, Y, Z and Mode buttons on pins 3, 2, 1 and 4 respectively. Before sending the last 1, when the multiplexer is set to 0 the joystick will return zero on pins 1, 2, 3 and 4, and this will tell you whether this is a 6-button control. To have the joystick showing the state of the normal buttons again, just reset the multiplexer to zero. Anyway it will return itself after a certain time (less than a 1/60s I think, although I'm not sure).
How does the MSX Joystick Port works:
This is the pinout of the MSX joystick port:
| ||Trigger 1|
| ||Trigger 2|
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|
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|
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 I have used the 74LS04 integrated, which is very simple and cheap. Power supply and grounding can bet get from the joystick port itself.
So these are the connections:
Note: all unused inputs of the 74LS04 chip must be connected to GND.
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.
I mounted it using a breadboard and did fit it into a box the size of a small matchbox. It had no problems with a 6-button joystick AsciiWare, very good indeed. To test it I created the JoyMega utility, which can check the status of all buttons.
Please remember that everything I said about the inner workings of the joystick describes it without the adapter. To code for the MSX you mut keep in mind that the select pin of the multiplexer is inverted.
I hope someone reads this and get interested to make a game that support these joysticks. For any questions write to firstname.lastname@example.org.
Sergio Guerrero Miralles.