Close
0%
0%

MEGA 2 MSX

Dual Megadrive controller adapter for MSX computers

Similar projects worth following
This project uses an ATMegaxx8 to provide the connection of up to 2 Megadrive (Sega Genesis) controllers to MSX Joystick port. The Circuit shall support either 3 or 6 button controller mapped as follows:
Megadrive -> MSX
UP -> ditto
DOWN -> ditto
LEFT -> ditto
RIGHT -> ditto
Button A -> Trigger A
Button B -> Trigger B
Button C -> Trigger A + Trigger B
Button X -> Autofire Trigger A
Button Y -> Autofire Trigger B
Button Z -> Autofire Trigger A + Trigger B
Start -> LEFT+RIGHT
Mode-> UP + DOWN

This project is to allows the connection of 2 Megadrive (Sega Genesis) controllers to the MSX joystick port. The Circuit shall support either 3 or 6 button controllers mapped as follows:

Megadrive -> MSX
UP -> ditto
DOWN -> ditto
LEFT -> ditto
RIGHT -> ditto
Button A -> Trigger A
Button B -> Trigger B
Button C -> Trigger A + Trigger B
Button X -> Autofire Trigger A
Button Y -> Autofire Trigger B
Button Z -> Autofire Trigger A + Trigger B
Start -> LEFT+RIGHT
Mode -> UP + DOWN

Hardware:
The circuit is based on an ATMegaxx8 with internal clock. The board was routed to fit within 1x1 inch and optimized for DIY construction (no vias under the microcontroller, 16/12 mils traces and olly 11 vias with 56 diameter and 27 mils (0.7mm) holes.

The MSX shall be connected to the board using a 9 way cable with DE-9 female connector on one side. The using of 9 way MOLEX 0.1" connector is optional as the wires can be soldered to the board. The board provides 2 DE-9 male connectors for attaching the Megadrive/Genesis controllers.

The selection of either controller to be read is according with the state of pin 8 from MSX joystick port. Low level for controller 1 and High level for controller 2, hence it is necessary to use assembly code to read the second controller.

Software:
The software architecture is based on a main task and one interrupt task.   
The main task sample both controllers at a rate around 60Hz and updates the internal variables as well as the currently selected controller.

The interrupt code is attached to PIN CHANGE event and updates the state of the output according to the last sample. At the end it updates the state of the currently selected controller.

Autofire is provided as a modulation function at 1/6 of the sampling frequency.

MEGA_MSX(A).sch

Schematic (Eagle 7) new version

sch - 370.14 kB - 09/19/2018 at 02:02

See BOM
Download

MEGA_MSX(A).brd

Circuit Board (Eagle 7) new version

brd - 74.36 kB - 09/19/2018 at 02:02

Download

MEGA_MSX.sch

Schematic (Eagle 7)

sch - 370.07 kB - 08/23/2018 at 01:52

See BOM
Download

MEGA_MSX.brd

Circuit Board (Eagle 7)

brd - 73.11 kB - 08/23/2018 at 01:52

Download

  • 1 × ATmega8 Microprocessors, Microcontrollers, DSPs / ARM, RISC-Based Microcontrollers
  • 1 × 100nf capacitor 0805 size
  • 1 × 10K resistor 0805 size
  • 2 × DE-9 male Edge type sub-d connector
  • 1 × Molex 22-23-2091 Connectors and Accessories / Board-to-Board and Card Edge Connectors

View all 7 components

  • PCB ready!

    danjovic10/10/2019 at 03:19 0 comments

    PCBs just arrived. Routing was done in 2018 but I have just ordered the boards last month.

  • Expanding: Reading all buttons

    danjovic09/19/2018 at 02:23 0 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

  • Safeguard

    danjovic09/18/2018 at 23:41 0 comments

    As this project uses internal clock I have merged both SELECT inputs from Megadrive cotrollers in a single line at pin PB7 OSC-OUT and left pint PB6 OSC-IN open just in case something go wrong with the fuses configuration and the AVR would expect to operate from external crystal.

    A track was added to pin 7 which ends in a large track. Over the latter another track on the TSTOP layer as added so the solder mask will not be poured over it

  • Iterative design

    danjovic08/23/2018 at 02:05 0 comments

    Such small boards require some iteration in design:

    • Lay the components,
    • Choose the pins to use for each function
    • Draw some straight lines between pins that shall be interconnected
    • Connect pins schematic
    • Route the board
    • Repeat all steps as necessary until routing is finished (and you're happy with it)

View all 4 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates