Skip to content

ArjunNair/chip3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chip3 - A Chip8 Emulator

About

Chip3 is a Chip-8 emulator written in C3. It emulates all of the instructions, including some ambiguous ones. There are various sources that document the Chip-8 specifications and the instructions. Some resources that I found useful:

* [Cowgod's Chip-8 Technical Reference](http://devernay.free.fr/hacks/chip8/C8TECH10.HTM)
* [Chip-8 Tutorial](https://www.chip-8.com/tutorial)
* [Massung's info on Chip-8](https://github.com/massung/chip-8)

The emulator is a port of the original C++ emulator I wrote previously, with some noteable differences:

  • There is no GUI.
  • I didn't bother implementing sound in this version because it's a real pain for what is essentially a very boring beeper.
  • It tries to maintain 60FPS in a lazy manner by calculating how much time it took to render one frame, and sleeping a bit if it's under 16ms (which is roughly but not quite 60Hz). The original C++ version actually syncs framerate to the sound which plays at 60Hz and is a lot more timing accurate.

Building and running the emulator

Building the emulator is easy due to C3's build system. First ensure you have installed C3 lang.

To build: c3c build

To run: c3c run

To build a distributable: c3c dist

Command line arguments:

The first parameter after the executable name is the path to the chip8 ROM of your choice. For example: c3c run -- ./resources/BRIX.ch8

Note that if you create a distribution, the path needs to be adjusted relative to the executable.

Other flags:

--shiftUsingVY

The original Chip8 specs for the 'shift' instruction required the Vx register to be the shifted value of Vy, but someone didn't get the memo apparently and most implementations tend to use the shifted value of Vx instead. This flag allows for the possibility to use the original specs instead.

--incrementIOnLD

Another quirk is that some specs call for the I register to be incremented for LD [I], Vx instruction. When enabled, this flag emulates the behaviour.

Examples usage: c3c -O1 run -- ./resources/BRIX.ch8 --incrementIOnLD

The above enables O1 optimization (optional), loads the BRIX.ch8 program in resources folder and enables incrementIOnLD flag.

About

Chip8 emulator written in C3.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages