A high-performance Game Boy Advance emulator written in modern C++ (C++20), utilizing SDL2 for rendering and input. This project implements a cycle-accurate ARM7TDMI CPU core, supporting both ARM and Thumb instruction sets, a functional PPU for Mode 3/4/5 rendering, and an MMU with mirroring support.
- Full Instruction Set Support:
- Implements all ARM v4T instructions (Data Processing, Multiply/Long Multiply, LDR/STR, LDM/STM, Swap, Branches, PSR Transfer).
- Implements all Thumb instructions (Formats 1-19).
- Accurate Pipeline & Timing:
- Simulates the 3-stage pipeline (Fetch-Decode-Execute) behavior (PC = Instruction Address + 8/4).
- Cycle counting for accurate timing emulation.
- Register Banking:
- Complete implementation of banked registers for all CPU modes (User, System, FIQ, IRQ, Supervisor, Abort, Undefined).
- Verified Accuracy:
- Passed 100% of tests in
gba-tests/arm/arm.gba(532 tests). - Passed 100% of tests in
gba-tests/thumb/thumb.gba.
- Passed 100% of tests in
- Memory Map Implementation:
- BIOS (0x00)
- EWRAM (0x02)
- IWRAM (0x03)
- I/O Registers (0x04)
- Palette RAM (0x05)
- VRAM (0x06) with correct mirroring behavior.
- OAM (0x07)
- Game Pak ROM (0x08 - 0x0D)
- SRAM (0x0E)
- Wait State Handling:
- Region-specific cycle costs (e.g., fast IWRAM vs slow ROM).
- Bitmap Modes Supported:
- Mode 3: 240x160 Direct Color (15-bit).
- Mode 4: 240x160 Palette Index (8-bit) with Page Flipping.
- Mode 5: 160x128 Direct Color (15-bit) with Page Flipping.
- Rendering Pipeline:
- Scanline-based rendering (HDRAW/HBLANK/VDRAW/VBLANK timings).
- Accurate VCOUNT and DISPSTAT status updates.
- CMake (3.10+)
- C++ Compiler with C++20 support (MSVC, GCC, Clang).
- SDL2 (Fetched automatically via CMake FetchContent).
- Clone the repository.
- Create a build directory:
mkdir build cd build - Configure and build:
cmake .. -DCMAKE_BUILD_TYPE=Release cmake --build . --config Release
Run the executable with a path to a GBA ROM file:
./Release/GBA_Emulator.exe path/to/rom.gbaThe project includes a headless test runner for verifying CPU correctness against gba-tests.
./Release/GBA_Tests.exe path/to/test_rom.gbasrc/: Source code files.GBA.cpp/h: System coordinator (Top-level class).CPU.cpp/h: ARM7TDMI implementation (Registers, Decoder, ALU).MMU.cpp/h: Memory map, read/write logic, DMA hooks.PPU.cpp/h: Graphics rendering engine.Utils.h: Common bit-twiddling and helper functions.main.cpp: SDL2 entry point, event loop, and frame timing.
tests/: Test suite integration.
This project is open-source.