3 releases
new 0.1.0-alpha.2 | Nov 2, 2024 |
---|---|
0.1.0-alpha.1 | Oct 31, 2024 |
#41 in Emulators
171 downloads per month
77KB
1K
SLoC
Compile Rust code to GBZ80 (Work in Progress)
You can find ROM builds of examples in release
How is this possible?
GameBoy is not a possible target of Rust (even its not in Tier 3), and there is currently no suitable (stable) LLVM backend for the CPU in GameBoy. Therefore, the Rust code is compiled using the following process.
- The Rust compiler can generate LLVM-IR for the ATMega328 processor. (which powers Arduino)
- LLVM-IR can be converted to C code using llvm-cbe.
- The C code can then be compiled to Z80 Assembly using sdcc.
- Z80 Assembly can be assembled into GBZ80 object code with sdasgb.
- The GBZ80 object code can be linked with GBDK libraries and built into a Game Boy ROM using lcc.
I referred to z80-babel for steps 1–3, and used gbdk-2020 for steps 4–5.
In the long run, I hope to write LLVM backend for z80 (sm83), and include it in Rust's Tier 3 list. This will dramatically simplify the build chain.
Why use Rust instead of C or ASM?
- Rust provides higher-level and better grammer than C.
- Rust's memory stability and strict types help you avoid to write incorrect code (even on a small device).
- Putting everything aside, it's fun!
Goal
This project's goal is to develop a Game Boy Development Kit that enables the creation of Game Boy games using Rust, including safe management APIs in Game Boy memory, abstracted functions, and more.
Currently, the dependence on GBDK is large, but we plan to gradually reduce it.
Support
If you like this project, you can always join our Discussion! Please feel free to share your opinions or ideas.
This project is in its very early stages, and we are still designing many things, so it would be nice to have a variety of ideas.
PRs are always welcome too!
Dependencies
- rust (nightly)
- avr-gcc
- avr-libc
- sdcc
This project is still a work in progress, and I haven't tested it outside of my development environment.
Dependencies may change as the project evolves.
Related & Similar projects
Dependencies
~0.2–12MB
~92K SLoC