TMNT gameplay with front and back views of the original Game Boy

Emulate classic Game Boy action in The Linux Terminal  

David Rutland
David Rutland Gaming

Nintendo's Game Boy is a smidge older than Linux, with the pocket console making its Japanese debut in 1989. For those of us on the Eastern shores of the Atlantic, the first units appeared on the shelves in late 1990, making them the perfect stocking filler for Christmas that year.

The initial Linux release came a mere nine months later in September 1991.

Both platforms have developed almost beyond recognition in the three decades that followed: The original Game Boy was followed by the Game Boy Color, then the Game Boy Advance, the Game Boy Advance SP, and finally the novelty-sized Game Boy Micro, with a form factor that harked back to Nintendo's earlier Game and Watch System.

Linux, meanwhile, has progressed from a hacked-together kernel to the ever-expanding family of distros that power the internet, desktop computers, and even a line of games-consoles.

But when it first appeared - mere months after the Game Boy made its debut on these shores, Linux offered users little more than a naked terminal.

So it seems kind of appropriate to use that monochrome terminal to emulate the monochrome gameplay of the first Game Boy.

Emulate a Game Boy with... PHP?

Emulating the original Game Boy isn't a computationally expensive task, and we were running Pokemon ROMs back when we were still convinced that Amiga was the future - proudly waving the bouncy ball banner as the system disappeared beneath the waves.

Midway through the third decade of the 21st century, you can probably emulate a Game Boy on your electric toothbrush. It's the Doom of consoles - destined to be the benchmark by which the casual excesses of our hardware is judged.

If you just want a quick couple of rounds of Tetris, it's easy enough to find a browser-based version online - or you can boot up one of the very many conventional Game Boy emulators available with a commercial or open-source licence.

PHP is a scripting language that appeared on the scene in the 1990s, and back in the day, stood for Personal Home Page. You'd use it to build websites to display pictures of your cats and your kids. Almost 30 years on and PHP has evolved almost beyond recognition. Aside from dumping its association with homebrew web development, later versions added support for object-oriented programming, better database support Unicode, Just-in-time compilation, and a whole raft of optimisations.

Today, PHP, despite the rather boring rebranding as "PHP: Hypertext Preprocessor", powers most sites on the internet including everything built using the WordPress platform - which itself is often used for... personal home pages.

But it's PHP's usefulness as a relatively lightweight complete language, and the fact it can be executed on the command line, that makes it (kind of ) suitable to build a Game Boy emulator you can play in your terminal.

Why emulate Game Boy games in your terminal anyway?

Browsers are big, hefty things that consume massive amounts of memory. Terminals are usually pretty lightweight.

Maybe you want to play Mega Man V via SSH on a remote system like a Raspberry Pi while you're installing some self-hosted services, such as xxx.

Perhaps you just think playing Game Boy games in a terminal is cool. You're right. It is.

How to install php-terminal-gameboy-emulator on Linux

php-terminal-gameboy-emulator was developed by PHP enthusiast, Gabriel Rodrigues Couto, who has used PHP to start work on projects as diverse as PHP neural network, and even a PHP-based cryptocurrency.

The Game Boy emulator repository hasn't been updated since 2016, and the Readme states that it's compatible with PHP 5.6, PHP 7, and HHVM (HipHop Virtual Machine).

PHP 7 is pretty old, and HHVM hasn't supported PHP since 2017. But if you don't fancy installing ancient software on your spanky up-to-date Linux box, we're pleased to tell you that we've tried php-terminal-gameboy-emulator with all versions of PHP from 8.0 up. We ran into no difficulties, and you can proceed with confidence.

For the easiest way to install the software, you'll need PHP and Composer installed on your system. On Debian-based PCs, you can install these with:

sudo apt install php-cli git composer

To get started, open a terminal in the usual way and clone the php-terminal-gameboy-emulator repository, and use the cd command to move into your new directory:

git clone https://github.com/gabrielrcouto/php-terminal-gameboy-emulator.git && cd php-terminal-gameboy-emulator

Now use Composer to install the emulator:

composer install -o

The entire process should take no more than a minute.

we found it useful to create an alias to make it easier to launch the emulator:

echo -e "\nalias php-gameboy='~/php-terminal-gameboy-emulator/bin/php-gameboy'" >> ~/.bashrc
source ~/.bashrc

We found this to be the most reliable way to install the emulator. Other methods are detailed in the official repository.

You can play Game Boy games in your terminal on Linux!

Your new terminal-based gameboy emulator accepts the path of a Game Boy ROM as an argument, or will look for ROMs in your current directory. We wanted to play TMNT II - Back from the Sewers, so we entered:

php-gameboy Teenage\ Mutant\ Ninja\ Turtles\ -\ Back\ From\ the\ Sewers\ (U)\ [!].gb

Startup is instant, smooth, and gloriously monochrome.

As a quick reminder, the original Game Boy had a limit number of buttons. There was a D-Pad for directional control, plus B, A, Start, and Select. In contrast, your standard PC keyboard has six rows of keys, and probably a numeric keypad. It's a little overkill for a tiny console, and you'll onnly be using a few of them. These are your standard AWSD for direction, plus comma and period (full stop) for A and B, with M and N standing in for Select and Start.

How do Game Boy Games play in the Terminal?

We don't have limitless time on our hands, so were only able to test a few games during our coffee break.

Gameplay was smooth on all the games we tested, although there were some artefacts around the sprites when moving. Naturally, there was no sound.

And if you need some more nostalgia...

If we're being honest, the project is more an exercise in showing what the terminal can do, rather than a platform for engaging in serious retro gaming. If your committed the idea of using the command line for games, try these games you can play in your Linux Terminal.

Alternatively, if you want an emulation station you can take with you anywhere, you can easily convert a cheap Leapfrog Leapster into a fully featured pocket emulation platform