This article welcomes anyone that wants to help with translations or contributions.
The internal design of the Game Boy Advance is quite impressive for a portable console that runs on two AA batteries.
This console will carry on using Nintendo’s signature GPU. Additionally, it will introduce a relatively new CPU from a UK company that will surge in popularity in years to come.
Most of the components are combined into a single package called CPU AGB. This package contains two completely different CPUs:
Note that both CPUs will never run at the same time or do any fancy co-processing. The only reason for including the very old Sharp is for backwards compatibility.
Before ARM Holdings (currently “Arm”) became incredibly popular in the smartphone world, they licensed their CPU designs to power Acorn’s computers, Apple’s Newton, Nokia’s phones and the Panasonic 3DO. Nintendo’s chosen CPU, the ARM7TDMI, is based on the earlier ARM710 design, and includes:
Moreover, this core contains some extensions referenced in its name (TDMI):
The inclusion of Thumb in particular had a strong influence on the final design of this console. Nintendo mixed 16-bit and 32-bit buses between its different modules to reduce costs while providing programmers with the necessary resources to optimise their code. Usable memory is distributed across the following locations:
Although this console was marketed as a 32-bit system, the majority of its memory is only accessible through a 16-bit bus, meaning games will mostly use the Thumb instruction set to avoid spending two cycles per instruction fetch. Only critical sections should use the ARM instruction set.
You’ll be surprised that there is no software implemented to detect whether the cartridge inserted is a GB or GBA one. Instead, the console relies on hardware switches: A shape detector effectively identifies the type of cartridge and then only passes power through the required bus.
Before we begin, you’ll find the system a mix between the SNES and the Game Boy, the graphics core is still the well-known 2D engine called PPU. I recommend reading those articles before continuing since I’ll be revisiting lots of previously-explained concepts.
Compared to previous Game Boys we now have a colour LCD screen that can display up to 32,768 colours (15-bit). It has a resolution of 240x160 pixels and a refresh rate of ~60Hz.
We have the following regions of memory in which to distribute our graphics:
If you’ve read the previous articles you’ll find the GBA familiar, although there is additional functionality that may surprise you, and don’t forget that this console runs on two AA batteries.
I’m going to borrow the graphics of Sega’s Sonic Advance 3 to show how a frame is composed.
GBA’s tiles are strictly 8x8 pixel bitmaps, they can use 16 colours (4bpp) or 256 colours (8bpp). 4bpp tiles consume 32 bytes, while 8bpp ones take 64 bytes.
Tiles are grouped into charblocks. Each block is reserved for a specific type of layer.
Because each charblock is designed to fit in 16 KB of memory, up to 256 8bpp tiles or 512 4bpp tiles can be stored per block. There are six charblocks allocated, which combined require 96 KB of memory: The exact amount of VRAM this console has.
Four charblocks are used for backgrounds and two are used for sprites.
The PPU can draw up to four background layers. The capabilities of each one will depend on the selected mode of operation:
Each layer be up to 512x512 pixels wide. If it’s an affine one then it will be up to 1024x1024 pixels.
The size of a sprite can be up to 64x64 pixels wide, yet for having such a small screen they will end up occupying a big part of it.
If that wasn’t enough, the PPU can now apply affine transformations to sprites!
Sprite entries are 32-bit wide and their values can be divided in two groups:
As always, the PPU will combine all layers automatically, but it’s not over yet! The system has a couple of effects available to apply over these layers:
On the other side, in order to update the frame there are multiple options available:
Sometimes we may want to compose a background from which the tile engine won’t be able to draw all required graphics. Now, modern consoles addressed this by implementing a frame-buffer architecture but this is not possible when there’s very little RAM… Well, the GBA happens to have 96 KB of VRAM which is enough to allocate a bitmap with the dimensions of our LCD screen.
Good news is that the PPU actually implemented this functionality by including three extra modes, these are called bitmap modes:
The reason for having two bitmaps is to enable page flipping: Drawing over a displayed bitmap can expose some weird artefacts during the process. If instead we manipulate another one then none of the glitches will be shown to the user. Once the second bitmap is finished the PPU can be updated to point to the second one, effectively swapping the displayed frame.
Overall it sounds like a cutting-the-edge feature, however most games held on to the tile engine. Why? Because in practice it costs a lot of CPU resources.
You see, while using a tile engine the CPU can delegate most of the computations to the graphics chip. By contrast, the frame-buffer system that the PPU provides is limited to only displaying that segment of memory as a single background layer, that means no more individual affine transformations, layering or effects unless the CPU computes them. Also, the frame-buffer occupies 80 KB of memory, so only 16 KB (half) are available to store sprite tiles.
For this reason, these modes are used exceptionally, such as for playing motion video (Game Boy Advance Video completely relied on this) or rendering 3D geometry with the CPU.
The GBA features a 2-channel sample player which works in combination with the legacy Game Boy sound system.
Here is a breakdown of each audio component using Sonic Advance 2 as example:
The new sound system can now play PCM samples, it provides two channels called Direct Sound where it receives samples using a FIFO queue (implemented as a 16-byte buffer).
Samples are 8-bit and signed (encoded in values from -128 to 127). The default sampling rate is 32 kHz, although this depends on each game: since a higher rate means a larger size and more CPU cycles, not every game will spend the same amount of resources to feed the audio chip.
DMA is essential to avoid clogging CPU cycles. Timers are also available to keep in-sync with the queue.
While the Game Boy subsystem won’t share its CPU, it does give out access to its PSG. For compatibility reasons this is the same design found on the original Game Boy. I’ve previously written this article that goes into detail about each channel in particular.
The majority of GBA games used it for accompaniment or effects. Later ones will optimise their music for PCM and leave the PSG unused.
Finally, everything is automatically mixed together and output through the speaker/headphone jack.
Even though the GBA has just two PCM channels, some games can magically play more than two concurrent samples. How is this possible? Well, while only having two channels may seem a bit weak on paper, the main CPU can use some of its cycles to provide both audio sequencing and mixing (that should give you an idea of how powerful the ARM7 is!)
Some games took the PCM-PSG duality further and ‘alternated’ the leading chip depending on the context.
In this game (Mother 3), the player can enter two different rooms, one relatively normal and the other with a nostalgic setting. Depending on the room the character is in, the same score will sound modern-ish or 8bit-ish.
Programming for the GBA was similar to the SNES with the addition of all the advantages of developing games in the early 2000s: Standardised high-level languages, better compilers, faster RISC CPUs, non-proprietary computers for development, comparatively better documentation and… Internet access!
Games are mostly written in C with critical sections in assembly (ARM and Thumb) to save cycles. Nintendo provided a SDK with libraries and compilers. BIOS calls were available to simplify I/O access and reduce cartridge size.
Game data is stored inside a new proprietary cartridge called GamePak.
While the ARM7 has a 32-bit address bus, there are only 24 address lines connected to the cartridge. This should mean that up to 16 MB can be accessed on the cartridge without needing a mapper, however, the official docs state that 32 MB of cartridge data are mapped in memory. So what’s happening here? The truth is, the Gamepak uses 25-bit addresses (which explains that 32 MB block) but its bottommost bit is fixed at zero, so the only 24 remaining bits are set. This is how Gamepak addressing works.
Now, does this mean that data located at odd addresses (with its least significant bit at ‘1’) will be inaccessible? No, because the data bus is 16-bit: For every transfer, the CPU/DMA will fetch the located byte plus the next one, allowing to read both even and odd addresses. As you can see, this is just another work of engineering that makes full use of hardware capabilities while reducing costs.
In order to hold saves, Game Paks could either include:
The famous Game Boy Link Cable provided multi-playing capabilities. Additionally, the cable has a special feature internally known as Multi-boot: Another console (either GBA or GameCube) can send a functional game to the receiver’s EWRAM, then the latter would boot from there (instead of needing a cartridge).
In general terms, the usage of proprietary cartridges was a big barrier compared to the constant cat-and-mouse game that other console manufacturers had to battle while using the CD-ROM.
To combat against bootleg cartridges (unauthorised reproductions), the GBA’s BIOS incorporated the same boot process found in the original Game Boy.
As solid state storage became more affordable, a new type of cartridge appeared on the market. Flashcards looked like ordinary Game Paks but had the addition of a card slot (SD, MiniSD, MicroSD or whatever) which enabled to run game ROMs. The concept is not new actually, developers have internally used similar tools in order to test their games on a real console (and manufacturers provided the hardware to enable this).
However, commercial availability of these cards proved to be a grey area: Nintendo condemned its usage due to enabling piracy where as some users defended that it was the only method for running Homebrew (programs made outside game studios and consequently without the approval of Nintendo). After Nintendo’s legal attempts, these cartridges were banned in some countries (like in the UK) nonetheless they still persisted worldwide.
This article is part of the Architecture of Consoles series. If you found it interesting please consider donating, your contribution will be used to get more tools and resources that will help to improve the quality of current articles and upcoming ones.
A list of desirable tools and latest acquisitions for this article are tracked in here:
## Interesting hardware to get (ordered by priority) - Any Dev kit (only if found at a reasonable price) ## Acquired tools used - Original GBA (£40) - The two games analysed in the article (£20)
Alternatively, you can help out by suggesting changes and/or adding translations.
Always nice to keep a record of changes.
## 2020-09-19 - Corrected grammar and added content, thanks @dpt - Expanded section about gamepak's 25-bit addressing ## 2020-08-22 - Clarified tile section ## 2019-12-09 - Even better Thumb explanation. - Added more audio info. ## 2019-10-03 - Improved Thumb explanation ## 2019-09-17 - Added a quick introduction ## 2019-09-01 - Added my GBA 🧐 ## 2019-08-26 - Used better wording on some explanations ## 2019-08-19 - Corrected wee mistakes ## 2019-08-18 - Ready for publication