

In brief, CHIP-8 has 4k of RAM, although the first 512 bytes are used by the machine-specific interpreters (yes, just 512 bytes!). You can read more about CHIP-8, and the benefits of interpreters, from Joseph Weisbecker in his article for Byte Magazine. Interestingly CHIP-8 isn’t a physical architecture, it is a virtual machine that was implemented by a number of computers in the 1970 and calculators in the 1980s. Perhaps it made sense to start with something simpler?Īfter a bit of reading around I found that CHIP-8 () is a good starting point for would-be emulator authors due to its relatively simple instruction set and architecture. However, that architecture also makes it a real challenge to emulate. My initial idea was to write a Atari 2600 VCS emulator because its architecture is absolutely fascinating.

#Chip8 javascript emulator code
My earliest programming experiences were on early 8-bit microcomputers, and I’ve always enjoyed returning to writing code that is close to the ‘metal’. I must admit, writing an emulator has been on my programming ‘bucket list’ for a long time now. I’m not going to cover my CHIP-8 implementation in great detail, however, I will pick out a few areas which highlighted Rust language features that I enjoyed.īut before that, what’s CHIP-8 all about? CHIP-8 no GC and a minimal runtime), that would be fun to learn. So for my CHIP-8 emulator I wanted a language with relatively mature WebAssembly support (if that’s such a thing!), that doesn’t create bloated binaries (i.e. We’re poised to be THE language of choice for wasm. Rust is looking to be a popular choice for WebAssembly and its community is really embracing it …

This, combined with an active community, has contributed to it holding the title of “Most Loved Language” It also has many language features in common with other modern programming languages such as Swift. Rust is a relatively new language (2010) which, while syntactically similar to C++, is designed to be more ‘safe’. The most mature support is for C / C++ via Emscripten, although if I’m being totally honest, I don’t really like C++ … or Emscripten! WebAssembly currently lacks a garbage collector (GC), and as a result languages that don’t require a GC tend to have better support. While there are a number of languages with support for WebAssembly, many of these are quite immature in their implementation. It’s also hosted online if you want to have a play (I’d recommend Kraftwerk’s Computer Love as suitable backing track!). You can find the code for the finished emulator on GitHub. I wanted to try my hand at creating a more complex WebAssembly application, which is why I’ve been spending my evenings working on a CHIP-8 emulator … and learning Rust! Over the past couple of months I’ve been exploring the potential of WebAssembly initially looking at compilation options and performance, and more recently the migration of D3 Force Layout to WebAssembly using AssemblyScript.
