Content
Last year, I received a well-preserved Gameboy Color (GBC) as a gift, which inspired me to explore its capabilities beyond traditional gaming. Fascinated by its built-in infrared (IR) transceiver, I decided to develop an application enabling the Gameboy to control my air-conditioner (A/C) by leveraging its existing, reverse-engineered IR protocol. The Gameboy Color distinguishes itself from its predecessors through several enhancements, such as a color display, an option to run at double the processor speed, and infrared diodes for transmitting and receiving signals, located at the top-left corner of the device.
My project began by investigating whether anyone had previously utilized the Gameboy's IR transmitter for such purposes. I found that the 'Mission Impossible' game could record and replay IR signals, proving the feasibility of the concept. To implement this, I required additional hardware to program the Gameboy with custom code. I acquired a bootleg game cartridge originally containing Pokemon Red, which can be reprogrammed unlike official cartridges that are typically write-once. Programming the cartridge was done using InsideGadget's gbxcart-rw programmer, a well-documented and affordable tool.
Understanding the IR communication protocol of my A/C was essential. Since the company "National" that manufactured my A/C no longer exists and documentation was scarce, I resorted to physically capturing the IR signals by carefully drilling a hole and soldering a thin wire onto the original remote’s transmitter. This invasive yet effective method revealed that the IR signal was modulated at 36.5kHz, slightly different from the more common 38kHz frequency. This frequency discrepancy posed a challenge, as the Gameboy hardware does not natively support switching the IR LED at such a precise rate.
Once I had captured various commands for temperature and modes, I analyzed the patterns and successfully generated transmissions using a modern microcontroller as a test platform. Equipped with this understanding, I began coding for the Gameboy itself. When choosing a software development kit (SDK), I found two main options: GBDK, based on C, and RGBDS, an assembler. While GBDK offers ease of use and rich examples, it is limited by an outdated compiler lacking some advanced features like inline assembly. Assembly language offers full control and efficiency, crucial given the platform's strict constraints like limited memory, sprite counts, and processing speed.
For my project, I combined both: using C for general logic (UI, input, IR packet construction) and assembly for timing-critical IR transmission. Precise timing was vital, as the IR LED had to be toggled with exact delays, achieved through calibrated NOP (no operation) instructions. The "GBDK-N" project, an enhanced fork of GBDK with modern compiler support, facilitated this hybrid approach.
Activating the IR LED on the GBC was straightforward—setting a register bit to power it on. However, generating the modulated IR carrier wave was challenging. Attempts to use the hardware timer failed to achieve the desired 36.5kHz frequency, so I resorted to CPU-intensive busy-wait loops using carefully counted NOP instructions to modulate the signal manually. This approach, although inefficient, paralleled methods used by Nintendo in other timing-sensitive scenarios like sound generation.
To verify transmissions without modifying the Gameboy hardware, I used an intriguing property of LEDs: when exposed to light, they produce tiny electric currents. Using a simple setup with an IR diode, resistor, and oscilloscope, I recorded the IR LED’s output signal and fine-tuned timing parameters until the modulation frequency closely matched the target 36.5kHz. Once the frequency was close to 37kHz, the A/C responded with a beep, confirming successful communication.
The Gameboy’s IR transmitter is highly directional and requires a direct line of sight to the A/C unit, but otherwise functions identically to the original remote. This project highlights the ingenuity of repurposing vintage hardware for practical modern uses, underscoring the contrast between the constraints of legacy embedded systems and the flexibility of contemporary software development environments. Overall, it was a rewarding experience, combining hardware hacking, signal analysis, and low-level programming to breathe new life into a classic gaming device.