-
Introducing the World's First Joystick for Game Boy
08/31/2019 at 11:40 • 0 commentsI made it. The Joy Boy has seen the day of light. Now anyone can play their Game Boy using a joystick. Anytime, anywhere.
Finally, you're playing with power. Stick power!
-
My Work Environment, Tools, and Resources
08/30/2019 at 17:07 • 0 commentsHardware and software tools, making development a lot easier. Us humans tend to love creating and make use of our tools. They are essential in almost everything we do. We are also fans of standing on each other's shoulders, taking advantage of the knowledge and resources accumulated by the ones who came before us.
I want to share whit you some of the tools and resources that made up my working environment under this silly project, aiding me in the pursuit of making Joy Boy a reality.
Hardware tools
Let's kick it off with the NES to Game Boy Adapter: my handcrafted custom tool for connecting any NES controller, like a Zinger, to the EXT port on a Game Boy. In the photo above, you notice it attached to a Game Boy Advance and a joystick. See Inverter Simulation and Moving To Protoboard for a closer look at the adapter board.
Also attached to the adapter is the probes of a logic analyzer – the Saleae Logic 8. I've used it a lot during this project to peek at the signals and get their timings just right. Without it, I would have fumbled around in the dark.
On the subject of signals, to generate them I need my code running on the Game Boy. There's a handful of ways to make that happen, but I'm using the EverDrive-GB. It's a cartridge that slips right into the Game Pak Slot of the Game Boy and enables executing homebrewed software from an SD card. Super smart!
Software tools
Before running custom software on the Game Boy, it has to be authored and assembled. For that, I'm using Sublime Text as my editor of choice, rgbds for assembling and Make for managing the build process.
I'm a big fan of Make as a tool. In this project, I wrote the sd target, so when running make sd in the terminal, it builds the whole project and copies the resulting ROM file to an SD card. If no card is present, it patiently waits. After the file is successfully copied over the card is automatically unmounted. That sort of thing saves me from much manual typing in the terminal.
BGB is a Game Boy emulator and debugger that helps a lot during development. It's a Windows application but runs fine under Wine. For fast and easy access to documentation, I'm using Dash. If you take a close look at the photo, you'll catch a glimpse of Logic, the software accompanying Logic 8 for signal analyzing.
Great resources
There's no shortage of great material out there when it comes to Game Boy development and hardware tinkering.
The Ultimate Game Boy Talk gives an excellent overview of the Game Boy's architecture and Internet Archive host the official Game Boy Programmers Manual that contains everything you need to get started developing for the handheld. Section 2.5.1 Serial Cable Communication was crucial when figuring out how to communicate with the Zinger.
After all these years the Game Boy Community is alive and kicking, visit https://gbdev.github.io to discover more resources and fellow Game Boy nerds.
-
Inverter Simulation and Moving To Protoboard
08/30/2019 at 13:46 • 0 commentsAn inverter turned out to be an okay solution to the polarity problem. My parts bin lacked anything even remotely looking like a NOT gate, so I implement my own using an ATtiny85. Try to find a dedicated 74x1G04 chip if you are following along and building this yourself at home.
/* Performs the Boolean function Y = Ā, a quick and dirty simulation of an inverter gate. Please don't use this. Buy a 74x1G04 IC [0] instead. [0]: https://www.mouser.com/Semiconductors/Logic-ICs/Inverters/_/N-5820b?Keyword=74%3f1G04 */ const int IN_PIN = 2; const int OUT_PIN = 3; void setup() { pinMode(IN_PIN, INPUT); pinMode(OUT_PIN, OUTPUT); } void loop() { boolean pinInState = digitalRead(IN_PIN); digitalWrite(OUT_PIN, !pinInState); }
With that fixed, I have a fully working connection between any Game Boy and Zinger Joystick (or any NES or SNES controller really). Until now, I have experimented on a breadboard, but I grew tired of the messy state it was in, so for a more permanent installation I took the time to move everything over to a protoboard.
NES to Game Boy Adapter protoboard. Don't pay the wire color choice to much attention. I intended to match the wire colors inside the Zinger cable, but I messed that up. I call it the NES to Game Boy Adapter and you should be able to throw one together yourself by having a look at the schematic.
-
Polarity Sucks
08/15/2019 at 10:06 • 0 commentsDo you remember me telling you about both the Zinger (or any NES controller for that matter) and the Game Boy communicates using not quite SPI, but close enough. That's still true. However, I was naive thinking the two could have a conversation without an interpreter.
The problem resolves around clock polarity and the fact that the NES controller expects the clock signal to be idle low while the Game Boy thinks it should be idle high. Polarity 0 in one end, 1 in the other. That's no good.
There's no way for me to change the polarity from firmware, so additional hardware is probably needed. In the best-case scenario throwing an inverter (NOT gate) on the clock signal should suffice.
If you need to brush up your SPI skills, as I did, What Could Go Wrong: SPI by Elliot Williams is a great read.
-
SNES success
08/13/2019 at 22:38 • 0 commentsSNES controller with relevant pins connected to Arduino Uno. Yes, I found my old SNES controller and, yes, it uses the same communication protocol as the NES controller and, by extension, the Zinger. In other words: it is a decent substitute until a working joystick shows up.
First thing I did after unearthing the controller, was to figure out its pinout. I ended up learning the order of things from the Schematics, Ports, and Pinouts page at the SFC Development Wiki. There's no fancy drawing this time, just this photo:
SNES controller plug pinout. From left to right: GND, NA, NA, D0, OUT, CLK, +5V. SFC Development Wiki provides different signal names compared to the ones at wiki.nesdev.com; using data, latch, and clock instead of D0, OUT, and CLK. I like the former, more descriptive ones, better. Next, I hooked up the controller to the Arduino Uno and ran my test program.
Lo and behold, it worked. I made contact! What does that mean? That I'm able to show current controller state, which buttons are held down at any moment, in a serial monitor on my Mac.
Finally, I've made progress.
Serial monitor and source code windows. Each serial output line represents a change in the controller state. It's me, pressing buttons! What you see in the screenshot above is the result of me pressing buttons frantically during a test session. The controller state fits in a single byte, each bit representing one of the buttons. Can you guess which buttons I pressed in each case with just the screenshot as your guide? There's a hint in the source code window.
On the subject of source code, my test program is pretty simple. On a high level, it implements the NES controller protocol using the Arduino's SPI hardware. At roughly 60 Hz the controller is asked nicely to latch the button state into its shift register and start delivering bits until a full byte is received.
That byte is sent out on the serial line for me to marvel at in the monitor.
I won't go into more details here. The source file is short (< 100 lines) and heavily documented, so I strongly suggest anyone interested to take a closer look and study it.
It's great to be on track again. Now, time to focus on the Game Boy.
-
Stuck and unstuck
08/12/2019 at 18:35 • 0 commentsI like keeping my workbench tidy and organized. Sometimes it doubles as our dining table. Given how much time I've spent troubleshooting, I'm a little disheartened it didn't get me anywhere. I still haven't been able to communicate with the joystick from an Arduino.
Today I, once again, took a screwdriver to the Zinger and tore it down. This time around, I took a closer look at the circuit board and snapped a couple of photos.
Front and back of the printed circuit board. It's virtually just buttons and switches connected to an IC. Next, I grabbed my multimeter and made sure everything was hooked up the way I expected it to be. No shorts circuits or other nasty surprises. I took note of the single integrated circuit on the board and which of its pins each wire ended up at.
Partial pinout of the integrated circuit identified as MDT 5022N. Markings on the IC yielded no result when searching the interwebz. Lacking a proper datasheet, I can never be 100 % sure I've made the right assumptions concerning the pinout. Maybe I got it wrong somehow, and that's why I can't get data off the joystick.
Anyhow, with the PCB exposed I connected the pins directly to my logic analyzer and Arduino Uno and started running my test program – I'll get into more details in a future log entry – and, just as before, the clock (CLK) and latch (OUT) signals from the Arduino to the joystick looked okay, but the data signal (D0) from the joystick was flat. No matter what.
That's it, I'm stuck. At least with this particular joystick. Maybe it tanked during my investigations or perhaps it was already broken when I bought it. (I never confirmed with an actual NES that the joystick actually worked.)
To move forward, I need another Zinger to experiment with. Or some other interim controller, utilizing the NES protocol, like an original NES or SNES controller. I lack the former, but the latter is actually in my possession. Somewhere.
Maybe I'm not stuck, after all.
-
Bad news and good news
08/11/2019 at 09:14 • 0 commentsI've got some bad news and some good news to deliver. Let's start with the bad.
I missed the August 10 deadline for the "Useless Machine" contest.
The good news is that Macrofab decided to extend the deadline to 31st. Yay!
Neither good nor bad is the fact that my initial efforts at communicating with the joystick, utilizing an Arduino board, were fruitless. The data line is silent, no matter what I do to the stick and buttons. Maybe I messed something up during my teardown?
I should team up with a multimeter and logic analyzer next.
-
Crafting breadboard friendly cables
08/10/2019 at 12:48 • 0 commentsI want to start interfacing the joystick already. However, I'm not quite there yet. I need an easy way to connect the joystick to an Arduino, maybe a logic analyzer, and, of course, an actual Game Boy. In my previous log entry, I described the decapitation of the joystick cable – the removal of its NES connector. After that treatment, it's hard to use the joystick even as intended, connected to a Nintendo Entertainment System.
In cases like this, I tend to strip the wires inside the cable and attach jumper wires to them. The result is the breadboard friendly cable shown in the header image.
Jumper wires stripped and prepared with heat-shrink tubing. Everything is ready for the next step: twisting and soldering the wires together. The blue wire before and after the joint is soldered and covered with shrink tube. That's it! Later on, I will need something similar at the Game Boy end: a breadboard friendly Game Link Cable. Luckily that's something I already made for myself a couple of years ago using the same method described above.
The vivid breadboard-Game Link Cable hybrid by yours truly. -
A colorful plug teardown
08/10/2019 at 08:55 • 0 commentsAfter a good nights sleep and breakfast, I reached for my wire cutter and cut off the NES connector from the joystick cable. There are five wires inside the cable, color-coded as black, white, blue, green and brown. I had no idea what color corresponded to wich signal. What I do know is the NES controller port pinout, thanks to the hard-working Nesdev community. With that information, I pried open the plug to figure out the relationships between wires and pins.
So, without further ado, I'll present to you my findings. Be careful though: I can't guarantee all Zinger joysticks are wired the same way or using the same colors as mine.
The Zinger plug pinout
Name
Wire color GND Brown CLK Blue OUT White D0 Green +5V Black D3 Not present D4 Not present Black for +5V and brown for GND? Not the most obvious choices of color if you ask me.
The plug seems happy enough, even after my brutal treatment. -
A strange-looking robot pirate
08/10/2019 at 00:04 • 0 commentsThe Zinger is sold as a Nintendo Entertainment System (NES) accessory and connects to the controller socket. For the joystick to be compatible with every NES game, it should pretend to be an ordinary NES controller.
If that's the case, I'm in luck because the standard controller is well documented and basically just a big parallel-in to serial-out shift register.
I don't want to destroy my Game Boy for this to work, so I have to interface the joystick unobtrusively. Fortunately, every Game Boy come equipped with an External Extension Connector – EXT for short. Have you ever used a Game Link Cable to trade Pokémons with other kids at school? That cable goes to the EXT connector.
The port consists of 6-pins and, according to my interpretation of the Game Boy Programming Manual, it works pretty much like an SPI (Serial Pheripial Interface) device without a slave select line.
"Hey! Isn't a shift register just that?", you might think, "A peripheral device, communicating over a serial line. Maybe … the Zinger and the Game Boy can understand each other. Really well."
Yeah, that's my thought as well. Great minds think alike and all that.
However, the plug at the end of the Zinger cable is too big to fit into the EXT connector. My plan right now (given that my assumptions above turn out to be correct) is to cut away the NES plug from the Zinger cable. Then slice a Game Link Cable in half, merging one of the halves with the Zinger cable. That should yield me a joystick with a cable and plug that fits right into the EXT connection on a Game Boy.
Reasoning about all this is part of what I did since the last log entry. I also cracked open the Zinger and peeked inside.
Some plastic Zinger parts. I throw them out on the floor, and they randomly formed this strange-looking robot pirate. Spooky! Opening the case was easy enough. Seven screws, and that's it. Two wires connecting the stick and PCB prevents a total disassembly, however, unless you're up for some desoldering.
There's not much going on here. I count to one integrated circuit, probably containing the shift register and some circuitry to handle the "Quick Fire" functionality.
When the joystick was all in parts, I seized the opportunity and gave most of the plastic pieces a bath. Probably the first one in a long time. The Zinger is a lot cleaner now and smells goodish.
There's more work to be done before this is a success:
- Remove the plug from the joystick and replace it with pins for easy breadboarding.
- Get a hold of a Game Link Cable with pins suitable for breadboarding (I have one laying around from earlier projects).
- Try communicating with the joystick (using an Arduino) to confirm my shift register theory.
After that, I should be able to write a Game Boy homebrew that interfaces with the joystick.