Coder Social home page Coder Social logo

chip-8's Introduction

CHIP-8 Emulator

A simple emulator for the CHIP-8 interpreted programming language written in C (SDL for graphics).

About

This is a really basic emulator written for educational purposes, the code is meant to be readable and clear, with a lot of comments. I am a beginner in this field and this is my first attempt to emulators. I have implemented this project mainly by following the Wikipedia page and this awesome resource; I had no experience with SDL either so I have helped myself during that process with various resources online. The most important part to me was understanding the architecture itself, not the graphics.

Requirements

This project has been developed under a Linux system.

  • SDL library
  • C compiler

Run

make

./bin/emulator.out <game_rom_path>

Or you could use the test_emu script I wrote to automate the process of testing the program.

./test_emu.sh

Quick Walkthrough

By reading here:

Chip-8 is a simple, interpreted, programming language which was first used
on some do-it-yourself computer systems in the late 1970s and early 1980s.
The COSMAC VIP, DREAM 6800, and ETI 660 computers are a few examples.
These computers typically were designed to use a television as a display
had between 1 and 4K of RAM, and used a 16-key hexadecimal keypad for input.
The interpreter took up only 512 bytes of memory, and programs, which were entered into the computer in hexadecimal, were even smaller

So this emulator replicates this behaviour by creating a virtual machine with the following specs:

  • 4096 Bytes of memory
  • 16 general 8-bit purpose registers
  • A special 16-bit register
  • ProgramCounter and StackPointer pseudo registers
  • The stack (array of 16 16-bit values)
  • The keypad (adapted to modern keyboards)
  • 64x32 pixels monochrome screen
  • Delay timer
  • Sound timer

The emulator is then able to run .ch8 games. Please note that I have written only the emulator itself, not the games (freely accessible on the Internet).

The emulator logic consits of parsing and executing the instructions coming from those games.

scr_1

The default mode is debug mode, which outputs a lot of stuff to the screen, if you want to disable it you have to set the int DEBUG = 1; variable to 0 in chip8.c.

Improvements

  • Sound support
    • I was lazy and focused more on the interpreter so there's no sound here
  • Use function pointers instead of big switch statements.

References

Another good article

Improvements

chip-8's People

Contributors

f0lg0 avatar guijan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.