schip8

Crates.ioschip8
lib.rsschip8
version0.1.0
sourcesrc
created_at2023-07-29 14:20:34.367743
updated_at2023-07-29 14:20:34.367743
descriptionInterpreter backend for Chip-8 and Super-Chip
homepage
repositoryhttps://github.com/overthemil/schip8/
max_upload_size
id929278
size39,216
Pedro (skrewby)

documentation

README

Schip8

A library with the aim to provide a simple CHIP-8 interpreter backend that can integrate into any graphics library or renderer of your choosing.

Examples

Quickstart

This is a basic skeleton of how to start implementing a frontend. It's recommended to use the [anyhow] crate as well.

use schip8::Chip8; 
use anyhow::{Context, Result};

fn main() -> Result<()> {
    let mut chip = Chip8::default();
    
    // The load_file function needs to be implemented
    let file = load_file("roms/TETRIS")?;    
    chip.load_rom(&file).context("Loading ROM file")?;

    // Use the frontend to make this loop run at 60 Hz
    loop {
        // Process input
        // ...

        chip.tick().context("Interpreter tick")?;

        // Render screen - check the examples for scaling demo 
        for y in 0..chip.screen.height {
            for x in 0..chip.screen.width {
                if chip.screen.get_pixel(x, y) {
                    // Draw
                }
            }
        }

        // Reset with chip.reset() if reset key is pressed

        if chip.should_play_sound() {
            // Play a tone
        } 
    }
}
Commit count: 16

cargo fmt