Code Monkey home page Code Monkey logo

oito's Introduction

Oito

Oito is a personal project that I wanted to make in my free time. I always had interest on emulation so I decided to make my own Chip8 emulator, the first step to anyone wanting to join the emulation world.

The idea behind Oito was to build the core of the emulator using Rust and a very component oriented approach. This means that the goal of this emulator is not searching the best performance as it is in a lot of cases, but to model the emulator in a way that it's easy to understand how the "physical" components would work and communicate. This doesn't mean that I didn't put some though into performance, I'm using Rust after all, but it's not the main objective.

Over that core there are two front-ends: one for desktop using SDL2 and the other for web using HTML5 and compiling Rust to WASM. So, you can run it as you want. The web version is also published with GitHub Pages using Actions.

Hope you like it.

Architecture

Oito is not modeled after the Chip8 virtual machine description. Of course, it follows it to perform the emulation, but the entities of it are not what was implemented. Oito architecture is based on real-life world architectures and components and it's like the following:

Oito architecture

Crates

The Oito emulator is made of four crates:

  • oito_core, library with all the internal logic of the emulator to be executed. The backend.
  • rom_loader, utility library to load the ROM in the OitoCore. It could have been part of SDL2 as it's the only crate using it but I don't discard to make another desktop version.
  • sdl2, executable that allows you to run the emulator in desktop with SDL2.
  • wasm, bundle of a library that compiles the emulator to WebAssembly, the script to execute and the rest of files to conform the webpage.

API

OitoCore offers the following interface to use it and it's what's implemented in both front-ends:

  • new, returns a new instance of the core with the preloaded sprites ready to be used.
  • load, loads the bytes of the ROM to execute.
  • tick, simulates a CPU tick. The first call to this function is the start of the execution of the loaded ROM. This should be used 10 times per frame rendering for max efficiency.
  • frame_tick, simulates a frame tick. This should be called with each frame render.
  • frame_buffer, returns the buffer representing the next frame to draw. It's made of booleans indicating if the pixel should be drawn or not (Chip8 was black and white).
  • key_press, to execute a key press event.
  • key_release, to execute a key release event.
  • sound, to know when to play the beep sound. It should be called after each frame tick.
  • default, returns a new instance without the preloaded sprites. This can't work with the common ROMs but it's useful for testing.

Any front-end should be able to make OitoCore run with this functions.

Usage

Refer to the instructions of each front-end:

Next

I'm not finished with Oito. I want to build some insights out of this experience. I always wanted to make a MdBook and I think that some kind of tutorial to make this could be a good option. I would also like to make some post over DEV or Medium, but I don't know yet.

oito's People

Contributors

kriogenia avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

riszl

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.