Skip to content

Latest commit

 

History

History
86 lines (54 loc) · 3.1 KB

File metadata and controls

86 lines (54 loc) · 3.1 KB

Hello World!

In this lesson, we will begin by assembling our first program. The rest of this chapter will be dedicated to explaining how and why it works.

Note that we will need to type a lot of commands, so open a terminal now. It's a good idea to create a new directory (mkdir gb_hello_world, for example, then cd gb_hello_world to enter the new directory).

Grab the following files (right-click each link, "Save Link As..."), and place them all in this new directory:

Then, still from a terminal within that directory, run the following three commands.

:::tip Convention

To make it clear where each command begins, they are preceded by a $ symbol. However, do not type it when entering them in your shell!

:::

$ rgbasm -o hello-world.o hello-world.asm
$ rgblink -o hello-world.gb hello-world.o
$ rgbfix -v -p 0xFF hello-world.gb
<style> .box.danger ol { list-style-type: symbols(fixed "✗" "✓" "✓"); } </style>

:::danger Warning

Be careful with arguments! Some options, such as -o here, use the argument after them as a parameter:

  1. rgbasm -o hello-world.asm hello-world.o won't work (and may corrupt hello-world.asm!)
  2. rgbasm hello-world.asm -o hello-world.o will work

If you need whitespace within an argument, you must quote it:

  1. rgbasm -o hello world.o hello world.asm won't work
  2. rgbasm -o "hello world.o" "hello world.asm" will work

:::

It should look like this:

<script id="asciicast-weljUlcp1KC5GqS9jqV62dy5m" src="https://asciinema.celforyon.fr/a/weljUlcp1KC5GqS9jqV62dy5m.js" async></script>

(If you encounter an error you can't figure out by yourself, don't be afraid to ask us! We'll sort it out.)

Congrats! You just assembled your first Game Boy ROM! Now, we just need to run it; open Emulicious, then go "File", then "Open File", and load hello-world.gb.

You could also take a flash cart (I use the EverDrive GB X5, but there are plenty of alternatives), load up your ROM onto it, and run it on an actual console!

Picture of the Hello World running on a physical DMG

Well, now that we have something working, it's time to peel back the curtains...

:::challenge Challenge!

When you see this box, a small challenge is available for you to try out. It can include questions or a small programming challenge. This is to help you understand the underlying material!

For educators, these can be used in conjunction with learning materials.

  1. Your current challenge is to get the hello world shown above!
Answer (Click me!)

This is where answers for the challenges will be placed!


:::