Gameboy Hardware
CPU: 8-bit
Address Bus: 16-bit
Total Memory Addresses: 65,536 (0x10000) (64KB)
Why only 65536 addresses?
“The GameBoy contains an 8-bit processor, meaning it can access 8-bits of data at one time. To access this data, it has a 16-bit address bus, which can address 65,536 positions of memory” [1].
Memory Map
| Address Range (dec) | Address Range (hex) | Purpose of Memory |
| 0 -> 255 | 0x0000 -> 0x00FF (255 bytes) | Restart and Interrupt Vectors |
| 256 -> 335 | 0x0100 -> 0x014F (80 bytes) | Cartridge Header Area |
| 336 -> 16383 | 0x0150 -> 0x3FFF (16KB) | Cartridge ROM - Bank 0 (fixed) |
| 16384 -> 32767 | 0x4000 -> 0x7FFF (16KB) | Cartridge ROM - Switchable Banks 1-xx |
| 32768 -> 38911 | 0x8000 -> 0x97FF (6KB) | Character RAM (VRAM) |
| 38912 -> 39935 | 0x9800 -> 0x9BFF (1KB) | BG Map Data 1 (VRAM) |
| 39936 -> 40959 | 0x9C00 -> 0x9FFF (1KB) | BG Map Data 2 (VRAM) |
| 40960 -> 49151 | 0xA000 -> 0xBFFF (8KB) | Cartridge RAM (If Available) (WRAM) |
| 49152 -> 53247 | 0xC000 - 0xCFFF (4KB) | Internal RAM - Bank 0 (fixed) (WRAM) |
| 53248 -> 57343 | 0xD000 -> 0xDFFF (4096 bytes) | Internal RAM - Bank 1-7 (switchable - CGB only) |
| 57344 -> 65023 | 0xE000 -> 0xFDFF (7680 bytes) | Echo RAM - Reserved, Do Not Use |
| 65024 -> 65183 | 0xFE00 -> 0xFE9F (160 bytes) | OAM - Object Attribute Memory |
| 65184 -> 65279 | 0xFEA0 -> 0xFEFF (96 bytes) | Unusable Memory |
| 65280 -> 65407 | 0xFF00 -> 0xFF7F (128 bytes) | Hardware I/O Registers |
| 65408 -> 65534 | 0xFF80 -> 0xFFFE (127 bytes) | Zero Page (HRAM / HiRam) |
| 65535 | 0xFFFF (1 byte) | Interrupt Enable Flag |
OAM - Object Attribute memory (Sprites)
Size of memory: 160 Bytes
Number of Sprites: 40
Size of Sprites: 8x8 or 8x16
“On the Gameboy the OAM is a 160-byte long chunk of memory, and each sprite takes up 4 bytes which leaves just enough room for exactly 40 sprite.
We can not access it while the display is updating (Which is a lot of the time!). This is where the so-called Direct Memory Access (DMA) comes into play.” [2].
| Y | Location of Sprite on Screen from top to bottom |
| X | Location of Sprite on Screen from left to right |
| Tile Number | Tile in the tile-map to use to render this sprite |
| Flags | Flag values: 7: Render priority 6: Y flip 5: X flip 4: Palette number (GB Color only) 3: VRAM bank (GB Color only) 2: Palette number bit 3 (GB Color only) 1: Palette number bit 2 (GB Color only) 0: Palette number bit 1 (GB Color only) |
Hardware I/O Registers (0xFF00 -> 0xFF7F) (128 bytes)
| 0xFF42 | ScrollY |
| 0xFF43 | ScrollX |
| 0xFF44 | LY - LCDC Y-Coordinate (Read-only) |
| 0xFF45 | LYC - LY Compare (Read/Write) |
| 0xFF46 | DMA - DMA Transfer and Start Address (Write-only) |
| 0xFF47 | BGP - BG Palette Data (Read/Write) - Non CGB Mode Only |
| 0xFF48 | OBP0 - Object Palette 0 Data (R/W) - Non CGB Mode Only |
| 0xFF49 | OBP1 - Object Palette 1 Data (R/W) - Non CGB Mode Only |
| 0xFF4A | WindowY |
| 0xFF4B | WindowX |
| 0xFF4C | ?? |
| 0xFF4D | KEY1 - CGB Mode Only - Prepare Speed Switch |
| 0xFF4E | ?? |
| 0xFF4F | VBK - CGB Mode Only - VRAM Bank |
| 0xFF50 | Locks Bootrom |
| 0xFF51 -> 0xFF55 | LCD VRAM DMA Transfers (CGB only) |
| 0xFF56 | RP - CGB Mode Only - Infrared Communications Port |
| 0xFF57 -> 0xFF67 | ?? |
| 0xFF68 | BCPS/BGPI - CGB Mode Only - Background Palette Index |
| 0xFF69 | BCPD/BGPD - CGB Mode Only - Background Palette Data |
| 0xFF6A | OCPS/OBPI - CGB Mode Only - Sprite Palette Index |
| 0xFF6B | OCPD/OBPD - CGB Mode Only - Sprite Palette Data |
| 0xFF6C -> 0xFF6F | ?? |
| 0xFF70 | FF70 - SVBK - CGB Mode Only - WRAM Bank |
| 0xFF71 -> FF7F | ?? |
References: