============================================= Sega Six Button Controller Hardware Info ============================================= Source: http://www.cs.cmu.edu/~chuck/infopg/segasix.txt Author: Charles Rosenberg, chuck@cs.cmu.edu Version: 1.0Last Update: 9/9/96==========Background==========A couple of months ago I was looking for a cheap, robust, hand heldcontroller for a project I was working on. The controller for theSega Genesis was the perfect choice because it was ready available andhad a standard DB-9 connector for interfacing instead of theproprietary connectors used on the controllers for a lot of the newergame systems. I was able to find interface info for the 3 buttoncontroller, but I could not find any information about accessing theX, Y, and Z buttons on the newer 6 button controllers. A littlereverse engineering uncovered the necessary info. This documentdescribes how to interface to a 6 button Sega Genesis Controller.============Introduction============The controller for the Sega Genesis is a hand held controller usefulfor many applications. It has a joypad, a start button, and actionbuttons. Another big advantage is that it has a standard DB-9connector for interfacing instead of a proprietary connector. Theoriginal version of the controller has three action buttons, labeled:A, B, and C. The original version was easy to interface to. Newerversions of controller have six buttons, the original three and threenew ones, labeled: X, Y, and Z. The newer version is a little moretricky.======================Three Button Interface======================The interface for the original three button controller is relativelysimple. (I know that it has been described elsewhere, but I thinkthat this description is more straightforward.) You can open up thecontroller and see that a standard quad 2:1 multiplexer chip isinside, a 74HC157. A 2:1 multiplexer directs data from one of twosources to a single input line based on the state of a select signal.So, theoretically, this chip would allow 8 signals to be sent over 4data lines. The way the Genesis uses this chip, the data from the 8switches in the controller is sent over 6 data lines, not quite themost economical solution, but one which makes the controller backwardscompatible with Atari 2600 joysticks.Inside the controller is a small PC board which contains the 74HC157,some 10K pull-up resistors and some bypass capacitors. The switchesare connected so when a switch is pressed (closed) it shorts itsoutput to ground, otherwise it's output is 5 volts (via the pull-upresistors). One additional connection is a pull-up resistor on theselect line. If it is left unconnected it will be "pulled" high.The following tables summarize how the signals are mapped to DB-9.The output signal to a particular pin depends on the state of theselect line from the Genesis. During a standard game, the processorwill set the select line high or low, depending on the which gamecontroller buttons it wants to read.This table lists connections which are outputs from the Genesis to thecontroller, the first column is the pin number of the DB-9:Pin Connection --- --------------- 5 Power: +5 Volts 7 Select signal 8 Power: GroundThis table lists connections which are outputs from the controller tothe Genesis and are dependent on the logic level to the select signal,again the first column is the pin of number the DB-9:Pin Connection with select low Connection with select high--- -------------------------- --------------------------- 1 joypad up signal joypad up signal 2 joypad down signal joypad down signal 3 logic low (ground) joypad left signal 4 logic low (ground) joypad right signal 6 Button A signal Button B signal 9 Start button signal Button C signalNotice that the signals on pins 1 and 2 are not affected by the selectsignal, there is a direct connection from those switches to thecorresponding pins. Also notice that signals on pins 3 and 4 are notused to send switch info when select is low.If you monitor the select signal to the controller on an oscilloscopewhile playing a game on the Genesis, it will look something like this:5V ---+ +-------------+ +-------------+ +--- | | | | | |0V |_| |_| |_|The low time of the signals is not drawn to scale with the period ofthe signals. However, notice that the signal is mostly in one state(high), and then is low (inverted) for a short period. A typical gamemay sample the controller at 60 Hz, resulting in a period of 16.7milliseconds. The low time for a select signal pulse might be around20 microseconds. The timing can vary significantly from game to game.The basic reason for this pulse pattern, is that every so often, thegame will call a routine which reads the state of the controller.This routine will bring the select signal low and then record thosevalues and the bring it back to its default state.That sums up the three button controller, now on to the new stuff.====================Six Button Interface====================The three button controller description was just a preamble for thesix button controller. When you open up the six button controller,you notice a bunch of differences in the circuit besides the threenew buttons. The simple one is the addition of a fourth button whichacts as a mode select and tells the controller to be compatible withthree button controller games. The ugly one is that the nice standardHC157 has been replaced with a custom chip (a microcontroller, a GAL?)and most of the pull-up resistors are gone. So instead of being ableto trace out the circuit, you have to resort to the oscilloscope (orlogic analyzer) and see what the signals are doing while playing agame that uses the additional three buttons. My test subject was MK3.So why did Sega go to all of this trouble of replacing a nice simplelogic chip with a custom IC? Did they have too much time and money ontheir hands? (Of course that is a possibility.) No, the reason seemsto be backwards compatibility. As the descriptions following I hopewill show, the new controller is designed to be compatible with almostall three button games, without the use of the mode select switch.Some quick probing on the circuit board reveals that the pull-upresistors for the switches have moved inside the chip and all of theswitches still output a logic low when pressed. The pull-up for theselect signal still exists as a discrete resistor. There are alsosome additional capacitors for power supply filtering and generatingthe clock signal for the custom chip.If you monitor the select signal generated during a game, you will seesomething like the following:5V ---+-+-+-+-------------+-+-+-+-------------+-+-+-+--- | | | | | | | | | | | |0V | | | | | | | | | | | |The amount of time between the start one of these pulse groups and thenext is about 16.6 milliseconds or 60 Hz. In my interfacingexperiments I have successfully used 33.3 milliseconds or 30 Hz.A closer examination of the pulse groups on the select line:5V ---+ +-+ +-+ +-+ +----------------------------------- | | | | | | | |0V |_| |_| |_| |_|The period of these signals for MK3 was about 27.6 microseconds. Thatis the high or low time for the pulses was 13.8 microseconds. In myinterfacing experiments I successfully used a signal with a 200microsecond period, 100 microsecond high or low time. I suspect thatthere is some maximum period length associated with a time-out in thecustom chip, but I have not investigated what that is.Interesting things reveal themselves if you monitor pin 3 of the DB-9with the X button pressed:5V ---+ +-+ +-+ +------------------------------------- | | | | | | 0V |_| |_| |___|And if you monitor pin 3 of the DB-9 with the X button NOT pressed:5V ---+ +-+ +-+ +--------------------------------------- | | | | | |0V |_| |_| |_|Now what Sega has done can be deciphered. To obtain the new buttondata, a series of pulses needs to be sent to the controller on theselect line. For the first two pulses, the controller responds in thesame way as a three button controller. However, immediately after thethird pulse goes from low to high, the controller will output new dataon existing data lines. You can think of this as a new value for theselect line: Low, High, and what I will call Pulse-3. The fourthpulse resets the controller to compatible mode.The updated table with the third select state is as follows, the firsttwo columns are the same as the three button case:Pin Select: low Select: high Select: pulse-3--- ------------ ------------ --------------- 1 joypad up joypad up button Z 2 joypad down joypad down button Y 3 logic low joypad left button X 4 logic low joypad right 6 button A button B 9 start button button CThis table does not change from the three button controller case:Pin Connection--- --------------- 5 Power: +5 Volts 7 Select signal 8 Power: GroundSo what about compatibility? Under normal circumstances this systemmaintains compatibility. So what's the use of the "compatibility"mode switch? Obviously the controller could be fooled if some gamesdo strange things with the select line. Some game code might not polland store the state of the controller, if game code accesses thecontroller throughout its code, then unpredictable pulse trains couldbe sent to the controller which put it in "pulse-3" mode. And howabout games that aren't compatible no matter what? My guess is thatthat has to do with the speed of the custom chip. Because the threebutton version uses a discrete logic chip, the outputs of themultiplexer can react to the state of select line in a matter ofnanoseconds. However a little microprocessor or a slowly clockedstate machine made from custom logic would not be able to respond asquickly, causing incompatibility problems if code was written toassume instantaneous response on the select line.==========Conclusion==========So interfacing is not that difficult after all if you are interfacingthe controller to a microprocessor of some sort. In my case it was a68332 running Lisp. I highly recommend the controller it packs a lotof punch in a small price and the DB-9 interface makes it easilyreplaceable if it goes bad. Have fun interfacing.