| Crates.io | oxid8-core |
| lib.rs | oxid8-core |
| version | 0.2.0 |
| created_at | 2025-06-30 02:50:06.934035+00 |
| updated_at | 2025-07-31 04:57:56.544649+00 |
| description | CHIP-8 interpreter core. |
| homepage | https://edibblepdx.github.io/Oxid-8/ |
| repository | https://github.com/edibblepdx/Oxid-8 |
| max_upload_size | |
| id | 1731353 |
| size | 34,111 |
Oxid-8 CoreThis 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.
▄▄▄▄ ▄▄▄▄
█ █ ▜▄▛ █ █▀▄ ▄▄ █▄▄█
█▄▄█ █ █ █ █▄▀ █▄▄█
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(())
}
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"']
This project is licensed under the MIT License.