michelhe / rustboyadvance-ng Goto Github PK
View Code? Open in Web Editor NEWRustBoyAdvance-NG is a Nintendo™ Game Boy Advance emulator and debugger, written in the rust programming language.
License: MIT License
RustBoyAdvance-NG is a Nintendo™ Game Boy Advance emulator and debugger, written in the rust programming language.
License: MIT License
The emulator panics right after the BIOS logo because the game tries to set an invalid, mode 6 graphics mode. Should it be silently ignored? Is this a part of an anti-emulation trick or just garbage game code?
Not to be confused with WWE Road to WrestleMania X8.
No mosaic for objs
The menu screen doesn't react to the Start and Select buttons, cannot start a new game. May be related to #95.
Missing support for SRAM
Affected game:
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 ()
The audio implementation for the WASM frontend is done with raw WebAudio.
Need to find some way to stream samples to WebAudio without waiting for the frame emulation to finish.
The distortion effect used for MISSION START
label lingers on after the animation finishes, causing the UI layer to look like that.
The distortion effect is implemented with HBlank interrupts, whenever the animation finishes the HBlank IRQ handler may disable the HBLANK_IRQ_ENABLE bit of REG_DISPSTAT. This only happens when REG_VCOUNT value is 160 as can be seen below:
Due to improper emulation of the GPU, HBLANK Interrupts are not triggered when the Gpu is in VBlank state, thus VCOUNT will never be 160 (0xa0) and HBLANK_IRQ_ENABLE bit never gets cleared.
I'm using rustboyadvance-ng/core for a personal project. It seems to work fine in release mode (as runtime overflow checks are disabled), but in development I run into this error when attempting to render the second frame. The bios frames and first frame of the game itself render fine.
Reproduction of the issue can be found here: https://github.com/SkyLeite/pokecord/tree/0b69d9ae03491ca2190e6cdcf52fb5710925f197
warning: `pokecord` (bin "pokecord") generated 6 warnings
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/pokecord`
Rendered!
First frame rendered!
thread 'main' panicked at 'attempt to subtract with overflow', rustboyadvance-ng/core/src/gpu/mod.rs:464:47
stack backtrace:
0: 0x5579b61468ec - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb16b437de6ab6276
1: 0x5579b6171bde - core::fmt::write::h8f8bef23583ee234
2: 0x5579b614d0c1 - std::io::Write::write_fmt::h8486efe074824056
3: 0x5579b61544be - std::panicking::default_hook::{{closure}}::hdfa4615b29a34cb8
4: 0x5579b6154127 - std::panicking::default_hook::h60ffd169fe7df297
5: 0x5579b61549d1 - std::panicking::rust_panic_with_hook::hf0183b899953e185
6: 0x5579b6146ea9 - std::panicking::begin_panic_handler::{{closure}}::h93eac1c61f0beba3
7: 0x5579b6146cc4 - std::sys_common::backtrace::__rust_end_short_backtrace::he4788588c206eaab
8: 0x5579b6154682 - rust_begin_unwind
9: 0x5579b5e68813 - core::panicking::panic_fmt::h20a31c8e90ca0d37
10: 0x5579b5e686dd - core::panicking::panic::h95bb893ef3e7cb7f
11: 0x5579b5ec92be - rustboyadvance_core::gpu::Gpu::on_event::ha2e8b68811dd5add
at /mnt/hdd/projects/pokecord/rustboyadvance-ng/core/src/gpu/mod.rs:464:47
12: 0x5579b5edd4c6 - rustboyadvance_core::gba::GameBoyAdvance::handle_event::hda667049d6b7e2c7
at /mnt/hdd/projects/pokecord/rustboyadvance-ng/core/src/gba.rs:310:38
13: 0x5579b5edd2b2 - rustboyadvance_core::gba::GameBoyAdvance::run::hc95f87805a33d994
at /mnt/hdd/projects/pokecord/rustboyadvance-ng/core/src/gba.rs:288:17
14: 0x5579b5edcd8a - rustboyadvance_core::gba::GameBoyAdvance::frame::h10956a8c82e3b727
at /mnt/hdd/projects/pokecord/rustboyadvance-ng/core/src/gba.rs:222:25
15: 0x5579b5e6e027 - pokecord::main::hf48fb910a058991b
at /mnt/hdd/projects/pokecord/src/main.rs:77:14
16: 0x5579b5e69f7b - core::ops::function::FnOnce::call_once::h794bd1593b72e1e2
at /build/rustc-1.63.0-src/library/core/src/ops/function.rs:248:5
17: 0x5579b5e68b9e - std::sys_common::backtrace::__rust_begin_short_backtrace::hdded08256cdf329e
at /build/rustc-1.63.0-src/library/std/src/sys_common/backtrace.rs:122:18
18: 0x5579b5e68b61 - std::rt::lang_start::{{closure}}::h010441cf4be51538
at /build/rustc-1.63.0-src/library/std/src/rt.rs:145:18
19: 0x5579b614c9d5 - std::rt::lang_start_internal::h3e617fbe87035bdb
20: 0x5579b5e68b30 - std::rt::lang_start::hda90f78f082db313
at /build/rustc-1.63.0-src/library/std/src/rt.rs:144:17
21: 0x5579b5e6e0cc - main
22: 0x7f1956160237 - __libc_start_call_main
23: 0x7f19561602f5 - __libc_start_main_impl
24: 0x5579b5e689b1 - _start
at /build/glibc-2.34/csu/../sysdeps/x86_64/start.S:116
25: 0x0 - <unknown>
It's broken and causes graphical glitches (obviously)
Similar to #96
Very similar to the glitches shown in #111
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', rustboyadvance-core/src/arm7tdmi/psr.rs:73:9
Games hitting this panic:
When running in unbounded fps (holding down space button), the emulator underperforms compared against other emulators.
I needed to perform these steps to be able to build this project on my arm64 macOS:
brew install SDL2 SDL2_image
export LIBRARY_PATH="$LIBRARY_PATH:/opt/homebrew/lib"
cargo run --release -- path/to/rom
When logging invalid memory writes I noticed pokemon emerald tries to read from a NULL pointer during the fade out animation in the naming screen (right after the players confirm their name)
The problematic function is called GetTextCaretPosition
, and this is the instruction that loads the global pointer gNamingScreenData
080e4a46 04 68 ldr r4,[r0,#0x0]=>gNamingScreenData = ??
gNamingScreenData is set to NULL when waiting for the fade to finish in the following function
static bool8 MainState_WaitFadeOutAndExit(void)
{
if (!gPaletteFade.active)
{
if (gNamingScreenData->templateNum == NAMING_SCREEN_PLAYER)
SeedRngAndSetTrainerId();
SetMainCallback2(gNamingScreenData->returnCallback);
DestroyTask(FindTaskIdByFunc(sub_80E31B0));
FreeAllWindowBuffers();
FREE_AND_SET_NULL(gNamingScreenData);
}
return FALSE;
}
But for some reason GetTextCaretPosition
still gets called every frame causing this NULL deref.
Possibly a real bug in the game itself?
Need to stop using #Derieve(Serialize,Deserialize)
And do custom serialization that takes a fewer as possible data fields
i also have problem with audio if i turn on turbo mode or change frame rate of emulator... audio cracks and Logs show this message . Games run perfectly but only audio has some cracking
I/chatty: uid=10539(com.mrmichel.rustdroid_emu) Thread-4 identical 25 lines
W/EmulatorBindings: : failed to push audio sample
W/EmulatorBindings: : failed to push audio sample
I/chatty: uid=10539(com.mrmichel.rustdroid_emu) Thread-4 identical 3752 lines
W/EmulatorBindings: : failed to push audio sample
W/EmulatorBindings: : failed to push audio sample
I/chatty: uid=10539(com.mrmichel.rustdroid_emu) Thread-4 identical 26652 lines
W/EmulatorBindings: : failed to push audio sample
W/EmulatorBindings: : failed to push audio sample
Never encountered any actual game that uses it though
Some games are buggy, and since the hardware emulation is nowhere near perfect at the moment,
These bugs break these games on this emulator (while on real hardware, they don't break).
Some of the broken games:
Need to
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.
If i try to load a saved Snapshot in Android the rust emulator hangs with a cracking sound. Please help with any fix
Missing emulation of the 4 analog channels
Cloned the repo, ran 'cargo build --release' on commit 1dfdec3 and get this error:
error :
warning: `rustboyadvance-core` (lib) generated 4 warnings
error: couldn't read platform/rustboyadvance-sdl2/src/../../../external/SDL_GameControllerDB/gamecontrollerdb.txt: No such file or directory (os error 2)
--> platform/rustboyadvance-sdl2/src/main.rs:66:9
|
66 | include_str!("../../../external/SDL_GameControllerDB/gamecontrollerdb.txt");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this error originates in the macro `include_str` (in Nightly builds, run with -Z macro-backtrace for more info)
warning: unused import: `io`
--> platform/rustboyadvance-sdl2/src/options.rs:1:11
|
1 | use std::{io, path::PathBuf};
| ^^
|
= note: `#[warn(unused_imports)]` on by default
warning: `rustboyadvance-sdl2` (bin "rustboyadvance-sdl2") generated 1 warning
error: could not compile `rustboyadvance-sdl2` due to previous error; 1 warning emitted
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:
Thanks for the emulator! Every game I tried running rustboyadvance-sdl2
with triggered a subtraction overflow panic. Here's the log for Pokemon Emerald:
INFO [rustboyadvance_sdl2] Initializing SDL2 context
INFO [rustboyadvance_sdl2] No game controllers were found
INFO [rustboyadvance_sdl2::audio] Found audio device: AudioSpec { freq: 44100, format: S16LSB, channels: 2, silence: 0, samples: 2048, size: 8192 }
INFO [rustboyadvance_sdl2::audio] ringbuffer size = 8192
INFO [rustboyadvance_core::cartridge::builder] Loaded ROM: CartridgeHeader { game_title: "POKEMON EMER", game_code: "BPEE", maker_code: "01", software_version: 0, checksum: 114 }
INFO [rustboyadvance_core::cartridge::builder] Found game overrides for BPEE: GameOverride {
force_rtc: true,
save_type: None,
}
INFO [rustboyadvance_core::cartridge::builder] Detected Backup: Flash1M
INFO [rustboyadvance_core::cartridge::builder] Emulating RTC!
INFO [rustboyadvance_core::gba] Verified bios rom
INFO [rustboyadvance_core::sound] MSE enabled!
INFO [rustboyadvance_core::sound] bias - setting sample frequency to 32768hz
INFO [rustboyadvance_core::sound] MSE disabled!
thread 'main' panicked at core/src/gba.rs:218:25:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I was able to have the game run, after replacing the subtraction in core/src/gba.rs
with .saturating_sub
. I'll do a pull request in a second.
Upon entering a new stage in Wario Land 4 there's an animation of a rotating vortex. It should be rotating at the dead center of the screen, however RustBoyAdvance-NG currently renders it off-center. The rotation also glitches twice during the animation.
Screenshot:
Expected rendering (mGBA master):
Smashing the A button in the menu should trigger the panic.
thread 'main' panicked at 'invalid arm condition', rustboyadvance-core/src/arm7tdmi/cpu.rs:403:21
When entering the in-game menu, the game jumps to a random address in the form of 0x23XXXXXX
This can cause short graphical glitches on scene transitions, when games perform large VRAM updates while expecting the GPU to draw nothing.
The only visible example of this I currently know is the magenta colored screen flash when opening the in-game menu in DBZ Legacy of Goku.
Thanks for the great work!
Can you update instructions for how to build it with Android Studio, or is there an existing APK for Android? Just want to try it on my phone : )
Probably related to #94
Missing support for flash backup
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.