Giter Club home page Giter Club logo

chip8-cuda's Introduction

CHIP8 on CUDA

This is an interpreter for the CHIP-8 CPU that runs (almost) entirely on a CUDA kernel. Simple as that.

Disclaimer

This is literally the first time I'm working with CUDA (besides cryptomining). Be aware that the code might be very, very bad, as well as the performance. The way I'm moving memory in and out of the GPU is slow and there are probably better ways of doing so. Also, Python might screw up the performance a bit.

I don't think I have to say this, but don't use this in any kind of production environment. This was just for fun and a way of learning new stuff. And, finally, feel free to contribute if you want to.

Background

I was on vacation (at home due to the pandemic outside) and was wondering what can a GPU do (besides math). Computers are basically powerful calculators, so I was wondering if I could emulate another architecture inside a GPU. I thought at first about targeting a GameBoy CPU, or maybe an AVR which I'm familiar with, but they require some I/O i wasn't willing to implement. So I googled for "the simplest CPU to create an emulator for" (for real), and CHIP-8 came up.

The implementation is heavily based on Cowgod's Chip-8 Technical Reference and Werner Stoop's implementation.

Usage

Assuming you want to run this, all you gotta pass as argument is the path of a .ch8 file (CHIP-8 binary code). The code requires Numba, NumPy and SDL2 (for the display) to work. It has a few flags that help debugging and dealing with weird code, such as exiting on 0x0000, infinite loops and even VF compatibility mode for some test programs.

Right now there are a few test programs that more or less run on it:

  1. BC_TEST (passes)
  2. C8_TEST (error 16)
  3. chip8-test-rom (runs fine)
  4. SCTEST (error)

And a few programs that actually load:

  1. MAZE (runs fine)
  2. PONG (runs fine but does nothing)

The ROMs above have links to the repository I got them from if you want a copy.

Known bugs and limitations

  1. Keyboard is not implemented yet, so keyboard-related instructions will fail.
  2. Timer/delays/sound/etc do nothing. They still need to be coded.
  3. Display has a single mode (the original).
  4. RND crashes the CUDA interface when using a device different than 0. Seems to be a bug on Numba actually.
  5. Code runs on a single thread (I guess), so the GPU is just an expensive single-core CPU.
  6. The SDL code is messy and the performance is bad.

chip8-cuda's People

Contributors

nconder avatar rgsilva 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.