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 Color Only mode.
GB Studio 4.0 introduced a new Color Only mode that makes use of the extra VRAM bank that the GBC has access to. VRAM is handled differently in this mode, so most of this guide does not apply to games in Color Only mode. A separate guide may address this in the future.
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.
GB Studio 4.0 and up allow you to visualise VRAM in real time while playing your 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. Open the Debugger pane at the bottom of the Game World window and start the debugger.
Some emulators also allow you to visualise VRAM, useful if you are using an earlier version of GB Studio or want a more detailed view. I recommend using the BGB emulator. 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.
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.
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.
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 20/6/2024.