WIP Gameboy Advance Emulator written in D. Passes 2020/2020 mGBA timing tests, and fourth software-based emulator to pass the AGS Aging Cartridge test. Currently working on improving GBA accuracy.
aging.mp4
Superstar.Saga.mov
Pokemon.Emerald.mov
Emulator main project is in src/emu
.
- Dlang + DUB
- Python3/PyPy3 (packages:
ply
)
Optionally add -b release --compiler=ldc2
for optimized build.
dub build
Build with support for gperftools_d. This requires the LDC2 compiler.
dub build -c gperf --compiler=ldc2 -b release-debug
Then, run with the CPUPROFILE=/tmp/prof.out
environment var to write a profile log.
Finally, convert the log to human readable graph:
pprof --pdf gamebean-emu /tmp/prof.out > ~/Downloads/gamebean_profile.pdf
Specify path to rom. You can also optionally use -s
to specify window scaling (default = 1). Note that you must have a gba_bios.bin located in the same directory as the executable. You can acquire a substitute BIOS (see Cult of GBA), or you can dump the official BIOS from a GBA.
./gamebean-emu [rom]
To run the tests, run dub test
. This will test the ARM CPU by running it through the GBA files located in /tests/asm/bin/. If the cpu states after every cycle matches the expected states found in the log files in /tests/asm/log, then the tests will pass. These roms are written in ARM assembly and are located in /tests/asm/src. These tests have their own makefile that produces a .gba file as well as a log file. Logfile production requires having an editted version of NanoBoyAdvance, and having the command NanoBoyAdvance
added to PATH.
ARM Technical Reference Manual: https://static.docs.arm.com/ddi0029/g/DDI0029.pdf
ARM Architectural Reference Manual: https://cs.nyu.edu/courses/spring18/CSCI-GA.2130-001/ARM/arm_arm.pdf
GBATEK: https://problemkaputt.de/gbatek.htm
Patater GBA ASM Guide: https://patater.com/gbaguy/gbaasm.htm
Tonc: https://www.coranac.com/tonc/text/
- nocash, for the excellent documentation about the GBA's internals on GBATEK
- fleroviux, for sharing research on GBA timing, as well letting me take inspiration NanoBoyAdvance for my frontend design.
- DenSinH, whose code (DSHBA) I referenced while adding shaders to my emu
- Near and Talarubi, who created the aforementioned shaders.