With this little device you can play t a he original Game Boy Tetris with friends over
the internet. And here’s how!
It all started with my last video, where I mined Bitcoin on the Game Boy. As I now had
a USB to link cable adapter, I thought: What’s next?
And then I got an idea: What if I built something that lets me play Tetris against my friends
over the internet? Because for the past year, meeting friends and playing with them hasn’t
really been an option, and I thought it’d be really fun to sit with some friends in
Discord and play Tetris on the original game boy against each other!
In case you haven’t played Game Boy Tetris via link cable before, here is how it works:
You connect two Game Boys to each other, select two player, the host selects the music, then
both get to select a handicap, and when the game starts, both players get the same tiles.
There are two ways to win: The first is by being the first who clears 30 lines, the second
one is if your opponent fills up. You can make life for your opponent harder by clearing
multiple lines at once, which will send lines to your opponent that will be added to the
bottom of his stack!
When I started searching for the details of the communication details I was surprised
to not really find much, and so I started reverse engineering it myself. And after staring
into the logic analyzer for a bit, I had all the details together to build it.
The way the Tetris Link cable protocol works is that the Game Boy that starts the 2 player
game basically becomes the Game Host, and when the game is started the hosting Tetris
will randomly generate 256 tetrominos and send them to the client Tetris. This is done
so that both players get the same tiles. After that, each Tetris sends its current
height to the other one, and also notifies if multiple lines have been cleared of if
the player won or lost.
My goal was to build something that would allow me to play Tetris not only against one
player, but against two, three or many others, making it possible to even have a battle royal
tetris competition.
To do that, my idea was to let my computer act as the Game Host Game boy, and to let
the actual Game Boy run as the second player. The communication between the link cable and
the computer is done via a Raspberry Pi Pico plus some level shifters, which acts as the
USB to link cable adapter. To communicate with the adapter, I would have to build a
game client that runs on the computer. This game client would then talk to an online
game server, that provides basic match creation and match management functionality.
Using this architecture multiple Game Boys can talk to the same game server. The game
server, on game start, will send the same tiles to all of the connected clients, which
will then forward it to the actual Game Boy.
During the game, the server will handle if one of the gameboys fills up, and distribute
that information to all others clients. Eventually, all but one game boy will either fill up and
win, or someone finishes the 30 lines, and wins that way. l
Now in my last video, I already used the Raspberry Pi Pico, combined with some level shifters
and a modified link cable, to connec the Game Boy to my computer.
This is not really something you can send to your friends, and it also was not really
easy to use or stable. And so I decided to design a custom PCB that has the level-shifters
and the Raspberry Pi on board, is much easier to handle, and doesn’t require cutting open
a link cabel, because it has the Link Cable connector directly on board.
It’s also both compatible with the original Game Boy connector, as well as with the Game
Boy Pocket, Color and the Advance and Advanced SP.
On the other side we have a Raspberry Pi Pico that provides all the logic and USB functionality..
I am also excited to announce that I am now manufacturing these boards and will sell them
as a small kit: The more difficult to solder components will
already be soldered onto the board, and you just have to quickly solder on a Raspberry
Pi Pico - either through hole, or using pin sockets, or just soldering it on surface-mount
style like I did here. This allows you to experiment with the Link Cable protocol yourself,
and to play Tetris against your friends over the internet!
You can find the link to order one in the description!
Alternatively, you can also sacrifice a link cable, and use a couple of level shifters
and a breadboard to build your own adapter. I’ll put some instructions for that into
the github repository.
For the firmware, I wanted to try something I hadn’t used before: WebUSB.
I wanted to make usage of the adapter as simple as possible, without having to deal with building
drivers for different operating systems and without having to deal with building a cross-platform
application for Windows, Linux and Mac OS.
And WebUSB allows me to do just that: When you plug in the device you get a small popup,
and when you click it it will lead you to a website. And that website immediately allows
you to start playing: No driver installation, no downloads, nothing. You click connect,
and your Browser starts talking to the Game Boy! Isn’t this cool? And what’salso really
awesome: Using WebUSB, the adapter can even work on Android phones! As always, the link
to the Github repository with the code of the firmware is in the description!
Now I’m not particularly into web-development, but a lot of people seem to like React, so
I decided to learn a bit of React development, and built a simple frontend that makes creating
and joining a match super simple: You visit the website, click Connect, select
the Game Link adapter, and the website will then automatically connect to your Game Boy.
Next the web-interface allows you to chose your tune - obviously Music A is the only
acceptable choice, but if you really want to you can also select one of the other melodies
or turn music off entirely.
Next you can choose a username, and either create a new match, or join an existing match
using a match-code. When you create a new match, a unique match ID will be generated
that you can send to your friends. Once everyone is connected you simply click start to start
the game.
But before we try that, we need to talk about the game server:
The game server is written in Python3. And to allow our browser application to talk it,
it’s providing an API via websockets. The websockets API is relatively simple, and so
for example we can ask the server to create a match, and it will simply reply to us with
a match ID.
All other players that want to join your game, will ask the server to join the match using
the match id. If the match is found, and not already in progress, all players will be put
into a common lobby.
When the lobby creator starts the game, the server will send the same tile-set to all
players in the lobby, and the react client will then send them to the Game Boy.
From then on the clients will report whether they won, or lost, and the server will distribute
all the information.
With all that in place, it was finally time to give it a try. But first, I had to find
a worthy opponent! And I thought who could be a better choice than my good friend and
now tetris archenemsis liveoverflow!
Hey this is liveoverflow and stacksmashing also sent me one of the USB to Game Boy Link
cable adapters, which means i can challenge him to a game of Tetris!
So lets connect the Game Boy and create a new lobby. I’ll send the code to liveoverflow
so he can join, and.. There he is! So it’s time to start the match: LiveOverflow vs stacksmashing
- round one, go!
As you can see, as soon as I hit start, my Game Boy starts the game! And so does LiveOverflows!
And we are getting exactly the same tiles! You can also see that I’m a pretty terrible
tetris player!
As you can see we get exactly the same tiles, and you can also see that I’m a pretty bad
tetris player once the camera is running!
I had a strong start with a quick tetris, and you can see how the lines appear on LiveOverflow’s
screen, unfortunately I couldn’t keep that up, and LiveOverflow quickly started filling
up my screen, until I eventually lost. All this work, programming, testing, soldering,
PCB design, and so on.. And I lose. Unbelievable.
But wait. This is just 1 vs 1, we also needed to try the multiplayer aspect - something
that isn’t supported by the original tetris!
And so we created another match, this time with 3 players!
And it works! We all get to play together! And even better, this time, liveoverflow is
quickly put out of the game, with only nightowl and me remaining! But unfortunately…. I
lost.. Again… Damn it! But wow is it fun to play!
All the source-code for the Pico, the game server and the frontend is linked in the description,
and I’ve also got a hosted version of the game online.
ALso if you’re looking for players, I’ve created a dedicated channel for match-making
on my discord.
If you want to support my channel, you can order a PCB from the link in the description,
or support me on patreon.
I’ll also publish more details on how I reversed the tetris communication protocol
here soon, so please subscribe if you enjoy that kind of content!
I hope you enjoyed this video, and to see you on this channel again soon! Thank you!