Explaining VRAM and tile limits in GB Studio.

How VRAM and tile limits work in GB Studio, and how you can push them further.

Introduction.

Tile limits in GB Studio can be mysterious things. You might have noticed that they are not hard limits. It is technically possible to use more than 192 sprite tiles in a scene, or more than 128 background tiles. That’s because tile limits are simply suggestions based on how VRAM is organised in GB Studio. This guide explains exactly how tile limits and VRAM work, and aside from being interesting, might help you squeeze a few more graphics into your scenes.

About sprite tile values.

In VRAM and in this guide, one sprite tile refers to one single 8x8 tile. In the GB Studio editor however, one sprite tile refers to two 8x8 tiles. Halve the values in this guide to get GB Studio editor values. For example, if this guide says 192 sprite tiles, the GB Studio editor would display that as 96 sprite tiles. This only applies to sprite tiles and not any other tiles.

What is VRAM?

VRAM stands for video random access memory. When running a GB Studio scene, all of the tiles in the scene must be loaded into VRAM at once. That includes sprite, background and text tiles. The Game Boy can keep up to a maximum of 384 tiles in VRAM at once. All of the sprite, background and text tiles in a scene must fit in said 384 tiles of VRAM, which is why there are tile limits per scene in GB Studio.

Some emulators allow you to visualise VRAM in real time while playing a game, which is very helpful for understanding how it works. It's also helpful for diagnosing any graphics issues caused by tiles overlapping in VRAM.

I recommend using the BGB emulator to visualise VRAM. Run your game in BGB, right click the window, then go to Other -> VRAM viewer -> Tiles. You can see how tiles are loaded into VRAM and exactly how much space you have for additional tiles in a scene. VRAM is not cleared between scenes, so it can be difficult to tell exactly what is loaded in the current scene. It may be helpful to export a ROM that starts in the scene you want to inspect.

A GB Studio game running in BGB with the VRAM viewer open.

How does GB Studio use VRAM?

Sprite tiles are added in the positive direction from index 0. They will eventually hit either background tiles or text tiles, which is why there is a sprite tile limit.

Background tiles are added in the positive direction from index 256. After 128 tiles, further background tiles are added in the negative direction from index 191. Each background tile over 128 reduces the sprite tile limit as they begin to grow towards the sprite tiles.

Text tiles always occupy index 192 to index 255 with a fixed size of 64 tiles. The 12 tiles of the textbox frame are always at index 192 to index 203. The 52 tiles of the text buffer are always at index 204 to index 255.

This image contains basically everything you need to know about VRAM. Note that the layout matches the BGB VRAM viewer.

This image overlays the VRAM example from the start of this guide onto the above diagram.

Why is this information helpful to know? Well, you can bend the rules a little bit by filling empty VRAM space. If you are using less than 128 background tiles, you can use up to 192 sprite tiles. If you also aren’t using text, you can also overlap the text area to use up to 256 sprite tiles. You can also add additional background tiles beyond 192 if you sacrifice one sprite tile for each one.

Extra notes.

Here are some extra notes that didn't fit elsewhere in the guide.

The Game Boy Color actually has twice the VRAM of the original Game Boy. That's what the second empty bank is in the BGB VRAM viewer. Despite this, Color mode in GB Studio doesn’t make use of this additional VRAM for more sprite and background tiles. The only additional VRAM used by Color mode is to double the size of the text buffer, allowing for twice as many text tiles to be written on screen at once. Beside the text buffer, everything is the same as in this guide.

Chris Maltby, the creator of GB Studio, recently teased a new Color Only mode that will make full use of the second bank of VRAM, allowing for more sprite and background tiles. If this new mode is released, it will use its own unique VRAM layout, so I will write another guide for it.

Logo scenes use a different VRAM layout to all other scene types, so this guide doesn’t apply to them.

Guide by Shin. Thanks to Toxa for his detailed explanations that served as a basis for this guide. Last updated 31/3/2024.

Read these next.