This RISC-V CPU games in Rust from inside the game

[Xander Naumenko] has created something truly impressive: a working RISC-V processor fully contained within a Terraria world. And then for more fun, he wrote the pong game, playable in real time, from the Terraria game. It's all based on the game's wiring system, combined with a little hack that uses the faulty lamp mechanism to create a very weird AND gate. In Terraria, existing logic gates have timing issues that make them ineligible for complicated projects like this. The faulty tube is intended to do random outputs, stacking multiple inputs to get a weighted output when a clock signal is applied. The hack is to simply give this device a single input, turning it into a clocked IF gate. Two of them together in series form a clocked AND gate, and two in parallel form a clocked OR gate.

Why would [Xander] embark on this legendary adventure? Apparently, after more than eight thousand clocked hours in the game, one gets bored of killing slimes and building NPC houses. And messing with the game's wiring system lit a metaphorical light bulb, that the system could be used to build some interesting systems. A prototype processor, with a completely custom instruction set, came next and was powerful enough to calculate Fibonacci. But that was obviously not enough. Come back after the break for the rest of the story and the awesome demo video.

Surprisingly, playing Terraria for three months improved my career prospects.

After this prototype worked, the obvious next step was to use the RISC-V specification to build an rv32i processor. And a display. Because the CPU must be able to play. The full version has a problem though. That's huge, and Terraria is really, really not designed for such complicated wiring projects. So naturally, [Xander] just rolled up his sleeves and rewrote Terraria's wiring system, in the form of the WireHead mod. Through a series of tricks, like looking at the wires as a whole, instead of each individual tile, he was able to run the processor at a blazing 5 MHz. Fast enough for pong, but slow enough that Conway's Game of Life has to be watched in fast forward.

The whole thing is very reminiscent of the Nand2Tetris course, as well as the equally impressive Minecraft computers we've already covered. And there's even more fun to come for Computerraria, as a low-res Doom clone is in the works, along with a video playback for the well-known Bad Apple. It's all open source and ridiculously well put together, so check it out!

This RISC-V CPU games in Rust from inside the game

[Xander Naumenko] has created something truly impressive: a working RISC-V processor fully contained within a Terraria world. And then for more fun, he wrote the pong game, playable in real time, from the Terraria game. It's all based on the game's wiring system, combined with a little hack that uses the faulty lamp mechanism to create a very weird AND gate. In Terraria, existing logic gates have timing issues that make them ineligible for complicated projects like this. The faulty tube is intended to do random outputs, stacking multiple inputs to get a weighted output when a clock signal is applied. The hack is to simply give this device a single input, turning it into a clocked IF gate. Two of them together in series form a clocked AND gate, and two in parallel form a clocked OR gate.

Why would [Xander] embark on this legendary adventure? Apparently, after more than eight thousand clocked hours in the game, one gets bored of killing slimes and building NPC houses. And messing with the game's wiring system lit a metaphorical light bulb, that the system could be used to build some interesting systems. A prototype processor, with a completely custom instruction set, came next and was powerful enough to calculate Fibonacci. But that was obviously not enough. Come back after the break for the rest of the story and the awesome demo video.

Surprisingly, playing Terraria for three months improved my career prospects.

After this prototype worked, the obvious next step was to use the RISC-V specification to build an rv32i processor. And a display. Because the CPU must be able to play. The full version has a problem though. That's huge, and Terraria is really, really not designed for such complicated wiring projects. So naturally, [Xander] just rolled up his sleeves and rewrote Terraria's wiring system, in the form of the WireHead mod. Through a series of tricks, like looking at the wires as a whole, instead of each individual tile, he was able to run the processor at a blazing 5 MHz. Fast enough for pong, but slow enough that Conway's Game of Life has to be watched in fast forward.

The whole thing is very reminiscent of the Nand2Tetris course, as well as the equally impressive Minecraft computers we've already covered. And there's even more fun to come for Computerraria, as a low-res Doom clone is in the works, along with a video playback for the well-known Bad Apple. It's all open source and ridiculously well put together, so check it out!

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow