{"id":13545836,"url":"https://github.com/ricky26/rust-mega-drive","last_synced_at":"2025-04-02T17:31:52.135Z","repository":{"id":40604622,"uuid":"339376153","full_name":"ricky26/rust-mega-drive","owner":"ricky26","description":"A proof-of-concept project using Rust to write Mega Drive ROMs.","archived":false,"fork":false,"pushed_at":"2021-10-14T17:58:43.000Z","size":296,"stargazers_count":63,"open_issues_count":5,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-03T13:35:26.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ricky26.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-16T11:26:56.000Z","updated_at":"2024-11-02T01:41:49.000Z","dependencies_parsed_at":"2022-08-24T23:41:13.006Z","dependency_job_id":null,"html_url":"https://github.com/ricky26/rust-mega-drive","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricky26%2Frust-mega-drive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricky26%2Frust-mega-drive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricky26%2Frust-mega-drive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ricky26%2Frust-mega-drive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ricky26","download_url":"https://codeload.github.com/ricky26/rust-mega-drive/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246860110,"owners_count":20845601,"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":[],"created_at":"2024-08-01T12:00:20.824Z","updated_at":"2025-04-02T17:31:51.843Z","avatar_url":"https://github.com/ricky26.png","language":"Rust","funding_links":[],"categories":["Programming"],"sub_categories":["Snippets and Demos"],"readme":"# Mega Drive toolkit for Rust\n\nThis repository hosts a few packages for use with the SEGA Mega Drive (Sega\nGenesis in North America).\n\n## Using these packages\nAt the moment, these packages only work with a fork of LLVM \u0026 Rust. To use them\nyou will need to build both.\n\n### Building with Docker\nFor convenience, this repository provides a two-stage Dockerized approach to building the contained code:\n- A [Dockerfile.toolchain](Dockerfile.toolchain) for a Motorola 68000-compatible Rust compiler. You can build this using\n  the command `docker build -t rust-m68k:latest -f Dockerfile.toolchain .`. If the build runs out of memory, you can\n  tweak the number of parallel build processes using `--build-arg NUM_JOBS=4` or lower if your system requires it.\n- A [Dockerfile](Dockerfile) to compile the megapong application. Use `docker build -t rust-mega-drive .` to compile it.\n  It assumes that you built the toolchain Docker image as `rust-m68k:latest`. To obtain the \"megapong\" example, run:\n  ```shell\n  # Run the image with default command to build megapong\n  docker run -it -v $(pwd)/target:/target rust-mega-drive:latest\n  # Take back control over the target directory\n  sudo chown -R $USER:$USER target \n  ```\n  Now, you will have a `megapong.md` binary in the subfolder `target/m68k-none-eabi/release/`!\n\n### Building LLVM\nThis is a more in-depth approach to building a Motorola 68000 compatible Rust/LLVM toolchain. You can skip these \ninstructions if you used Docker as the main build tool.\n1. Checkout the `llvm-12` branch from the\n[LLVM project fork](https://github.com/ricky26/llvm-project).\n  \n2. Build the toolchain with cmake:\n    1. Generate the project with the M68k backend enabled:\n       ```bash\n       cd llvm-project\n       mkdir build\n       cd build\n       cmake -G Ninja \"-DLLVM_USE_LINKER=lld\" \"-DCMAKE_BUILD_TYPE=Release\" \"-DLLVM_ENABLE_ASSERTIONS=ON\" \"-DLLVM_PARALLEL_LINK_JOBS=1\" \"-DLLVM_TARGETS_TO_BUILD=X86\" \"-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=M68k\" \"-DLLVM_ENABLE_PROJECTS=clang;lld\" ..\n       ```\n    2. Build:\n       ```\n       ninja -j16\n       ```\n       (This step can take along time and a lot of memory if used with a lot of threads.)\n    3. You should now have all of the LLVM binaries in `build/bin`.\n    \n### Building Rust\n1. Checkout the [Rust fork](https://github.com/ricky26/rust) (clone the\n   m68k-linux branch).\n   \n2. Copy `config.toml.example` to `config.toml` and edit:\n    1. Set `[build] target = [\"x86_64-unknown-linux-gnu\", \"m68k-unknown-linux-gnu\"`\n    2. Set `[target.x86_64-unknown-linux-gnu] llvm-config = \"path/to/build/bin/llvm-config\"`\n    \n3. Build:\n    ```\n    ./x.py build --stage=2 rustc cargo\n    ```\n4. You should now have a Rust toolchain in `build/x86_64-unknown-linux-gnu/stage2`.\n5. Link the toolchain in rustup so it is easier to use:\n    ```\n    rustup toolchain link m68k \"path/to/build/x86_64-unknown-linux-gnu/stage2\"\n    ```\n\n### Building this repository\n1. Set the required environment variables:\n    ```\n    export MEGADRIVE_HOME=path/to/rust-mega-drive/share\n    export RUSTUP_TOOLCHAIN=m68k\n    export LLVM_CONFIG=path/to/llvm/build/bin/llvm-config\n    ```\n2. Build the tools \u0026 libraries:\n    ```\n    cargo build --release\n    ```\n3. Install the cargo tool:\n    ```\n    cd tools/cargo-megadrive\n    cargo install --path=.\n    ```\n4. Build the example Mega Drive image:\n    ```\n    cd examples/megapong\n    cargo megadrive build\n    ```\n5. You should now have an example megadrive image in\n    `target/m68k-none-eabi/release/megapong.md`.\n   \n# License\nThis suite is distributed under the terms of the MIT license. The full license\ntext can be read in LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricky26%2Frust-mega-drive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fricky26%2Frust-mega-drive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fricky26%2Frust-mega-drive/lists"}