Rust-Rustboyadvance ng: Nintendo GameBoy Advance ™ emulator and debugger, written in rust.

RustBoyAdvance-NG

license Build

Nintendo GameBoy Advance ™ emulator and debugger, written in rust.

WebAssembly Demo: https://michelhe.github.io/rustboyadvance-ng/ Deploy

Project Structure

  • core/ - Main emulator crate
  • bindings/ - Bindings to other languages. Currently only java binidings through JNI.
  • platform/ - Constains executables & application built with rustboyadvance-core
    • platform/rustbodyadvance-wasm - Web emulator powered by WebAssembly
    • platform/rustbodyadvance-sdl2 - Desktop application built with sdl2
    • platform/rustbodyadvance-minifb - Desktop application built with minifb, not maintained.
    • platform/android - A PoC Android application.

Progress

Pokemon Emerald

Emulation Todo:

  • CGB audio (4 wave generator channels)

Build and usage (Desktop Application)

To get started, you need to get a stable rust toolchain.

Linux build dependencies

Install SDL2 dependencies

sudo apt-get -y install libsdl2-dev libsdl2-image-dev

Windows build dependencies

SDL2 runtime binaries are included in this repository, no extra setup needed.

Build & Usage

You need to obtain a gba bios binary. An open source GBA bios is also available and supported.

Place the bios file in the repository root and name it gba_bios.bin (or alternatively use the -b command line option)

Build and run in release mode (performance is terrible in the dev profile)

$ cargo run --release -p rustboyadvance-sdl2 -- path/to/rom

You can also drag&drop rom files or any zip files containing .gba files inside into the emulator window and a new rom will be loaded.

Key bindings

Currently the key bindings are not configureable.

GBA key bindings:

Keyboard GBA
Up Up
Down Down
Left Right
Right Right
Z B Button
X A Button
Return Start
Backspace Select
A L
S R

Special key bindings

Key Function
Space (hold) Disable 60fps cap
F1 Custom debugger (requires --features debugger)
F2 Spawn gdbserver (experimetnal, requires --features gdb)
F5 Save snapshot file
F9 Load snapshot file

Android Application

The android project is placed inside platform/android. To build it, open it with Android Studio.

You also need to set up rust to build android targets with NDK.

TODO - instructions

More Screenshots

Kirby - Nightmare in Dreamland Dragon Ball - Legacy of Goku 2

Links and attribution

  • ARM7TDMI Technical Reference Manual Technical Reference Manuals are fun.
  • GBATEK A single webpage written by no$gba developer Martin Korth. This page has pretty much everything. Seriously, it's the best.
  • TONC A comprehensive GBA dev guide that I used a-lot in order to understand the GBA system. Comes with neat demo roms that really helped me during development and debugging.
  • NanoboyAdvance A GameBoy Advance emulator written in C++17 by a nice person called fleroviux. I've used this for debugging.
  • Eggvance gba-suite Incredible test suite for the arm7tdmi interpreter that I'm using, written by Julian Smolka.

