SNES controller implementation on the Neo Geo
I’ve been in an admittedly slow process of consolizing a Neo Geo arcade board (MV1C model), and one thing I quickly realized is that the price of original Neo Geo controllers is staggering - and if I really was going to pay full price for controllers I may as well go all-in and buy a home version of the console itself and call it a day.
So one of the obstacles to overcome is to find an alternate solution, which I’ve settled on SNES controllers to be a substitute for the original Neo Geo controller. It maintains all the buttons, and probably anybody interested in a consolized Neo Geo is fanatical enough that they are almost certainly going to own a Super Nintendo, so they won’t have to shell out any more dollars.
The beautiful thing about this implementation is that it is LAGLESS. Even though the serial data from the SNES must be converted to parallel, an entire polling loop takes .098875mS, while a 60fps frame draw means a new frame every 16.67mS - so we can actually poll almost 168 times between frame draws! This is a lot of pulses to the shift register in the SNES controller, but it can handle it - the 4021 shift registers in the controller has a speed operation in excess of 12Mhz.
I’ve programmed the below in BASCOM-AVR and tested with an ATTINY2313. Potentially there are cheaper/smaller AVRs that will suffice, but the IC is already pretty cheap and plentiful. This code is also quite long (not complex, but repetitive) so it takes up more program space than usual. You can program the BASCOM code easily onto a ATTINY2313 with the cheap, yet powerful, TL866II Plus.
There is only three data wires on the controller to be concerned with; you can of course change what pins you want to use but in my actual PCB design these pins are most convenient for routing.
- Latch (connect to A0)
- Clock (connect to A1)
- Serial (connect to D5)
All the parallelized data will be put on Pins B0 through B7 and D0 through D3. Again, you can of course change this easily, I just chose those for routing purposes.
The basic operation of the SNES controller is that it awaits for a latch pulse (12uS wide, issued by the ATTINY) and then the controller transmits back the state of the buttons (pressed or not) via shift registers over serial - 16 such data points (first 12 only matter though, last 4 are dummy points). The clock pulses issued from the ATTINY to the controller are what ‘setup’ and ‘shift’ these values over serial such that you then sample theses serial pulses with the ATTINY and dump them out in parallel.
It’s also worth noting, I use the term parallel, but it’s really pseudo-parallel… the output pins are set in sequence, but this happens so fast the data is “staged” well in advance of when the Neo Geo will ask for it, thus it appears as parallel from the Neo Geo perspective.
I have mapped the SNES controller buttons to match that of the newer Neo Geo mini controller, which many people are saying is a better layout than the original controller. It makes sense, if you look at an MVS cabinet, A&B and C&D are next to eachother, which are usually pushed simultaneously for specific moves. The mini controller layout makes it easier to press those buttons at the same time with your thumb, whereas the traditional controller layout made it difficult.
Controller comparison (base photo credit @metaljesusrocks):
Download source files below:
You can program the compiled BASCOM code (.hex) easily onto a ATTINY2313 with the cheap, yet powerful, TL866II Plus.
When programming the board be sure to remember to upload as INTEL HEX and set fuse settings in the Xgpro software used by the TL866II.
Select INTEL HEX when you open the .hex file you compiled in BASCOM-AVR
For fuse settings, the ATTINY2313 datasheet on page 27 has the settings layed out for using an internal 8Mhz clock…
The relevant settings are on the config tab in the software. As we are using a 8MHz internal clock we want CKSEL to be 0100 and SUT as 10, which is a low fuse setting of 0x64
It is important the fuse settings are correct! You can brick your AVR if set incorrectly, and that’s not fun!comments powered by Disqus