Game Boy Coding with Chris! Pt. 1 – Writing to the Screen

arcadeattackAA Articles, Coding with ChrisLeave a Comment

So, not content with being a thoroughly gifted comic book artist and writer, our Chris is now honing his coding skills on retro consoles and computers! Here’s how to get those first precious words on to a Game Boy screen. Stay tuned for much, much more in the coming months!

 

When I was a kid, I used to love my Game Boy. This was one of the best handheld devices ever made (truth – Ed). It was a faithful companion on car trips and as I sat in my bedroom completing Super Mario Land for the hundredth time. In this new series I look at how the budding retro programmer can begin to code their own games for this wonderful piece of retro gaming history.

These tutorials are coded in C, this is a high level language which is close to English and is one of the most useful languages to learn when beginning to code for Retro machines. If you are new to the C language there are some fantastic primers available on YouTube. After watching this you will have a good working knowledge of the language.

 

Things you will Need

 

Getting Started

The object of this tutorial is just to get a simple “Hello World” message placed on the screen.

First, extract the files of the Game Boy Development Kit to a suitable location. On my system, I have extracted this to the root of my C drive.

Next we are going to write some code in Visual Studio Code. I like to organise my projects in folders, so I created a folder called Gameboy Programming and opened this in Visual Studio.

I created a new .c file called HelloWorld.c

 

Writing the Code

 

 

The first few lines are include statements. The first is a call to the library within the Gameboy Development Kit and the second is a call to the standard Input/Output library in C.

We then create our main function. This is where the program will execute from.

We then call a C function which will print a string to the screen.

 

Creating the Make File

In order to compile the code we have just written we need to craft a make file. This is nothing too scary and comprises of two lines.

Create a new file in your folder and call it Make.bat. Copy the following lines into it and save.

 

 

In order to run this file, go to the Terminal section of Visual Studio Code, and type .\Make.bat. This will run the file and create the Game Boy file which we need to run on the emulator.

 

 

When we open our Emulator and run the file we should see:

 

 

Chris

 

And there you have it! If you’ve followed Chris’ tutorial you can truly say you’re a Game Boy programmer! Well, sort of. Be sure to bookmark our homepage or follow us on social media to find out more!

 

 

 

Leave a Reply

Your email address will not be published.