Halfbrick Studios, 2001–2003
A real-time 3D engine for the Game Boy Advance, hand-written in ARM assembly.
We wrote a complete 3D engine for a 16.78 MHz handheld with no 3D hardware, plus the level editor and tools that fed it. Halfbrick Studios used it for technology demos it pitched to Activision, THQ and Electronic Arts. The same low-level discipline now runs AI on devices and IoT at the edge.
- Client
- Halfbrick Studios, which our founder co-founded in 2000
- Industry
- Games
- Services
- Real-time and low-level engineering, performance optimisation, developer tools
- Platforms
- Game Boy Advance (ARM7TDMI assembly and C); Windows tools in C++ and MFC
- Our role
- We designed and wrote the 3D engine, the 2D engine and the tools, and built the demos on them.
The challenge
The Game Boy Advance arrived in 2001 with a 16.78 MHz ARM7TDMI processor, 32 KB of fast on-chip memory, 256 KB of slower work RAM, a 240×160 screen and no 3D hardware at all. The processor had no floating point and no divide instruction. To win publisher deals, Halfbrick had to show that full 3D games could run on it, at speeds comparable to the PlayStation.
At 60 frames a second that leaves about 280,000 cycles per frame for logic, vertices and pixels. Code running from the cartridge sits on a slow 16-bit bus, so anything hot had to fit in those 32 KB.
An engine alone doesn't make a game, either. A handheld level was C source code, and every tile, collision box and patrol route had to become a constant in an array.
Our approach
We treated the frame as a budget. The hot path went into about 14,500 lines of hand-written ARM assembly, with the game code in C on top. Divides became tables, hot routines lived in fast memory, and every stage was timed on the hardware. Alongside the engine we built the tools, so content came from editors, not hand-typed numbers.
What we built
A software 3D pipeline in assembly
Vertices in 16.16 fixed point were transformed by the view matrix, then a single routine did back-face culling, z-clipping and off-screen rejection and computed each polygon's depth. A radix sort in assembly ordered the visible polygons far to near, the painter's algorithm, because there was no memory for a z-buffer. Each polygon was then drawn into a double-buffered 8-bit screen. Animated models were pre-baked vertex sets, one per frame, copied into place by DMA. The engine also handled collision detection, and a later version added skeletal animation.
A texture mapper with no loop
The span filler wrote its inner step out 120 times and jumped into the middle of the block with a computed branch, so a span costs no compare or branch per pixel. Textures were limited to 256×256 so both texture coordinates fit in one register and a single add stepped both. Each unrolled step was six instructions, so the jump offset was the span length times 24 bytes, built from two shifts and an add. The fast path wrote each texel to two pixels, because the screen memory only accepted 16-bit writes, trading horizontal detail for half the work, and the source keeps the more accurate version beside it.
No divides, and every byte placed
Edge slopes came from a generated table of 32,742 reciprocals in fixed point and a multiply. A file-naming rule and a custom linker script put the transform, cull, sort and fill routines in fast on-chip memory, big buffers in work RAM and tables in cartridge ROM. DMA did anything that only moved data.
Measured, one change at a time
We wrote a small timing library on the handheld's hardware timers, wrapped each pipeline stage with it and recorded every round of optimisation in the source, so nobody had to take a speed claim on trust. The polygon sort went from 9,158 ticks to 2,470 over four rounds, and polygon processing and fill from 24,400 to 8,422 over six.
The tools: GBAfool, converters and generators
GBAfool, our level and sprite editor, is about 8,100 lines of C++ with MFC and DirectDraw. It imported layers from any paint program, cut them into tiles, stored mirrored tiles only once, let designers place characters on paths and draw collisions, and exported everything as C that compiled straight into the game. A 2D engine, 3D model converters and table generators completed the kit. Porting DX-Ball took 20 hours.
The demos
On top of the engine we built recreations of Starfox and Croc levels, with Croc running at speeds comparable to the original PlayStation version; Omega, a fast 3D shoot-'em-up; and CloudKarts, a monster-truck game on texture-mapped terrain with three computer-driven trucks in a capture-the-flag mode.
Architecture
- Game code in CActors, state machines and levels
- TransformFixed-point vertices through the view matrix
- Cull and projectBack faces, clipping and depth in one pass
- Radix sortVisible polygons ordered far to near
- FillTextured, flat or sprite, into the back buffer
Every stage after the game code ran as assembly from on-chip memory.
Results
- 16.78 MHzARM processor, with no 3D hardware
- 3publishers pitched: Activision, THQ and EA
- 3.7×faster polygon sort, measured on the hardware timers
- 20 hoursto port DX-Ball and prove the tools
As a co-founder of Halfbrick Studios, I had the privilege of working alongside him during an era when technical ingenuity was everything. We pushed the absolute limits of Nintendo's handheld systems, extracting every ounce of performance from their ARM-based processors through meticulously handcrafted assembly language optimisations. What we achieved with such limited hardware resources was a testament to his exceptional technical craftsmanship, relentless curiosity and deep understanding of computer architecture.
Where others saw hardware limitations, he saw opportunities for innovation. A genuine technical visionary with an extraordinary ability to solve problems at the lowest level of computing while never losing sight of the bigger picture. The kind of engineer you want alongside you when you're attempting to achieve something others consider impossible.
Under the hood
Every cycle counted.
- ARM assembly
- C
- C++ and MFC
- DirectDraw
- Fixed-point maths
- Affine texture mapping
- Radix sort
- Lookup tables
- DMA
- IWRAM & EWRAM
- Hardware-timer profiling
Why it matters now
Running a model on a phone, glasses or a field device is the same problem in a new form: a fixed budget of cycles, memory and power. Quantised weights are fixed point by another name. That's the work behind our wearables and Edge AI and real-time and IoT services, such as our Edge AI smart-glasses prototype.
The tools taught us that building the tool first is often the fastest way to speed up a project, a large part of how we approach technical leadership. After Halfbrick, we led AI development on a console game at THQ: see console game AI for THQ.
What we'd do now
The hardware changed. The principles didn't.
- Profile before you optimise, and keep the numbers. Every speed-up in this engine was measured stage by stage. On a phone or an edge device today we'd start the same way: a trace of where the milliseconds and milliwatts go, before anyone touches the code.
- Write the trade-off down where the next engineer will see it. The fast texture mapper said it was less accurate. A quantised model, a cached result or a skipped check deserves the same honesty in the code and the docs.
- Decide where data lives on purpose. Fast memory is always scarce, whether it's 32 KB of on-chip RAM or a phone's neural-engine budget. Placement is a design decision, not something to leave to defaults.
Questions
Why write a 3D engine in assembly rather than C?
The compilers of the time couldn't match hand-scheduled code in the inner loops. Assembly let us control registers, unroll the span filler and keep hot code in fast on-chip memory.
Was the engine used in a released game?
It powered the technology demos Halfbrick Studios pitched to Activision, THQ and Electronic Arts, including Starfox and Croc recreations and CloudKarts.
How does this relate to on-device AI?
Both mean fitting heavy maths into a fixed budget of cycles, memory and power. Fixed point, lookup tables, memory placement and profiling carry straight over to running models on devices.
Related
The services behind this work, and more stories like it.
Services
Case studies
THQ Studio Australia, 2002–2004A companion that follows the player. Lead AI development for Goddard, the robot dog in a Jimmy Neutron console game on PS2, Xbox and GameCube.
Halfbrick, 2000Online high scores in 2000. The Void, a Java applet shoot-'em-up offered to website owners, with prizes based on players' scores.
Knowby R&DHands-free help, with no cloud. An R&D prototype: Gemma 4 E2B running on the phone paired with Ray-Ban Meta glasses, reading work instructions aloud.
Bring us the hard problem.
A 45-minute discovery call with the person who'll design and build it. Clear scope, regular showcases, honest advice, and no handovers to people you've never met.