Chip8 emulator

Chip8 emulatorHere it is – a “working” Chip8 emulator done using Actionscript3. This idea came from André Michelle when he asked in the Flashforum who would be interested in working on an emulator. I am always interested in working with assembler, memory access and things like shellcode. :)

I found a lot of information about emulating Chip8 using Google. Good resources were EmuTalk.net, CHIP8 (also an emulator), and a list where all ASM instructions are explained.

Emulating Chip8 is a very easy thing. You have just a small manageable piece of instructions and a simple sort of memory. But I have to mention that my emulator has got some bugs because it is hard to test your piece of work. An error could be in every function (like add, substract, etc.) or even where a variable gets stored in the register.
Because of this I wrote a simple disassembler. The output is the whole rom in ASM syntax which Flash “evaluates”.
This is how the debugger outputs the instructions (Address: opCode ASMequivalent):

0x03a3: 0x13af jmp 943
0x03af: 0xa50a mvi 1290
0x03b1: 0xf01e adi v0
0x03b3: 0xdbc6 sprite v11,v12,6

In fact it is not very easy to recognize an error but makes it more comfortable. I would suggest to take a look at the function in AS3 instead of trying to figure out what the ASM code really does but I was able to find some bugs with the ASM instructions. Another thing with the memory was comparing my memory to the memory of an emulator written in C++.

Currently all keys are a little bit screwed because I have no time to take a closer look here. You can play the MISSILE rom online and of course play around with the sourcecode which has a lot of comments. You can press i to shot if you play the MISSILE game; space resets the emulator. Have fun with this oldschool machine :o)

8 Comments

  1. Posted Dec 7, 2005 at 1:07 pm | Permalink

    Awesome. I love stuff like that.
    Anyone wants to team up with me to write a MOS 6502 emulator? :)
    claus dot wahlers at gmail dot com

  2. Edwin Smith
    Posted Dec 10, 2005 at 1:15 am | Permalink

    Very Cool! If you have any AS3 performance tuning questions, send them my way.

  3. Newsdee
    Posted Dec 21, 2005 at 1:13 am | Permalink

    Actually you can also emulate Chip8 with AS2.0 and Flash8… Check my emulator on http://newgrounds.com/portal/view/260625

  4. ripx
    Posted May 8, 2006 at 4:53 pm | Permalink

    Actually, i wrote a chip8 emulator some time ago in actionscript 1

  5. Posted Apr 10, 2007 at 11:38 pm | Permalink

    Winrar thought me that zip file
    http://je2050.de/files/source/chip8.zip
    is broked, can you upload again?

    Dark-N

  6. Posted May 16, 2007 at 2:28 am | Permalink

    Don’t use winrar to open it use Windows’ own Compressed file archive-er thing :D

  7. Posted Feb 7, 2008 at 11:01 pm | Permalink

    very cool! so when is a gameboy or nintendo version coming ;)

  8. Posted Mar 8, 2008 at 10:36 pm | Permalink

    Hi there !. I would like to ask about the sub operation. Let’s say that we have the following instruction sub v1, v2. Register v1 has the value 180 and v2 has the value 190. The final result in v1 is 245 and vf is set to 01 ? Is that correct ?

    Thanks !

3 Trackbacks

  1. [...] cember 7th, 2005 joa ebert has done the [...]

  2. By CHIP-8 « Necrobits on Mar 19, 2007 at 12:35 am

    [...] Chip-8 emulator en Flash [...]

  3. By < ByteArray.org on Jun 2, 2009 at 7:12 pm

    [...] programming has always been something really interesting to me. Joa, Claus and Darron and Jon Pollard already did some really cool stuff in AS3 concerning emulation [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*