Comments

  • Update gba-suite
    Update gba-suite

    May 22, 2020

    gba-suite has been updated, and these tests now have a bitmap UI. Also, need to make sure the tests (suchs as test_arm7tdmi_arm_eggvance) are updated accordingly.

    enhancement good first issue 
    Reply
  • Dragon Ball Z: Supersonic Warriors - Sprite ordering issues
    Dragon Ball Z: Supersonic Warriors - Sprite ordering issues

    May 24, 2020

    Screenshot_20200524_130628

    On the team select screen the character portraits should be rendered on top of the level selection slider, not below.

    game-bug 
    Reply
  • Games panicking with 'forbidden DMA source address adjustment'
    Games panicking with 'forbidden DMA source address adjustment'

    May 28, 2020

    thread 'main' panicked at 'forbidden DMA source address adjustment', rustboyadvance-core/src/dma.rs:125:18
    

    Games hitting this panic right after the BIOS logo:

    • The Sum of All Fears
    • Tom Clancy's Rainbow Six - Rogue Spear
    • X-Men - The Official Game
    game-bug 
    Reply
  • Panic on invalid CPU modes
    Panic on invalid CPU modes

    May 28, 2020

    thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', rustboyadvance-core/src/arm7tdmi/psr.rs:73:9
    

    Games hitting this panic:

    • Madden NFL 2002 (after the BIOS logo)
    • Starsky & Hutch (after starting a new game)
    • Ultimate Muscle - The Kinnikuman Legacy
    • Banjo-Kazooie - Grunty's Revenge
    • The Powerpuff Girls - Mojo Jojo A-Go-Go
    • Colin McRae Rally 2.0
    • Gauntlet - Dark Legacy
    game-bug 
    Reply
  • NFL Blitz 20-02 (USA) - Glitch
    NFL Blitz 20-02 (USA) - Glitch

    May 30, 2020

    The game intro sequence is rushing through at 100000x speedup and gets stuck on a black screen.

    nfl_blitz

    (The emulator runs at 60FPS in this recording)

    game-bug 
    Reply
  • The Game will stop
    The Game will stop

    May 17, 2021

                                                                                                                                                                                                           
    Reply
  • Android Loading of snapshot not working
    Android Loading of snapshot not working

    Sep 27, 2020

    If i try to load a saved Snapshot in Android the rust emulator hangs with a cracking sound. Please help with any fix

    Reply
  • Work towards having passing Travis CI
    Work towards having passing Travis CI

    May 15, 2020

    Thumb tests are now passing, the ARM tests are still failing.

    Reply
  • core: Clamp BLDY to 0..16 in compose_pixel
    core: Clamp BLDY to 0..16 in compose_pixel

    May 16, 2020

    As per the GBATEK docs. Fixes the fadeout animations in Ice Age.

    Reply
  • Happy Feet (USA) - Flickering corrupt graphics
    Happy Feet (USA) - Flickering corrupt graphics

    May 30, 2020

    They are not happy at the moment: vlcsnap-2020-05-30-13h23m01s729

    game-bug 
    Reply
  • Pokémon GBA Video cartridges - Garbage sprites at the top left corner
    Pokémon GBA Video cartridges - Garbage sprites at the top left corner

    May 28, 2020

    Screenshot_20200528_162715

    All four volumes of these Pokémon video cartridges are affected. Other video carts doesn't seem to have these garbage sprites.

    Reply
  • Segmentation fault in SysBus::read_8
    Segmentation fault in SysBus::read_8

    May 30, 2020

    Affected game:

    • Power Rangers - Ninja Storm (USA)

    Backtrace:

    Thread 1 "rustboyadvance-" received signal SIGSEGV, Segmentation fault.
    0x000055555562e029 in <rustboyadvance_core::sysbus::SysBus as rustboyadvance_core::bus::Bus>::read_8 ()
    (gdb) bt
    #0  0x000055555562e029 in <rustboyadvance_core::sysbus::SysBus as rustboyadvance_core::bus::Bus>::read_8 ()
    #1  0x00005555555fe94d in rustboyadvance_core::arm7tdmi::thumb::exec::<impl rustboyadvance_core::arm7tdmi::cpu::Core>::do_exec_thumb_ldr_str ()
    #2  0x00005555555fec05 in rustboyadvance_core::arm7tdmi::thumb::exec::<impl rustboyadvance_core::arm7tdmi::cpu::Core>::exec_thumb_ldr_str_imm_offset ()
    #3  0x000055555560054d in rustboyadvance_core::arm7tdmi::cpu::Core::step ()
    #4  0x00005555555fa336 in rustboyadvance_core::gba::GameBoyAdvance::step ()
    #5  0x00005555555fa1b6 in rustboyadvance_core::gba::GameBoyAdvance::frame ()
    #6  0x00005555555be914 in rustboyadvance_sdl2::main ()
    #7  0x00005555555c44c3 in std::rt::lang_start::{{closure}} ()
    #8  0x00005555557c3ac8 in std::rt::lang_start_internal::{{closure}} () at src/libstd/rt.rs:52
    #9  std::panicking::try::do_call () at src/libstd/panicking.rs:331
    #10 std::panicking::try () at src/libstd/panicking.rs:274
    #11 std::panic::catch_unwind () at src/libstd/panic.rs:394
    #12 std::rt::lang_start_internal () at src/libstd/rt.rs:51
    #13 0x00005555555c0042 in main ()
    
    game-bug accuracy 
    Reply