{"id":13578798,"url":"https://github.com/misprit7/computerraria","last_synced_at":"2025-05-14T01:02:24.644Z","repository":{"id":85648054,"uuid":"602870090","full_name":"misprit7/computerraria","owner":"misprit7","description":"A fully compliant RISC-V computer made inside the game Terraria","archived":false,"fork":false,"pushed_at":"2025-03-24T01:08:52.000Z","size":37301,"stargazers_count":3588,"open_issues_count":0,"forks_count":46,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-04-03T09:39:48.105Z","etag":null,"topics":["logic-gates","risc-v","riscv","terraria","terraria-mod"],"latest_commit_sha":null,"homepage":"https://youtu.be/zXPiqk0-zDY","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/misprit7.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":"2023-02-17T05:34:39.000Z","updated_at":"2025-04-02T14:14:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"fba4144b-a18c-4f13-84f2-e3a7f6e7fdde","html_url":"https://github.com/misprit7/computerraria","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/misprit7%2Fcomputerraria","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misprit7%2Fcomputerraria/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misprit7%2Fcomputerraria/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/misprit7%2Fcomputerraria/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/misprit7","download_url":"https://codeload.github.com/misprit7/computerraria/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248228418,"owners_count":21068683,"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":["logic-gates","risc-v","riscv","terraria","terraria-mod"],"created_at":"2024-08-01T15:01:33.847Z","updated_at":"2025-04-10T13:51:19.647Z","avatar_url":"https://github.com/misprit7.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cpicture\u003e\u003cimg src=\"./doc/img/logo.png\" height=\"400\"/\u003e\u003c/picture\u003e\n  \u003cbr /\u003e\n  Computerraria\n\u003c/h1\u003e\n\u003ch2 align=\"center\"\u003e\n  A fully compliant RISC-V computer inside Terraria\n\u003c/h2\u003e\n\u003ch2 align=\"center\"\u003e\n  Video explanation: https://youtu.be/zXPiqk0-zDY\n\u003c/h2\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=https://github.com/misprit7/computerraria/actions/workflows/in-game-tests.yml\u003e\n    \u003cimg src=https://github.com/misprit7/computerraria/actions/workflows/in-game-tests.yml/badge.svg/\u003e\n  \u003c/a\u003e\n  \u003ca href=https://github.com/misprit7/computerraria/actions/workflows/rust-tests.yml\u003e\n    \u003cimg src=https://github.com/misprit7/computerraria/actions/workflows/rust-tests.yml/badge.svg/\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n# Pitch\n\nThere are two fundamentally competing forces when it comes to computer speed. The first, and most famous, is Moore's law, where physical transistor densities scale exponentially. The second is the inevitable growth of software bloat that runs on top of increasingly modern processors. There's a kind of equilibrium between these two competing beasts, ensuring that a user always manages to get at least a split second of mindfulness while staring at a frozen screen whenever attempting to open the latest app. \n\nThis project is an attempt to score a decisive rout in this ongoing battle in favor of the *programmer*. By emulating a complete rv32i instruction set inside the wiring system of [Terraria](https://www.terraria.org/), we push back speeds to the early 70s era, tossing the ball firmly back into the court of the silicon engineer without losing any software functionality. \n\n# Overview\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=https://easyzoom.com/image/412333\u003e\n    \u003cimg src=\"doc/img/poster-small.png\"/\u003e\n    Click to see navigable image\n  \u003c/a\u003e\n\u003c/div\u003e\n\nDespite what the pitch may lead one to believe the goal of this project is to maximize the compliance and processing ability of the in game cpu. This is only possible with the help of an accelerator mod, which maintains full compatibility with the vanilla wiring system but reimplements it in a much more efficient manner:\n\n[WireHead](https://github.com/misprit7/WireHead) - A wiring accelerator and headless control mod\n\nWith this installed, the current specs of the computer are as follows: \n\n- Clock speed: ~5kHz\n- Ram: 96kb\n- Instruction set: rv32i\n\nAs an example of what it can do, here is Pong, running purely on the in-game cpu (see [app/pong/src/main.rs](app/pong/src/main.rs) for implementation):\n\nhttps://user-images.githubusercontent.com/33139843/229342342-de4708e1-7467-4f99-834b-3d0fb28d0858.mp4\n\n# Setup\n\nNote that currently only Linux is fully supported, and only parts of this have been tested on Windows. However I've left some steps for anyone who wants to try getting Windows working, in theory using wsl it should be fairly straightforward and things should be identical.\n\n## Prerequisites\n\nFor a comprehensive list of everything that is needed to run all aspects of this project, see the [Dockerfile](docker/Dockerfile). However, to develop and run applications for the computer all you really need is a working Cargo/rustc installation, install it [here](https://www.rust-lang.org/tools/install) or through your package manager.\n\n## Setup Process\n\nNavigate to where you want to keep this project and clone it. Copy computer.wld to your tModLoader world path. Depending on your platform, this is:\n```\nWindows: Documents\\My Games\\Terraria\\ModLoader\\Worlds\nLinux: ~/.local/share/Terraria/tModLoader/Worlds\n```\nOn Linux you can automate copying back and forth like this with the `copy-world.sh` script with either the `--to` (copy to world folder) or `--from` (copy from world folder) flags.\n\nNext, navigate to the mod sources folder and clone [WireHead](https://github.com/misprit7/WireHead):\n```\n#Windows\ncd \"%userprofile%\\Documents\\My Games\\Terraria\\ModLoader\\ModSources\" \u0026\u0026 git clone https://github.com/misprit7/WireHead.git\n\n#Linux\ncd \"~/.local/share/Terraria/tModLoader/ModSources\" \u0026\u0026 git clone https://github.com/misprit7/WireHead.git\n```\n\nPrepare the binary you wish to run. For example for pong compile the rust app and copy the binary to a more convenient path:\n\n```\ncd \u003cpath to computerraria\u003e/app/pong\ncargo rb\n./copy-bin.sh /tmp/pong.txt\n```\n\nStart [tModLoader](https://store.steampowered.com/app/1281930/tModLoader/), and from the main menu go to Workshop-\u003eDevelop and click on the Build button next to WireHead. For convenience I'd also recommend installing Cheat Sheet and HERO's Mod from the Download Mods section of the workshop if you haven't already. Then open the new world you copied earlier in game. In game type:\n```\n/bin write /tmp/pong.txt\n```\n\nCurrently the NPCs that run the CPU clock are too far away to spawn immediately, this is a bug and should be fixed soon. As a workaround, go through the blue teleporter shown below, fly upwards a bit, come back down and go back through the same teleporter.\n\n![Control Panel](doc/img/control-panel.png)\n\nAfter this workaround is done, press the first two of the three levers on the far right to start the program. Go through the orange teleporter to arrive at the screen area. Pong should be running and is controllable by the controller beneath the screen (use HERO's Mod's camera lock to see the screen and controls at the same time).\n\n![Pong](doc/img/pong-still.png)\n\n## Docker\n\nFor advanced CI/headless usage you can use the docker image:\n\n[Docker Image](https://hub.docker.com/r/misprit7/computerraria)\n\nIf you already have docker installed this can be pulled with\n\n```bash\ndocker pull misprit7/computerraria\n```\n\nYou can then start the container with\n\n```bash\ndocker run -it misprit7/computerraria\n```\n\nThis image already has all tooling installed so you should be able to build everything. \n\n# File Structure\n\nThe major relevant parts of the project are as follows:\n\n```\n.\n├── app/\n│   ├── tdriver/\n│   └── template/\n├── computer.wld\n├── doc/\n├── docker/\n├── test/\n└── tinterface/\n    ├── bin/\n    └── tinterface/\n```\n\n`app/`\n\nHigher level applications to be run on the computer, not including compliance tests. Currently all in rust but could also easily be in C. \n\n`app/tdriver/`\n\nDriver API for interacting cpu from rust, mostly extremely low level startup code and graphics drivers.\n\n`app/template/`\n\nTemplate for new rust projects that implements minimal tdriver\n\n`computer.wld`\n\nThe actual world file. This is technically a binary file, but given the context of the project it acts much more like source code given that it is edited manually and compresses extremely well. This generally isn't edited in place, it's copied back and forth to the user installation with [copy-world.sh](copy-world.sh). \n\n`doc/`\n\nDocumentation/notes for the project\n\n`docker/`\n\nFiles required to build docker image for CI. \n\n`test/`\n\nAll automated tests written for the CPU. These are mostly handled through [riscof](https://github.com/riscv-software-src/riscof). This consists of both the computerraria plugin as well as a reference plugin ([sail_cSim](test/sail_cSim/)) to compare the results to. \n\n`tinterface/`\n\nInterfaces programmatically with running Terraria instance. This consists of both a python module as well as a command line wrapper to upload binaries, start execution and manipulate other fine grain controls without needing a GUI. \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisprit7%2Fcomputerraria","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmisprit7%2Fcomputerraria","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmisprit7%2Fcomputerraria/lists"}