[Demo]CHIP-8 Interpreter

The CHIP-8 is a virtual machine designed in the 1970s for creating simple games. I tried making a quick port of an existing CHIP-8 interpreter, and I partially succeeded. Here is it running the Trip-8 demo rom:

I can run CHIP-8 roms successfully, but after a seemingly random delay the simulator freezes completely. I can only imagine this being a threading issue, so I’m not sure if there’s something in the CHIP-8 interpreter I ported causing problems, an issue with how I used the APIs, or whether there’s a bug in the simulator. I may also still be using some libraries that the interpreter originally used that the Pokitto won’t have, which means it might not work on hardware without minor modification. That said, I feel fairly confident that this will work on a Pokitto without too much trouble because I managed to port the interpreter to the Gamebuino with much more effort and this should be easier. With the Pokitto’s specs, I think the limited resources of the CHIP-8 shouldn’t be much trouble to handle at full speed.

Here are the files. I simply modified the example Hello World simulator project by adding chip8.c, modifying Hello.cpp, and adding the two header files chip8.h and trip8.h. Since this project was a quick experiment I didn’t set up a proper git repo yet, so I just added the files to a gist for now:

5 Likes

I want to give this 10999 hearts.

2 Likes

Yes, it is a threading issue and it has something to do with SDL2. And it only appears with some programs, not all. I have been trying to find it like crazy but have not managed to trace it to any specific cause.

Edit: does it happen at random or exactly at same time if you run the same program exactly?

It happens at random. It can run only a couple seconds or up to about a minute before freezing on the same program, but it never seems to freeze in the same place. I added a counter that increments every frame and it usually doesn’t make it to 1500 before a freeze.

Well. I am pretty close to getting the linux version to compile. Then we can (hopefully) test it on linux and see if the problem reappears

1 Like

While I’m honored you thought of my topic when tagging the CHIP-8 interpreter, the gif demoing the interpreter is from @Initgraph’s arguably superior version that I think is completely unrelated to mine. His topic might be more deserving than mine to be tagged as a full game, since my version didn’t progress past a proof-of-concept.

By the way, I tried finding the source of Initgraph’s interpreter, but I wasn’t able to find it. Is there a link?

2 Likes

Thank you for your remark Wuuf. My Chip-8 editor is not finished too, you can download a WIP version here if you want : http://www.initgraph.com/download/Chip8_20170712.zip.
Please keep in mind that the source is dirty and the project still experimental, I have to finish it when I will have time :grimacing:

2 Likes

You accidentally added a 1 to the link which makes it not work.
Removing the 1 on the end fixes it.

Generally the code is pretty good.
Glad to see someone using the uint8_t and uint16_t types.
(One or two things that I’d nitpick though.)

2 Likes

Thank you, bad copy-paste :frowning:
The link should work now.
Yes I like to use intX_t and uintX_t type especially for this kind of device :slight_smile:

2 Likes

Attributed to @Initgraph. Thanks for the heads up @wuuff

1 Like

Wait, this post was originally mine though. Initgraph made another thread posting his CHIP-8 interpreter, but this thread really did show mine originally.

2 Likes

Sorry. Will fix

2 Likes