GB101:Introduction to the Gameboy Advance

From NYC Resistor Wiki
Jump to navigation Jump to search
GB101 Class Notes
Sections
  1. Home
  2. Installing Gameboy Development Tools
  3. Introduction to the Gameboy Advance
  4. Hello Background
  5. Working with Palettes
  6. Tiles and Background Maps
  7. Sprites
  8. Scrolling Backgrounds
  9. Collision Detection
  10. Fixed point math
  11. Affine Sprites
  12. Sound
  13. Where do I go from here?

The Processor[edit]

The GBA uses a 16mhz 32bit ARM7TDMI processor. The CPU is RISC, so instructions are simple and generally take one cycle. The processor has a 16bit and 32bit instruction mode, and you have to switch from one to the other. We'll be telling our compiler to use both and handle these switches automatically.

The Memory[edit]

Gbamem.gif

There are three primary segments of general use memory.

Internal Working RAM (iwram)[edit]

32KB of fast RAM. 8, 16, 32 bit reads/writes allowed. Single cycle access. Starts at 0x30000000.

External Working RAM (ewram)[edit]

256KB of RAM. 8, 16, 32 bit reads/writes allowed. Two cycle access. Starts at 0x20000000.

ROM[edit]

Up to 32MB. This is where the code lives. Three cycles for random access, a single cycle for sequential access. It's actually faster to load images out of ROM than ewram. Starts at 0x80000000.

The Registers[edit]

The register space starts at 0x40000000 and is where we'll be communicating between various components (CPU, DMA, etc).

The Video[edit]

Access to the video is done via a memory mapped area. There are various modes that change the locations and behaviors of video memory. The main video memory area starts at 0x6000000.

Mode 3[edit]

This is the easiest mode. Each 16-bit value in the memory area starting at 0x60000000 represents a pixel. You can just write color values to memory like an array.

Mode 4[edit]

This is similar to mode 3, except we use 8-bit indexes into a 256 color palette instead of 16-bit color values. If you've ever done any VGA graphics coding in MS-DOS then you'll be familiar with this. Because you're only using 8-bits you can have two screens in memory at the same time and switch between them. This allows you do to drawing off-screen and switch once you're done. This is called double buffering.

Mode 5[edit]

This is just like Mode 3, but at half resolution so you can do double buffering.

Mode 0,1,2[edit]

These are the tiled modes. In tiled modes each value in the memory represents a 8x8, 16x16 or 32x32 tile. The number of tiles you can have varies depending on their size and the mode you're using. The tiles live in one area of video memory, and the map of which tiles go where live in another. These tiles are used to make up the background. You get to have various layers of background each of which can be scrolled, stretched and/or rotated depending on the specific mode you're in.

Sprites[edit]

All modes also get sprites. These sprites have a separate 256-color palette, giving you access to 512 total colors. The amount of memory available for sprites varies depending on the mode (16KB in 3,4,5 and 32KB in 0,1,2). You can have 128 sprites on-screen at a time. Sprite graphics are stored at 0x6010000, and the sprite locations and data are stored at 0x7000000.

The Audio[edit]

The Controller[edit]