Skip to content

GBA tile worlds

Before the DS, the main-series games were 2D: the Game Boy and Game Boy Color for the first two generations, the GBA for the third. Their worlds are built from small square tiles on a few layers, and the DS’s 2D engines are built on the same model. This page explains how a GBA world is drawn, how the Game Boy differs, and how PokeLoom draws the same thing as its second field style. What a creator makes is on The tile-map style; the DS’s 2D hardware is on The 2D engines.

The GBA’s screen is 240 × 160 pixels. Its picture is made of tiles: 8 × 8 pixels, 16 colours each (one of them clear), taken from a palette of 16 colours that the tile’s map entry names. A tile can be flipped across and down for free, so a symmetric shape is stored once.

Maps are not built from tiles directly. They are built from metatiles: 16 × 16 blocks of four tiles in each of two halves, a bottom half and a top half. A metatile is the unit a map cell holds, the unit a character walks, and the unit a mapper places. The tiles and metatiles come in tileset pairs: one general set shared by many maps (grass, paths, water, trees) and one for an area (a town’s houses, a cave’s walls).

Each map cell is a small number that packs the metatile, whether the cell is solid, and its height level. Each metatile carries a behaviour (grass, water, a ledge, a door, ice) and a layer type that says where its two halves are drawn.

The GBA has four background layers with priorities, and sprites that sit between them. A field uses three layers for the map and one for text and windows:

Layer Holds
Top the parts that should cover characters: a tree’s crown, a roof’s edge
Middle the ordinary ground, and what characters stand in front of
Bottom ground under everything, for metatiles whose both halves sit under characters
Window the text box and menus

Characters are sprites drawn between the middle and top layers. A metatile’s layer type decides whether its top half goes over the characters (a tree they walk behind) or under them (a flat rug drawn in two layers). Among characters, the one lower on the screen is drawn in front. On a bridge, some height levels lift characters above the top layer so they walk over it.

Nothing here needs a depth buffer: “behind” is a choice of layer, made once per metatile.

The layers are larger than the screen and wrap around. The camera is fixed over the player and moves by changing each layer’s scroll position, three numbers a frame. When the player steps into a new cell, the game writes the row or column of metatiles that comes into view at the far edge. Outside a map, a small border pattern repeats and cannot be entered. Where two maps join, the game copies the neighbour’s edge in, so walking from one map into the next needs no load; the view does not change.

Characters walk a cell in sixteen frames at one pixel a frame, and run or surf at twice that.

Water ripples, flowers sway and waterfalls fall without any sprites. Each tileset has a routine that, every few frames, copies the next frame’s pixels over a fixed range of tile numbers in video memory. Every place on the map that uses those tiles changes at once, for the cost of one small copy.

A palette is only a few colours, and every tile that names it changes when it changes. The games use that for effects that would otherwise need a new picture:

  • Weather colour maps. A drought brightens and warms every palette; a shaded, overcast map darkens them.
  • Fades. Stepping each palette toward black or white.
  • Reflections. A character over still water or a polished floor gets a second sprite: the same frame, flipped upside down, in a lighter palette, at the lowest priority, so the layers above it decide where it shows.
  • Fog. A see-through layer blended over the map.

The Game Boy Color games of generation 2 go further: they keep a set of palettes for each environment and each part of the day (morning, day, night, and a dark set for caves), swap the set with a fade when the hour passes into the next part, and give roofs their own day and night colours. That is their day and night: palettes by time, with no lighting at all.

The Game Boy draws exactly what the GBA draws, with less: a 160 × 144 screen, tiles of 2 bits (four shades), one background plane, one window plane for text, and 40 sprites. The original Game Boy shows four greys; the Super Game Boy adds palettes chosen per screen; the Game Boy Color gives each tile one of eight four-colour palettes. A sprite can be flagged to go behind the background, which is how the lower half of a character disappears in tall grass.

The GBA’s model is the DS’s 2D model: the same tile format, the same map entry, 16 palettes of 16 colours, layer priorities and sprite rules. So PokeLoom draws its tile-map style with the DS’s 2D engine, not as flat polygons on the 3D engine. The comparison was clear: 2D costs a few kilobytes of maps and three scroll registers a frame, is exact on desktop and DS by the 2D rule, and leaves the 3D engine and its video memory free; flat 3D would take hundreds of polygons and most of the texture memory and could never be pixel-exact.

As built:

  • The field fills the DS’s top screen (256 × 192) with three map layers and a window layer. [world] picture frames a smaller picture, such as the GBA’s 240 × 160, centred with a black border, with the text box and menus kept inside it.
  • The world’s logic is shared with the 3D style and runs 30 times a second; the tile field draws at 60, placing characters and the camera half a step on between world frames, which gives the GBA’s one and two pixels a frame exactly.
  • A tile map is an ordinary map folder: map.toml with style = "tiles", the cells in Tiled, tilesets of tiles, palettes and metatiles with their behaviours and layer types, and animations as data.
  • Heights become the engine’s heights: the GBA’s “joins every level” cell (stairs between floors) and its bridge cells with two floors are cell kinds of the one world.
  • Scripts, battles, menus, saves and the bag are the engine’s own and cannot tell the two styles apart.

Emerald, imported from its decompilation into a creator’s private project, is the proof; its towns are compared with the decompilation’s own build picture for picture. An original generated tileset is what the engine’s tests use.

A game drawn in this style on PokeLoom runs on the DS and desktop and may use the DS’s whole 2D hardware. Built (plan 37):

  • 256-colour layers. With the 3D engine idle, its video memory holds 256-colour tiles and extended palettes: each layer can use 16 palettes of 256 colours, so set pieces can have soft gradients the GBA could not show.
  • Pictures as tilesets. A tileset or a large set piece can be any PNG. The build cuts it into tiles, keeps each repeated tile once (with flips), gives each picture a palette and reports each map against its budget. A set piece’s upper rows go on the top layer so people walk behind a roof.
  • Reflections, shadows and hovering as sprites, and weather particles over the tile map.

Planned (plan 37): a tile cache that streams tiles as the camera moves, so a map’s tile pool can be any size and the limit is what one view shows; set pieces as large sprites that can move and fade.

Planned (plan 24): weather colour maps (drought, shade) and fog as a blended layer.

Planned (plan 35): the Game Boy view as a mode of the same tile-map style, not a third renderer. A 160 × 144 view inside the top screen with a border picture; 2-bit tiles written as 4-bit tiles at import; the “behind the background” sprite flag as a second layer of the same map; palette models for the original four greys, the Super Game Boy, the Game Boy Color, and generation 2’s palette sets by environment and period, which are the 2D form of light tables.

Planned (plan 24, plan 35): single-screen desktop windows of the GBA’s and the Game Boy’s sizes, like the wide desktop canvas.

The 3D field and the tile-map field are two ways to draw the same world. Cells, behaviours, heights, people, warps, scripts and battles are one model; only the drawing differs. A GBA-style game and a DS-style game are two settings of one engine, and the Game Boy is a set of values in the tile style.