Hi there, I've been messing around for the last couple of weeks trying to make a SNESBot with my Pi and I'm happy to announce I finally got the b*gger working! Woo yay etc
I'm sure this isn't the first and hopefully it won't be the last Pi controlled SNESBot, but I'd thought you guys might be interested in it.
My first approach is probably very familiar, wire up the Clock, Data and Latch pins straight into the GPIO and try to bitbang the data out. Even though the benchmarks I read for the Pi's GPIO said it might be possible, what I found was that it just wasn't quick enough to clock out the data. Latchs seemed to be sensed OK so I moved onto my next attempt.
This involved taking a knock off SNES controller (again, this is probably very familiar to certain readers) and tried wiring up 12 GPIO pins to the controller PCB. I'm normally pretty good with soldering, I work on pinball tables and have done the odd custom SNES cart, but for some reason the tracks just kept on lifting and I was getting nowhere.
This lead to my third attempt, which involved buying 2 4021 shift registers and cloning the SNES controller hardware. I then set about writing the code to drive it and was pretty disheartened when I found out that although I could get it to work, it wasn't any where near reliable enough. Live input (a PS1 controller plugged into the USB port in the Pi) seemed to be ok but it just desynced all the time when I was playing back recorded data. Not a happy chappy :-(
After spending a couple of days pouring through my code (and squashing a few bugs in the process) I was ready to give up and admit to all the people who had told me that it just wasn't possible with the Pi and I should use a microcontroller like everyone else. I was lying awake last night when at 3AM I had an idea and went to the shed to check something.
Like an idiot I had wired up the 3.3V output to the 4021 Vcc, after I switched it to the proper 5V I fired off a recording and lo and behold, there was Orchid hitting 42 hit combos again and again and again without missing a bit. To say I was pleased is an understatement.
Right now, I can play using live input with any USB input device (SMB on a real SNES with a keyboard is hilarious) and recording and playback from my disgusting simple file format works a treat. All I'm doing is copying the evdev event and the latch it occured on into a file, then replaying that data out.
Most carts are working fine, I've only done a little bit of testing but I can run over 10 minutes of playback without any desyncs, which I'm very pleased about. Even managed to get a synced playback of SuperGB Tetris, which I really didn't think it would be able to do due to the latch speed doubling (120Hz rather than 60Hz).
This is the same rate as the Nintendo controller test cart and I'm guessing it's because the CPU can poll the controllers more as it is doing less/offloading onto the Z80 in the SuperGB.
Next steps are to write a couple of file importers so I can start running some of the videos on the site on real hardware, look into some more fun features like auto-fire/button-macros etc. Maybe even have a shot at Netplay just for sh*ts and giggles.
I'm pretty pleased with the low budget I've managed to do this on, with a minimal part count but the wiring leaves a lot to be desired. When I get around to making my Mk4 board I'm hoping to tidy up a lot of it.
Here's the schematic I came up with:
And here's the code I am using, don't laugh, I'm not a great programmer which is why I am so amazed it actually works!
https://github.com/SonnyJim/snesbot