Writing “Hello World” for a Nintendo Game Boy!

I am a huge retro-gaming geek, I love reliving my childhood and playing classics such as Super Mario Land and Donkey Kong. The Nintendo Game Boy was (and still is!) one of my favourite systems. I’ve always stayed clear of doing any development on retro-gaming systems from the 80s/90s though as this typically involves writing code in assembly language and the learning curve for a non-dev like me is far too high 🧠.

I recently discovered the Game Boy Development Kit (GBDK) on GitHub, which allows you to write software for the Nintendo Game Boy (and a few other systems too!) in C.

I’m certainly no expert in C, however I was fairly sure that I could knock up “Hello World” without too much of an issue.

I downloaded the GBDK and extracted this to a folder (no install is required), I then set about writing this masterpiece –

#include <stdio.h>

void main()
{
int counter = 1;

while (counter <=16)
    {
    printf("\nHello World!");
    counter++;
    }
}

This is similar to the BASIC – 10 Print “Hello World”, 20 GOTO 10 that fills the screen with “Hello World” that I first wrote on my Amstrad CPC 6128 back in 1990 😀.

Once I’d saved the file (naming this “helloworld.c“), I then compiled the code using the following command. This creates a ROM for the Game Boy named helloworld.gb

./gbdk\bin\lcc.exe -o helloworld.gb helloworld.c
Once the code had compiled, which literally took a second ⏱️. I then headed over to https://virtualconsoles.com/online-emulators/gameboy/ which is an online emulator for the Game Boy and loaded up my newly created ROM.

Voila!

12-year-old me would have been amazed!

2 thoughts on “Writing “Hello World” for a Nintendo Game Boy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s