AppStars

Tools that make a team fast: level editors, converters and table generators

Build notes from 2001 to 2005: the editors, converters and generators we built so games were made by tools, not hand-typed data, and what that taught us about speed.

In 2002, a level for a Game Boy Advance game was C source code. Every 8×8 tile, every palette entry, every collision rectangle and every point on an enemy's patrol route had to end up as a constant in a C array, compiled into the cartridge. You could type those arrays by hand, once. You couldn't change a level that way twenty times a day.

So alongside the engines, we built tools. Looking through the archive from those years, the tools are as substantial as the engines: GBAfool alone is about 8,100 lines of C++, roughly the size of the 2D engine it fed. These are our notes on what we built, and why the tools, more than any clever inner loop, decided how fast a game got made.

The problem

A handheld game has a content problem before it has a code problem:

  • Artists work in paint programs, not hex. Anything that makes them think about tile indices slows them down.
  • Video memory is tiny. The GBA keeps background tiles in a small block of video memory. A level drawn freehand can easily need more unique tiles than fit.
  • Designers need to place things. Enemies, their paths, collision walls and ladders all have positions that someone has to choose, try and change.
  • Engines need tables. A renderer with no divide instruction runs on precomputed lookup tables that someone has to generate, correctly, every time a format changes.

Each of those is a job for a program, not a person.

Architecture

By 2003 the pipeline from art to cartridge looked like this:

 paint program --(BMP layers)--> GBAfool (MFC + DirectDraw editor)
                                   - tile de-duplication with flips
                                   - palettes, collision rects and lines
                                   - enemy paths, drag-and-drop
                                   v
                         level01.c, level01_Layer0..3.c, *_CREATURE.c
                                   v
 3D Studio models --> model converter --> mod_*.c (vertex sets per frame)
 table generators --> reciprocal, division and trig tables (.raw / .c)
                                   v
               engine: level, background, sprite, animation and
               collision managers  -->  cartridge ROM
  • GBAfool, our level and sprite editor, written in C++ with MFC and DirectDraw. It imported layers from any paint program, turned them into tiles, and let you place characters on paths and draw collisions.
  • Model converters from 3D Studio exports into C modules the 3D engine could compile in, one module per asset.
  • Table generators: small Visual C++ console programs that wrote the engine's lookup tables, such as 32,742 reciprocals in fixed point.
  • "Thomas, the Engine That Could": our 2D engine, built from independent subsystems for collision, backgrounds, sound, memory, DMA lists, fixed-point maths, input, fonts, characters, AI state machines, physics, effects and animation.

Notes on the techniques

Tile de-duplication that understands mirrors

The GBA's background hardware can draw any stored tile flipped horizontally, vertically or both, using bits in the tile map. A level drawn by an artist is full of mirrored pieces: the left and right edges of a platform, the top and bottom of a pipe. If the tool treats those as different tiles, video memory runs out.

So GBAfool computed four keys for every 8×8 tile of the imported art: as drawn, flipped horizontally, flipped vertically and flipped both ways. Simplified, not the production code:

for each 8x8 tile t in the layer:
    for each stored tile s:
        if key(t)    == key(s): emit (s, no flip);       next t
        if keyH(t)   == key(s): emit (s, flip H);        next t
        if keyV(t)   == key(s): emit (s, flip V);        next t
        if keyHV(t)  == key(s): emit (s, flip H and V);  next t
    store t as a new tile; emit (t, no flip)

Artists didn't need to think about any of this. They drew in their own paint program, and the tool did the packing.

Export straight to C

The editor's job ended in C source that dropped straight into the game's build. It wrote one file per layer, with tile sets, screen maps, palettes, collision rectangles and lines and paths, and a top-level level file tying them together. An excerpt of real output from a test game:

const LEVEL_TYP LEVEL_level01=
{
    1,    /* num layers */
    default_Creatures_Palette,    /* char palette */
    default_Layers_Palette,    /* layer palette */
    {/* LAYERS[] */
        {/* LAYER 1 */
            1,/* numCHARs */
            level01_Layer0_CharDescList,/* Layer CHARs DESC list */
            0,/* num Collision Rects */
            level01_Layer0_BKG_RECTLIST,/* Collision Rects List */

Generating const C data, not a file format read at run time, had two benefits on a cartridge: the data stayed in ROM without being copied into scarce RAM, and the compiler checked every reference. If the engine's structures changed, the next export and build told you straight away.

Paths and collisions drawn, not typed

Characters were placed on paths in the editor by drag-and-drop. Paths were exported as lists of points, and the engine's level manager started each actor at the first point and moved it along the list. Collision walls and ledges were drawn as rectangles and lines over the art. That put the shape of a level, and the routes its enemies patrolled, in the hands of whoever was designing it.

Generators for anything computed

The 3D engine's lookup tables came from programs, not from a spreadsheet or a calculation someone did once by hand. When a table format changed, the generator changed, and the table was rebuilt. It sounds obvious; it's also the difference between a table you trust and one you're afraid to touch.

Proving the tools

The test of a toolset is how fast you can make something new with it. We ported DX-Ball to the Game Boy Advance in 20 hours, start to finish, specifically to prove the tools.

Two years later the same habit showed up in a programming test. Asked to build a small 2D platformer, we spent about three hours on the whole thing, and used our own level editor to collision-map the level with lines and boxes rather than hand-coding them. The notes we submitted listed what we'd do next and why.

By 2005, writing a real-time strategy prototype for phones, we built a map editor beside it: about 2,000 lines of C#, for a game of about 5,800.

Where AI fits

The paths drawn in GBAfool were game AI's input: patrol routes that enemies followed, authored by a designer instead of hard-coded by a programmer. That split, people shaping behaviour with a tool while the engine executes it, is the start of the AI thread in this series, which we pick up in Game AI before "AI".

Today the most important tools in our kit are AI coding agents. The principle hasn't changed. A tool is worth building, or adopting, when it removes a class of slow, error-prone work and leaves people free to make decisions. And like a level exporter, an AI agent's output only earns trust when something checks it: a compiler, a test suite or a review.

What it taught us

Tools are leadership in code form. A good editor sets the conventions for everyone who uses it: where assets live, how they're named, what a valid level looks like. Our engine and game folders followed one rule, one C module per asset, because the tools generated them that way.

The same years taught us to teach. We wrote in-house game-development course material and taught experienced programmers 3D games development. At THQ Studio Australia we built an MFC scene editor and a texture asset toolchain for console games. In each case, the measure of the work was how much faster other people could go, not how clever the tool was.

Why it still matters

Every client project has its own version of "levels as hand-typed C": a spreadsheet re-keyed into a system each week, a deployment that needs one person's memory, test data nobody can regenerate. Often the fastest way to speed up a project is to build the tool first. That's a big part of how we approach technical leadership, and you can see the original tools on the Game Boy Advance case study.

Bring us the hard problem.

A 45-minute discovery call with the engineer who'll build it.