Tiny Bit Adventures

Fang the Fox on the Game Boy Color, built with Opus 5.5.

I have a Retroid Pocket, a little handheld built to look like a Game Boy. One evening I wondered whether Fang the Fox could run on it. Not in its browser: as a real Game Boy Color game.

I’ve never written a line of C. So I asked Claude Code, running Opus 5.5. It came back with a plan in ten phases, and by the end of the same day the game was running on the Retroid.

A Retroid Pocket on a desk at night, showing Fang the Fox's title screen: Fang on a floating island under the moon
The title screen on my Retroid Pocket.

A Game Boy Color is tiny.

The browser version of Fang draws on a 384 by 240 canvas with as many colours as it likes. The Game Boy Color has a 160 by 144 screen. It shows 56 colours at once, in palettes of four, and only four colours in any 8 by 8 square. It draws 40 sprites, and only 10 of them on one line. Its processor runs at 8 MHz, it has 32 KB of memory to work in, and it reads the cartridge 16 KB at a time.

So the port isn’t a copy. Every island had to be redrawn to fit, every song rewritten for four sound channels, and every rule of the game rewritten in C.

What's in the code.

The Game Boy edition lives in a gbc folder next to the browser game, in the same repository. It has three layers.

  • The game, in C. About 3,500 lines in 28 files, built with GBDK-2020, a toolkit for making Game Boy games in C. The rules are ported from the browser game’s JavaScript one function at a time. logic.c, combat.c and turn.c move Fang, settle every fight and give each monster its turn. story.c holds every line of dialogue and the quests. dialog.c draws the text boxes, Rudy’s shop and the perk picks, pause.c the pause screen, the world map and the credits, and save.c writes the two save slots on the cartridge.
  • Code that writes code. A build script of about 850 lines of JavaScript reads the browser game’s own maps, sprites and data, and writes another 120 files of C, about 19,500 lines: every island’s tiles and colours, the monsters’ stats, the shop, the font and the title screen. So the two versions share one source. Change a map in the browser game and the Game Boy version follows.
  • Tools that check it. About 750 lines of Python drive PyBoy, a Game Boy emulator you can control from code. One test walks through doors, opens menus and listens for the music. A bot plays the whole game, from the title screen to the credits. Another runs the browser game and the Game Boy game side by side with the same random numbers and checks that every step, hit and drop matches, in 22 different runs.

This is what it looks like.

Here’s one function, the one that starts a song. A Game Boy can only see 16 KB of its cartridge at a time, so each song lives in a bank of its own. To play one, the code finds the song’s bank, swaps it in, starts the music driver and swaps the old bank back, without the screen missing a frame.

void music_play(uint8_t s) {
  const void *song;
  uint8_t bank;
  if (s == music_cur) return;
  music_cur = s;
  sfx_stop();   // sound effects give their channels back first
  bank = song_ref(s, &song);
  __critical {
    uint8_t save = _current_bank;
    silence();   // no note of the last song hangs on
    song_bank = bank;
    SWITCH_ROM(bank);
    hUGE_init((const hUGESong_t *)song);
    SWITCH_ROM(save);
  }
  mute_all(music_on);
}

Every frame has to be done in a sixtieth of a second. The first version of the sprite code used almost the whole frame on its own, so it was rewritten the way old Game Boy games were: small arrays instead of objects, and lookup tables instead of multiplying.

The music is the album, played by a Game Boy.

The first try converted the album’s Bitwig projects note for note. On four sound channels that sounded thin. So each song was recreated by hand: the hooks, melodies and basslines taken from the projects, then written for two square waves, a wave channel and a noise channel. Slim Monsters’ bassline turned out to run in a five-bar loop, so that song is written one bar at a time to stay in step. Each one is a JavaScript file of under a hundred lines.

I did the listening. The title theme’s opening riff sounded better in the plain conversion, so the recreation borrowed that sound.

The bugs were the good kind.

  • Squeezing each island into five palettes of four colours turned the wooden signs green. A smarter palette picker fixed them.
  • Slime Pond’s top row had six slimes: twelve sprites on one line, where the Game Boy draws ten, so they flickered. Three of them moved down a row.
  • A slime from the island behind the title screen flashed through the menu for one frame. The screen was copying the sprite list halfway through an update. Now it waits.

What's in version 1.0.0.

All of Fang the Fox as a real Game Boy Color game. It plays on handhelds like the Retroid Pocket, in Game Boy Color emulators and in your browser.

The adventure

  • The whole web game: 24 floating islands, the five Ember bosses and the Primordial, Grandma, Hoot, Rudy, Lumen and the Fairy Queen, every puzzle, perk, relic and lost kit, from Fang’s nap to the credits.
  • The same rules as the web game, checked step by step against it.
  • Saves to the cartridge in two slots that take turns, so a save cut short by the power never costs you the other.

Made for the Game Boy Color

  • Every island redrawn within the Game Boy Color’s limits and kept at night: each place takes the web game’s lighting into its colours, while lava, crystals and portals glow.
  • Fang’s cottage, the Hearth that lights up at the end, Hoot’s tower, Rudy’s tent and the burrow stand on their islands.
  • A title screen with Forest Home floating in the night sky.
  • A pause screen with a world map, your quest, Fang’s stats and perks, and options for music, sound effects, volume and screen shake.
  • Hold SELECT to see the whole island at once; arrows at the screen’s edge point to foes out of view.

Music

The Tiny Bit Adventures album recreated by hand for the Game Boy’s four sound channels: Fang the Fox, Forest Home, Forest Exploration, Slim Monsters and Plasma Blast. A sound test on the options page plays any of them.

Controls

The D-pad moves, attacks and talks. A is Fire Spin, B eats a fish, START opens the pause screen and SELECT shows the whole island.

By the numbers.

  • One day, from the plan to the version on my Retroid.
  • About 3,500 lines of C written by Opus 5.5, and about 19,500 more written by its build script.
  • A 256 KB cartridge: 24 islands, six bosses, five songs and 19 sound effects.
  • 40 checks, 22 side-by-side runs against the browser game, and a bot that plays to the credits in about 900 moves.

Play it.

Fang the Fox for Game Boy Color has its own page. Download the ROM for your handheld or emulator, or play it in your browser.