

On the Gameboy the OAM is a 160-byte long chunk of memory, and each sprite takes up 4 bytes which leaves just enough room for exactly 40 sprites. All this really is, is a memory location that is used to store the information of each sprite. To render sprites we need to utilize what is referred to as the “OAM”, or “Object Attribute Memory”. Every sprite has a number associated with it which corresponds to one of the tiles in our tile map.

The sprites actually get their image from a larger image split up into either 8x8 or 8x16 “tiles”, we will refer to this as a “tile map”. Pretty small right? Due to these limitations you have to form larger sprites by stitching numerous small sprites together. On the Gameboy sprites are limited to two possible sizes, one being 8x8, the other being 8x16. The same is true for the Gameboy, with one exception being the size of the image. For those unfamiliar with the term, a sprite is essentially just a 2D image of arbitrary size, in the context of games it is generally used to refer to entities, moving objects, etc. If you have toyed with game development in the past, chances are you know what a “sprite” is. So without further ado, lets get started. If you require a working example of the code covered in this article, feel free to check out my most recent homebrew game Exeman on github, which I wrote for Ludumdare 38. Using the all-mighty Gameboy pandoc as a reference, I recommend you do the same. And various reverse-engineering tools such as Radare2, to disassemble the Megaman rom. The tools used are gb-convert, my own tool to convert images to data supported by the Gameboy. The code in this article is written specifically for RGBASM. Should anyone feel stuck or confused about anything, feel free to contact me on IRC or twitter and I will help to the best of my ability.

Many topics are only glanced at because teaching them is out of the scope of this article, other such articles exist and I recommend doing your research beforehand. This article does not cover the basics of Gameboy homebrew, and it assumes you have at least a little understanding of assembly and/or the Gameboy, etc. By the end of this article you should have a strong understanding of not only what a DMA transfer is, but how to use them in your own homebrew games. We will be going over some assembly code examples, as well as a bit of disassembled code from one of my favorite Gameboy games, Megaman. The purpose of this article is to explain DMA transfers on the Gameboy, specifically how to use them.
