oxid8-core 0.2.0

CHIP-8 interpreter core.
Documentation
  • Coverage
  • 100%
    19 out of 19 items documented1 out of 14 items with examples
  • Size
  • Source code size: 34.1 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 308.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 16s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • edibblepdx/Oxid-8
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • edibblepdx

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.