Skip to content

shnupta/Chip-Emul8

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chip-Emul8

My first little emulator of a Chip-8

The Idea

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.

What I Did

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.

Plans

The only thing I have planned for now is to implement sounds, that's it.

Screenshots

Mac

Linux

How To Use 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

Mac

FYI: If you have updated to sierra, some of the GLUT library has been fully deprecated and so will no longer compile.

```make build```

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.

Windows

To be done..

Linux

Exact same as Mac.

Feel free to use the code so long as you give credit to me.

Here are some useful links:

About the CHIP-8:

https://en.wikipedia.org/wiki/CHIP-8#Virtual_machine_description

Chip-8 Opcodes:

http://devernay.free.fr/hacks/chip8/C8TECH10.HTM

Writing an emulator:

http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/

http://mattmik.com/files/chip8/mastering/chip8.html

http://emulator101.com/

http://fms.komkon.org/EMUL8/HOWTO.html

ROMS:

http://www.zophar.net/

Reading in files as byte arrays:

http://www.linuxquestions.org/questions/programming-9/c-howto-read-binary-file-into-buffer-172985/

Some other good emulators:

https://github.com/eshyong/Chip-8-Emulator

https://github.com/bryangarza/chip8

https://github.com/prophittcorey/iC8

About

A little Chip-8 emulator

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published