{"id":14788449,"url":"https://github.com/zlfn/rust-gb","last_synced_at":"2025-04-08T11:10:12.684Z","repository":{"id":256454917,"uuid":"855346786","full_name":"zlfn/rust-gb","owner":"zlfn","description":"Compile Rust code to GBZ80 (Gameboy Z80)","archived":false,"fork":false,"pushed_at":"2025-03-11T15:31:30.000Z","size":37332,"stargazers_count":218,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-01T09:34:01.918Z","etag":null,"topics":["8-bit","cross-compiler","game-boy","gameboy","gbdk","hacktoberfest","retro","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zlfn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-10T18:06:41.000Z","updated_at":"2025-03-25T20:23:58.000Z","dependencies_parsed_at":"2025-01-18T17:24:06.984Z","dependency_job_id":"a1538680-874c-4d35-8ff1-d8c892b57fa9","html_url":"https://github.com/zlfn/rust-gb","commit_stats":null,"previous_names":["zlfn/rust-gb"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlfn%2Frust-gb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlfn%2Frust-gb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlfn%2Frust-gb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlfn%2Frust-gb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zlfn","download_url":"https://codeload.github.com/zlfn/rust-gb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247829511,"owners_count":21002997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["8-bit","cross-compiler","game-boy","gameboy","gbdk","hacktoberfest","retro","rust"],"created_at":"2024-09-17T09:01:21.313Z","updated_at":"2025-04-08T11:10:12.659Z","avatar_url":"https://github.com/zlfn.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg align=\"center\" width=80% src=\"media/rust-gb-logo.jpg\"/\u003e\n  \u003cbr/\u003e\n\u003c/div\u003e\n\n---\n\n[![Crates.io Version](https://img.shields.io/crates/v/rust-gb?style=for-the-badge\u0026logo=rust\u0026color=dea584\u0026link=https%3A%2F%2Fdocs.rs%2Frust-gb%2Flatest%2Fgb%2F)](https://crates.io/crates/rust-gb)\n[![docs.rs](https://img.shields.io/docsrs/rust-gb?style=for-the-badge\u0026logo=docsdotrs\u0026color=%23000000\u0026link=https%3A%2F%2Fdocs.rs%2Frust-gb%2Flatest%2Fgb%2F)](https://docs.rs/rust-gb/latest/gb/)\n[![Crates.io License](https://img.shields.io/crates/l/rust-gb?style=for-the-badge\u0026logo=opensourceinitiative\u0026logoColor=white\u0026color=3DA639)](https://github.com/zlfn/rust-gb/blob/main/LICENSE)\n\n\nCompile Rust code to GBZ80 (Work in Progress)  \nYou can find ROM builds of examples in [release](https://github.com/zlfn/rust-gb/releases/tag/v0.0.1-alpha). Documentation can be found [here](https://docs.rs/rust-gb/latest/gb/).\n\n## How is this possible?\nGameBoy is not a possible target of Rust (even its not in [Tier 3](https://doc.rust-lang.org/nightly/rustc/platform-support.html)), and there is currently no suitable (stable) LLVM backend for the CPU in GameBoy. Therefore, the Rust code is compiled using the following process.\n1. The Rust compiler can generate LLVM-IR for the ATMega328 processor. (which powers Arduino)\n2. LLVM-IR can be converted to C code using [llvm-cbe](https://github.com/JuliaHubOSS/llvm-cbe).\n3. The C code can then be compiled to Z80 Assembly using [sdcc](https://sdcc.sourceforge.net/).\n4. Z80 Assembly can be assembled into GBZ80 object code with [sdasgb](https://gbdk-2020.github.io/gbdk-2020/docs/api/docs_supported_consoles.html).\n5. The GBZ80 object code can be linked with GBDK libraries and built into a Game Boy ROM using [lcc](https://gbdk-2020.github.io/gbdk-2020/docs/api/docs_toolchain.html#lcc).\n\nI referred to [z80-babel](https://github.com/MartinezTorres/z80_babel) for steps 1–3, and used [gbdk-2020](https://github.com/gbdk-2020/gbdk-2020) for steps 4–5.\n\nIn 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.\n\n## Why use Rust instead of C or ASM?\n1. Rust provides higher-level and better grammar than C.\n2. Rust's memory stability and strict types help you avoid to write incorrect code (even on a small device).\n3. Putting everything aside, it's fun!\n\n## Goal\nThis 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.\n\nCurrently, the dependence on GBDK is large, but we plan to gradually reduce it.\n\n## Support\nIf you like this project, you can always join our [Discussion](https://github.com/zlfn/rust-gb/discussions)!\nPlease feel free to share your opinions or ideas.\n\nThis 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.\n\nPRs are always welcome too!\n\n## Dependencies\n* rust (nightly)\n* avr-gcc\n* avr-libc\n* sdcc (4.4.0)\n* ast-grep\n\nThis project is still a work in progress, and I haven't tested it outside of my development environment.\n\nDependencies may change as the project evolves.\n\n## Related \u0026 Similar projects\n- [GBDK-2020](https://github.com/gbdk-2020/gbdk-2020) : Provides the library for GameBoy.\n- [llvm-cbe](https://github.com/JuliaHubOSS/llvm-cbe) : Compile Rust code to C.\n- [z80_babel](https://github.com/MartinezTorres/z80_babel) : Giving an idea to compile Rust code into Z80.\n- [gba](https://github.com/rust-console/gba) : Compiles the Rust code into the GameBoy but its Advance. (Unlike DMG, GBA is Rust's Tier 3 target.)\n\n","funding_links":[],"categories":["Software Development","Rust"],"sub_categories":["Compilers"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlfn%2Frust-gb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzlfn%2Frust-gb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlfn%2Frust-gb/lists"}