Overview
Here is how I decided and built a Silverlight Chip8 emulator.
Download ChipGr8 Source Code
What is Special About Chip8?
Chip-8 is a small interpreter created in the early 70's that has these nice features:
- Is very easy to emulate (in 4 or 5 hours you can have a working emulator!)
- Has 2d sprite drawing and pixel-perfect collision detection
- Has sound and keyboard support
If you decide to create your own emulator, chip-8 is probably one of the best to start. The "all-in-one" peripherals make it
very easy to emulate the keyboard and screen.
How to Create Your Own Computer Emulator
- Decide on a programming language. C++ is fast. C# is cool and is working with Silverlight!
- Decide what you want to emulate.
At first I started with x86 (8086) emulation - wanted to play Digger badly :)
It turned out to be more time consuming, because of all the peripherals:
PCI bus, VGA adaptor, Keyboard, Interrupt Controller, etc, etc.
After I found the chip8, it turned out it has several registers, several keyboard commands and 4K memory and
25 games!
This sounds very promising!
Source Code Architecture
This is pretty easy:
- Make a big array for the memory. In Chip8-s case I used 65536 bytes array, since this was the chip's address space
- Add a C# class for screen manipulation.
Chip8 contains several screen commands: PutPixel() (always XOR-ed), scroll left, scroll right, scroll down.
I decided it makes sense to put these in separate class.
- Create the class for the chip
This is the class that contains the main variables: InstructionPointer (shows the next instruction to execute), stack,
CPU registers and such.
An interesting challenge is generating the screen image using Silverlight.
After searching around I found a PNG encoder for Silverlight implementation that is very usable for dynamic image generation.
Chip Architecture
For a very good explanation about the Chip8 architecture click
here.
Back to ChipGr8