1-bit
- Number of Values: 21 = 2 (Typically 0 or 1)
- Common Uses: Flags (on/off, true/false), simple masks.
- GBA Context: Individual bits within hardware registers often act as flags (e.g., enabling/disabling features in REG_DISPCNT).
A bit is the most basic unit of data in computing, representing either a 0 or a 1. Bit depth refers to the number of bits used to represent a single piece of data. The more bits used, the more distinct values can be represented.
Understanding bit depths is crucial in systems like the Game Boy Advance because hardware components (like graphics, sound, memory registers) often expect data in very specific bit sizes. Using the correct bit depth affects memory usage, performance, and correctness.
Bit Depth | Common Name(s) | Number of Values | Typical GBA Uses / C Type |
---|---|---|---|
1-bit | Bit, Flag | 2 | Flags in registers |
4-bit | Nibble | 16 | Hex digit, 4bpp palette index |
8-bit | Byte | 256 | char , u8 /i8 , 8bpp palette index |
16-bit | Half-Word, Short | 65,536 | short , u16 /i16 , Hardware Registers, Mode 3 Color |
24-bit | - | ~16.7 Million | Source Art Color (RGB888) |
32-bit | Word, Long | ~4.3 Billion | int , long , u32 /i32 , CPU Registers, Memory Addresses, DMA |
Choosing the correct data types (which correspond to bit depths) in your C code is important for GBA development. Using a short
(16-bit) to write to a 16-bit hardware register is more direct and often required compared to using an int
(32-bit). Understanding that Mode 3 color is 15-bit helps you pack RGB values correctly into a short
. Knowing the CPU is 32-bit informs you about efficient data handling and memory addressing capabilities. Being aware of these details helps you write code that works correctly and efficiently on the GBA hardware.