Close

Expanding: Reading all buttons

A project log for MEGA 2 MSX

Dual Megadrive controller adapter for MSX computers

danjovicdanjovic 09/19/2018 at 02:230 Comments
It is possible to expand the functionality of the adapter using the same technique as the Megadrive to read the 6 button joystick.

In normal operation the selection between Controller A and Controller B is performed by changing Pin 8 from MSX joystick port, then reading the state of the buttons.

As the signal from MSX pin 8 can be stuck at any value it is necessary to poll the Megadrive controllers and constantly update the state of the pins at MSX joystick port and such task is performed once at each 16.384ms.

Once an interrupt occur by a change in pin 8 the state of the pins at MSX joystick port is updated and the next poll is programmed to occur 16.384ms after the end of interrupt routine.

Expanded mode allows the reading of all buttons from a 6 button Megadrive controller and can be accessed after issuing 4 consecutive rising edges on pin 8 from MSX port within one poll cycle interval. The state of the pins will be then determined both by the state of pin 8 - denominated PHASE - that can be Low or High, and by the bit 0 of a rising edge counter that might be either even or odd.

-------MSX PIN STATE-------------     
8        1   2   3   4   6    7
Low      UP  DW  LF  RG  BtA  BtB (Contr. A)
High     UP  DW  LF  RG  BtA  BtB (Contr. B) 1st pulse
Low      UP  DW  LF  RG  BtA  BtB (Contr. A)
High     UP  DW  LF  RG  BtA  BtB (Contr. B) 2nd pulse
Low      UP  DW  LF  RG  BtA  BtB (Contr. A)
High     UP  DW  LF  RG  BtA  BtB (Contr. B) 3rd pulse
Low      UP  DW  LF  RG  BtA  BtB (Contr. A)
High     UP  DW  LF  RG  BtA  BtB (Contr. B) 4th pulse
Low      UP  DW  LF  RG  BtA  BtB (Contr. A)
High     UP  DW  LF  RG  B    C   (Contr. B - Raw ) 5th pulse	 
Low      UP  DW  LF  RG  B    C   (Contr. A - Raw ) 	 
High     Z   Y   X   MD  A    ST  (Contr. B - Raw ) 6th pulse	 
Low      Z   Y   X   MD  A    ST  (Contr. A - Raw ) 

High     UP  DW  LF  RG  B    C   (Contr. B - Raw ) 7th pulse	 
Low      UP  DW  LF  RG  B    C   (Contr. A - Raw ) 	 
High     Z   Y   X   MD  A    ST  (Contr. B - Raw ) 8th pulse	 
Low      Z   Y   X   MD  A    ST  (Contr. A - Raw )	          

...      
...      
...

 Expanded mode is exited by timeout after the next polling cycle

Discussions