gb/lib.rs
1//! # A crate for GameBoy (Color) development.
2//! Rust-GB is a both toolchain and library for compiling Rust code into
3//! Nintendo GameBoy. It compiles Rust code into valid GameBoy ROM through
4//! LLVM-CBE and GBDK-2020.
5//!
6//! ## Install the compiler
7//! Install a Rust-GB compiler with `cargo install`.
8//! You must use Rust nightly version with you are playing with `Rust-GB` because it uses a lot of
9//! experimental and unstable features.
10//!
11//! In addition, due to limited size issues, external dependencies required by Rust-GB could not be
12//! uploded to crates.io, so you have to clone the repository to install a compiler.
13//!
14//! ``` bash
15//! git clone https://github.com/zlfn/rust-gb.git
16//! git checkout tags/v0.1.0-alpha.2
17//! cd rust-gb
18//! cargo install --path . --features compiler
19//! ```
20//!
21//! `compiler` feature is required when installing the Rust-GB compiler.
22//! If not, binary will not be installed.
23//!
24//! Also, note that `avr-gcc`, `avr-libc`, `sdcc`, `rust-src` are required. You need to install
25//! them to your system before running the compiler.
26//!
27//! ```bash
28//! # Example for Ubuntu
29//! sudo apt install gcc-avr avr-libc sdcc
30//! rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
31//! ```
32//! ### Note
33//! Right now, you can't run the Rust-GB compiler other than Linux x64. This is because the
34//! GameBoy compilation process requires some "external binaries". We're going to solve this problem in
35//! the future by packaging Rust-GB compiler for a platform-specific package manager (`winget`, `homebrew`, `pacman` etc.)
36//!
37//! ## Setup a project
38//! Rust-GB ROM project have to provide all the right default settings so `cargo build` will just work.
39//! Most recommended way to do this is cloning [`rust-gb-template`](https://github.com/zlfn/rust-gb-template)
40//! repository.
41//!
42//! ```bash
43//! git clone https://github.com/zlfn/rust-gb-template.git
44//! ```
45//!
46//! This repository contains minimum files to be compiled GameBoy ROM properly.
47//!
48//! ## Compile your project
49//! By executing the `cargo build-rom` command inside you GameBoy ROM project, you can compile the
50//! Rust code into GameBoy ROM.
51//!
52//! The command creates two directories: `out` and `ext`.
53//!
54//! * **out** : In this directory, all intermediates generated during the compilation process
55//! (LLVM-IR, C, ASM etc.) and the final result `out.gb` are generated.
56//!
57//! * **ext** : GameBoy ROM builds require external binaries (SDCC, LLVM-CBE) and dependency files.
58//! By default, the Rust-GB compiler contains these files, but when compile GameBoy ROM, it needs
59//! to be copied to the file system. This directory contains those external dependency files.
60//!
61//! ## Execute your ROM
62//! The final result, `out.gb`, is located in the `out` directory. This file can be run using the
63//! GameBoy emulator or real GameBoy (Color / Advance).
64//!
65//! The most recommended emulator is [bgb](https://bgb.bircd.org/). However, unless there is a
66//! major problem, any GameBoy emulator should be able to run the `out.gb` file.
67#![doc = document_features::document_features!()]
68#![doc(html_logo_url = "https://github.com/zlfn/rust-gb/blob/main/media/ferris-gb.png?raw=true")]
69
70#![no_std]
71#![no_main]
72#![allow(dead_code)]
73#![feature(strict_provenance)]
74#![feature(format_args_nl)]
75#![feature(doc_cfg)]
76
77pub mod io;
78pub mod mmio;
79pub mod drawing;
80
81#[cfg(feature = "prototype")]
82pub mod irq;
83#[cfg(feature = "prototype")]
84pub mod time;
85#[cfg(feature = "prototype")]
86pub mod memory;
87pub mod gbdk_c;
88