My first little emulator of a Chip-8
So I first decided to code this Chip-8 emulator around a week ago as I've really wanted to get into emulation and as far as I was aware - writing one is the best way to learn about it. And I can definitely agree. I learnt a lot when going through this and searching the net for info, how to do certain things, using libraries etc and it has all been a great experience. The plan was that this would introduce me to the basics of emulation so I can progress to coding a Gameboy DMG-01 emulator... eventually.
I started where most people probably would: how to code a chip 8 emulator search in Google. I found the multigesture post linked at the bottom and I got going. I modelled the CPU, added the emulators basic functions and it was all good. I then tweaked around with some of the modelling for example using the header so I could model the registers as uint8_t rather than unsigned char. These little things just made it a bit easier to understand and keep track of everything. After that I went on to begin decoding the opcodes using the Cowgod's technical reference linked down below (as best as I could) and then took a look at a couple of the other emulators down below as reference on some of the instructions I was unsure about. When I finished writing them for the first time and had fixed the small syntax errors etc. I ran the program and it was fine! I couldn't believe that it actually worked (wasn't what I was expecting but then again there are only 36 instructions). I went on to looking at how I was going to draw the graphics. From what I had looked up I was either going to use SDL2 or GLUT. After playing round with both I decided to go with GLUT - primarily because it ships with OSX but also because it just seemed a bit easier to setup and initialise. To draw the graphics on screen was fairly simple as the Chip-8 has monochrome graphics and a 64 x 32 pixel display. Just iterate through my screen array and draw the pixels. On first run the picture was a mess. So I spent around an hour going back through my opcodes optimising some and correcting others and now that is all done so here we have the Chip-Emul8.
The only thing I have planned for now is to implement sounds, that's it.
Currently I've only tested this on Mac and I believe you have to download GLUT on other OSs. First off, download the repo and open it up. Navigate to the directory and run
FYI: If you have updated to sierra, some of the GLUT library has been fully deprecated and so will no longer compile.
After that, to use the emulator type
```./ch8 ./```Controls... I'm not exactly sure as to the controls for all the games but the keys will be one of: 1, 2, 3, 4, q, w, e, r, t, y, a, s, d, f, z, x, c, v. To quit the emulator press esc.
To be done..
Exact same as Mac.
https://en.wikipedia.org/wiki/CHIP-8#Virtual_machine_description
http://devernay.free.fr/hacks/chip8/C8TECH10.HTM
http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/
http://mattmik.com/files/chip8/mastering/chip8.html
http://fms.komkon.org/EMUL8/HOWTO.html
http://www.linuxquestions.org/questions/programming-9/c-howto-read-binary-file-into-buffer-172985/
https://github.com/eshyong/Chip-8-Emulator