This is a collection of simple examples for learners of assembly for the Nintendo Game Boy. They are meant to be primarily single-file examples with minimal dependencies which can be built easily to demonstrate commonly used hardware features of the platform. These are not meant to be good examples of how to structure/build complex projects nor are they meant to be comprehensive tutorials.
I hope someone finds them useful!
A simple batch file (Windows) and bash script (GNU/Linux) are provided for quick conversion/assembly/linking/fixing of the examples. They require RGBDS to be accessible, either installed somewhere in the path or copied locally. Please see the RGBDS installation instructions for more information on installing RGBDS.
To build an example, navigate to a given example's directory, such as /src/background-tile
in a terminal, and run:
- Windows:
..\build.bat background-tile.asm
- Linux:
../build.sh background-tile.asm
The example should assemble/link/fix, creating a ready-to-run ROM. Symbol and map files will also be generated alongside the ROM file. Some examples include PNG assets which will be converted to 2bpp binary files and/or tilemaps.
- Pandocs - The main resource for details on the Game Boy hardware
- hardware.inc - The repository for the hardware.inc file (which still gets updates!)
- GB ASM Tutorial - A modern and thorough tutorial teaching Game Boy assembly in much greater detail than these examples ever will
- Awesome Game Boy Development - A curated list of awesome resources for Game Boy development
Name | Description | Screenshot |
---|---|---|
background-tile | Show a single background tile | |
background-tilemap | Show a background tilemap | |
background-fullscreen | Show a fullscreen background image (360 unique tiles) | |
sprite | Show two sprites manually copied to OAM RAM | |
oamdma | Show 40 sprites copied using OAM DMA | |
vblank | Use the vblank interrupt to limit main loop speed with an animation | |
joypad | Poll the joypad and display the button states | |
grid-collision | Perform simple collision on a grid |
The code in this repository is licensed under the CC0 license. To the extent possible under law, all copyright and related or neighboring rights to code presented within simple-gb-asm-examples have been waived. This work is published from Canada.
The majority of the assets in this repository are licensed under the CC0 license. Assets not covered by this license are covered by a less permissive CC license, with their licensing information provided in the source file where they are included.