oxid8-core

Crates.iooxid8-core
lib.rsoxid8-core
version0.2.0
created_at2025-06-30 02:50:06.934035+00
updated_at2025-07-31 04:57:56.544649+00
descriptionCHIP-8 interpreter core.
homepagehttps://edibblepdx.github.io/Oxid-8/
repositoryhttps://github.com/edibblepdx/Oxid-8
max_upload_size
id1731353
size34,111
Ethan Randolph Dibble (edibblepdx)

documentation

README

Oxid-8 Core

This is the core interpreter library for Oxid8. Developers can create their own renderers on top of this library crate. It is a Chip-8 interpreter core written in rust. Try it out in the web with WGPU. More examples to be found in the GitHub repo.

▄▄▄▄              ▄▄▄▄
█  █ ▜▄▛ █ █▀▄ ▄▄ █▄▄█
█▄▄█ █ █ █ █▄▀    █▄▄█

oxid-tetris

Getting Started With a Basic Example

use oxid8_core::Oxid8;
use std::time::{Duration, Instant};

#[derive(Default)]
struct State {
    should_exit: bool,
    last_frame: Option<Instant>,
}

#[derive(Default)]
struct Emu {
    state: State,
    core: Oxid8,
}

fn main() -> anyhow::Result<()> {
    let mut emu = Emu::default();
    emu.core.load_font();
    emu.core.load_rom("rom_path")?;

    while !emu.state.should_exit {
        let time = Instant::now();

        // TODO: Poll and Handle Events.

        if let Some(last_frame) = emu.state.last_frame {
            if time.duration_since(last_frame) >= Duration::from_millis(16) {
                emu.core.next_frame()?;

                // TODO: Draw current frame.

                emu.state.last_frame = Some(time);
            }

            if emu.core.sound() {
                // TODO: Beep!
            }
        } else {
            emu.state.last_frame = Some(Instant::now());
        }
    }

    Ok(())
}

WASM Compatibility

Add the following to your Cargo.toml and config.toml.

# Cargo.toml

[dependencies]
web-time = "1.1.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }
# config.toml

[target.'cfg(target_arch = "wasm32")']
rustflags = ["--cfg", 'getrandom_backend="wasm_js"']

License

This project is licensed under the MIT License.

Commit count: 0

cargo fmt