Introduction to Chip-8


I’m guessing most of you have never heard of Chip-8 before… Neither had I. Although, to be fair, Chip-8 isn’t exactly a system… It’s an interpreted language. It’s reason for invention was to make it easier to program games on some mid-1970s computers but it later moved into graphing calculators in the late 1980s. As a result, it gained a huge following with hobbyists and enthusiasts.

The good thing about this is there is a massive amount of documentation and public domain ROMs that can be used when developing an emulator. And it’s these public documents that were a massive help! For the purposes of this tutorial, however, we’ll be referring to just the Wikipedia article about Chip-8 and Cowgood’s Chip-8 Technical Reference. However, once we’re all said and done, I will add an appendix with a couple of other resources that were quite useful as well, but you should be able to follow along with just these two.

Skills Required

Whilst this is intended as a tutorial, I will assume that you have at least a little knowledge of JavaScript. The knowledge that will help is declaring variables, functions, loops and conditional statements. There will be some bitwise operations, and other things that will pop up, but we’ll explain them as we go. To clarify: At least a basic working knowledge of JavaScript is required.

You should also have somewhere to test the code. This could be a local server or your own web server. I use http-server with Node.js in order to test locally. It’s quite simple to set up and requires you to download Node.js to your computer. If you have a local or a remote server, you can use that. I’ll briefly explain setting up http-server below…

Node.js and http-server

So… You want to do it this way, then? No worries. First thing: Grab and install Node.js for your machine. Once you’ve done that, we can continue.

Now… You’re going to need to create a directory for your development. On Windows, I normally have my development code in C:\Development, on Mac I have it in my home directory under Development\ and on Linux I use root\Workspace (I normally run as root on my machine). For this project I created a folder called JSEmu (you can call it what you like) and that’s where I put my files.

Now you should have Node installed, so we need to open a command prompt / terminal and get ourselves http-server.

On windows: 
npm install -g http-server

On Linux/Mac:
sudo npm install -g http-server

This should now install http-server. In the terminal you can now CD to your development folder and then just run:

http-server JSEmu

And it should now be accessible in a browser under http://localhost:8080. Remember to replace JSEmu with whatever you decided to call the folder for your files… And that’s it! Let’s start emulating.