Writing a simple emulator from scratch is fun: rCHIP8
11 minute read
I’ve written about the CHIP-8 machine before. It is a very simple interpreted programming language that can be implemented very easily as a “Hello world” of sorts by people interested in getting their feet wet with emulators.
Some time ago I decided to implement a CHIP-8 emulator in Rust as my second project written in that language. My first foray into the language was the porting of the Gaia Sky LOD catalog generation tool from Java. This allowed us to substantially increase the generation speed and dramatically (really) decrease the memory consumption of the processing, to the point where a processing that previously needed more than 2 TB of RAM could now be done with less than a hundred gigs. Back to the topic at hand, I called my implementation rchip8 (very creative). This post describes the process and structure of such an emulator with more or less detail.
Over the last two weeks I have released the feature-packed version 3.1.0 of Gaia Sky. Two bugfix releases (3.1.1 and 3.1.2) followed shortly to fix bugs and regressions introduced in the former. This post contains a small rundown of the most interesting features in these three new versions. Let’s get started.
GNU screen is a terminal multiplexer that allows for different virtual windows and panes running different processes within the same terminal session, being it local or remote. This post contains a quick reference to the most used default key bindings of GNU screen. In contrast to other terminal multiplexers like tmux, GNU screen is probably already installed in your server of choice.
If you are not interested in tech in general and in NAS manufacturers in particular you may have missed the latest news on the shiny new exploit affecting QNAP NAS systems: the Qlocker. Basically, the attackers gained access to QNAP systems and used 7-zip to move the user’s files to password-protected archives. Then, they started a massive ransomware campaign asking for 0.01 BTC (around 500 USD) for the password to unlock the files.
Looking for new projects to sharpen my Rust skills, I came across a Reddit post where someone mentioned CHIP-8. CHIP-8 is an interpreted low-level programming language and virtual machine specification that is very commonly used as a “Hello world!” project of sorts for people to get their feet wet with emulator programming. It is simple enough to be able to implement a fully-featured emulator in a couple of sessions, but it has all the key parts of a real machine, to the point that are many projects that implement CHIP-8 directly in hardware.
I have since implemented my own CHIP-8 emulator in Rust (see repository here) with support for sound, display scaling, configurable colors, and more. But this text is not about it (I’ll write about my implementation in a future post). Today I want to fully describe the CHIP-8 machine, because I had fun implementing it, and I like it so much that I want to have it here for my future reference. In this guide, every instruction is accompanied with a small pseudo-code block to help understand the interpreter’s intended behavior to the more technically inclined reader.
The CHIP-8 specification document I used as reference to implement my version is Cowgod’s Chip-8 technical reference1, and I also had a look at a guide by Tobias V. Langhoff.2
Simple script to add a CPU core load to your favorite bar
3 minute read
A while back I changed my bar from Polybar to i3bar with i3blocks. One of the things I missed about Polybar is its internal CPU module, which can produce a core load graph directly in your bar by adding the right ramp characters. In this post I’m sharing a simple POSIX shell script I’ve written that does the same and can be used with any text-based bar. Here is what it looks like: