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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.