2021-03-02 02:36:39 +11:00
[![License:Zlib ](https://img.shields.io/badge/License-Zlib-green.svg )](https://opensource.org/licenses/Zlib)
2018-11-14 06:47:52 +11:00
[![License:Apache2 ](https://img.shields.io/badge/License-Apache2-green.svg )](https://www.apache.org/licenses/LICENSE-2.0)
2021-03-02 02:36:39 +11:00
[![License:MIT ](https://img.shields.io/badge/License-MIT-green.svg )](https://opensource.org/licenses/MIT)
2021-02-21 05:49:40 +11:00
[![ci ](https://github.com/rust-console/gba/workflows/ci/badge.svg?branch=master )](https://github.com/rust-console/gba/actions?query=workflow%3Aci)
2018-11-15 13:48:45 +11:00
[![crates.io ](https://img.shields.io/crates/v/gba.svg )](https://crates.io/crates/gba)
[![docs.rs ](https://docs.rs/gba/badge.svg )](https://docs.rs/gba/latest/gba/)
2018-11-14 06:47:52 +11:00
2018-11-19 07:09:23 +11:00
* [![Built with cargo-make ](https://sagiegurari.github.io/cargo-make/assets/badges/cargo-make.svg )](https://sagiegurari.github.io/cargo-make)
2018-11-21 17:44:58 +11:00
* ![Stability:None ](https://img.shields.io/badge/Stability-None-red.svg )
2018-11-19 07:09:23 +11:00
2018-11-14 06:47:52 +11:00
# gba
2021-04-06 10:11:42 +10:00
A crate to make GBA programming easy.
2018-11-14 06:47:52 +11:00
2021-04-06 10:11:42 +10:00
Currently we don't have as much documentation as we'd like.
If you check out the [awesome-gbadev ](https://github.com/gbdev/awesome-gbadev ) repository they have many resources, though most are oriented towards C.
2019-01-03 14:50:05 +11:00
2021-04-09 15:57:30 +10:00
## System Setup
There's a few extra things to install that you just need to do once per system.
2019-01-03 14:50:05 +11:00
2021-04-06 10:11:42 +10:00
Building for the GBA requires Nightly rust, and also uses the `build-std` feature, so you'll need the rust source available.
2021-02-21 05:49:40 +11:00
```sh
rustup install nightly
rustup +nightly component add rust-src
```
2021-04-06 10:11:42 +10:00
You'll also need the ARM binutils so that you can have the assembler and linker for the ARMv4T architecture.
The way to get them varies by platform:
* Ubuntu and other debian-like linux distros will usually have them in the package manager.
2021-02-21 05:49:40 +11:00
```shell
sudo apt-get install binutils-arm-none-eabi
```
2021-04-06 10:11:42 +10:00
* With OSX you can get them via homebrew.
2021-02-21 05:49:40 +11:00
```shell
brew install --cask gcc-arm-embedded
```
2021-04-06 10:11:42 +10:00
* On Windows you can get the installer from ARM's website and run that.
2021-02-21 05:49:40 +11:00
* Download the [GNU Arm Embedded Toolchain ](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads )
2021-04-06 10:11:42 +10:00
* When installing the toolchain, make sure to select "Add path to environment variable" during install.
* You'll have to restart any open command prompts after you so run the installer so that they see the new PATH value.
Finally, rustc itself is only able to make ELF format files. These can be run in emulators, but aren't able to be played on actual hardware.
You'll need to convert the ELF file into a GBA rom. There's a `cargo-make` file in this repository to do this, and it relies on a tool called `gbafix`
to assign the right header data to the ROM when packing it.
```sh
cargo install cargo-make
cargo install gbafix
```
2021-02-21 05:49:40 +11:00
2021-04-09 15:57:30 +10:00
## Project Setup
2018-11-14 06:47:52 +11:00
2021-04-09 15:57:30 +10:00
To build a GBA project, you'll want to copy the `.cargo/config.toml` file from this repo into your own project.
2018-11-14 06:47:52 +11:00
2021-04-09 15:57:30 +10:00
Then use one of the examples as a guide to get started.
2018-11-19 02:25:32 +11:00
2021-04-09 15:57:30 +10:00
When you build your project, cargo will put outputs in the `target/thumbv4t-none-eabi/` directory.
This includes the `debug/` and `release/` sub-directories.
Your binary will be in there, but it'll be in ELF format.
You can run this directly in an emulator such as [mGBA ](https://mgba.io/ ) if you'd like.
When you're ready to convert your program into a "proper" GBA rom you'll need to run an `objcopy`
to extract just the raw binary data:
```
arm-none-eabi-objcopy -O binary [RUST_BINARY_NAME] [ROM_NAME].gba
```
Then you'll need to patch the header data with `gbafix`
```
gbafix [ROM_NAME].gba
2018-11-19 02:25:32 +11:00
```
2021-04-09 15:57:30 +10:00
And you'll be all done!
2018-11-19 02:25:32 +11:00
2018-11-14 06:47:52 +11:00
# Contribution
2021-04-06 10:11:42 +10:00
This crate is tri-licensed under Zlib / Apache-2.0 / MIT.
Any contributions you submit must be licensed the same.