Giter VIP home page Giter VIP logo

fchip's Introduction

FCHIP

FCHIP is a CHIP-8 interpreter (aka emulator) written in AssemblyScript. It comes with a web client optimized for speed and accuracy.

https://fchip.netlify.app

Netlify Status

screenshot.png

Features

  • Accurate cycle speed, independent of the screen framerate
  • Real-time adjustments of speed, screen size, volume and colors

What is CHIP-8?

From Wikipedia:

CHIP-8 is an interpreted programming language, developed by Joseph Weisbecker. It was initially used on the COSMAC VIP and Telmac 1800 8-bit microcomputers in the mid-1970s. CHIP-8 programs are run on a CHIP-8 virtual machine. It was made to allow video games to be more easily programmed for these computers, but CHIP 8 is still used today, due to its simplicity, and consequently on any platform and its teaching of programming Binary numbers.

Why?

I've been interested in emulators for as long as I can remember, and I always wanted to create my own one. Writing a CHIP-8 interpreter is considered to be a great introduction into emulators development, because of its simplicity and a lot of resources available.

Implementation overview

My main goal has been to write the most efficient and accurate interpreter running in a browser. This is achieved by running the interpreter core in WebAssembly, with a thin javascript layer handling input and output. They both share a memory buffer storing all the interpreter data. User interface is powered by a small Preact app.

Animation frame

Many existing browser-based interpreters execute a fixed number of cycles per animation frame. This makes their emulation speed being dependent on the current framerate. In FCHIP, a time difference is calculated between the current and previous frames. Based on the cycles per second setting, a specific number of cycles is then executed to maintain the target speed, regardless of the screen framerate.

At the end of each animation frame callback, the screen buffer is painted directly onto canvas in its original resolution. It is then scaled up to the full size of canvas, with imageSmoothingEnabled turned off to avoid blurry pixels.

Timers

For the delay and sound timers running at 60 Hz, a self-correcting recursive setTimeout implementation is being used instead of using setInterval. This is to achieve the most precise intervals possible.

Planned features

  • Improve roms compatibility
  • Add support for various CHIP-8 extensions (SCHIP, GCHIP, XO-CHIP...)
  • Customizable controls

Useful resources

Credits

Included games were downloaded from David Winter's CHIP-8 emulation page

Bug reporting

If you find a bug, please send me an e-mail to [email protected] or open an issue here on github.

License

ISC

fchip's People

Contributors

jakubito avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.