Rust bindings to libmgba, a Game Boy Advance emulator core.
Use this to build GBA emulator frontends, headless ROM testing tools, TAS (tool-assisted speedrun) utilities, or anything else that needs to run GBA software programmatically.
Add the safe wrapper to your project:
[dependencies]
mgba = "0.1"use mgba::Core;
use std::path::Path;
let mut core = Core::new().expect("failed to create core");
core.load_rom(Path::new("game.gba")).expect("failed to load ROM");
core.reset().expect("reset failed");
// Run one frame
core.run_frame().expect("run_frame failed");
// Read the framebuffer (240x160 XBGR8 pixels)
let pixels = core.video_buffer();If you need the raw C API directly, use mgba-sys instead.
| Crate | Description |
|---|---|
| mgba | Safe, high-level Rust wrapper |
| mgba-sys | Raw FFI bindings generated by bindgen |
The mgba C library is built from vendored source, so you need a few system dependencies.
| macOS | Ubuntu/Debian | Windows | |
|---|---|---|---|
| cmake | brew install cmake |
sudo apt install cmake |
cmake.org |
| clang | Xcode CLT (xcode-select --install) |
sudo apt install libclang-dev |
LLVM from releases.llvm.org |
| zlib | pre-installed | sudo apt install zlib1g-dev |
bundled by vcpkg or pre-installed with MSVC |
git clone https://github.com/ocnc/mgba-rs.git
cd mgba-rs
cargo buildThe Rust bindings in this repository are licensed under the MIT License.
libmgba, vendored under mgba-sys/mgba/, is licensed under the
Mozilla Public License 2.0. Binary distributions that
statically link libmgba must comply with MPL-2.0 requirements (notably, making the
libmgba source available).