Initial commit: NES emulator with GTK4 desktop frontend
Some checks failed
CI / rust (push) Has been cancelled
Some checks failed
CI / rust (push) Has been cancelled
Full NES emulation: CPU, PPU, APU, 47 mappers, iNES/NES 2.0 parsing. GTK4 desktop client with HeaderBar, pixel-perfect Cairo rendering, drag-and-drop ROM loading, and keyboard shortcuts. 187 tests covering core emulation, mappers, and runtime.
This commit is contained in:
10
crates/nesemu-adapter-headless/Cargo.toml
Normal file
10
crates/nesemu-adapter-headless/Cargo.toml
Normal file
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "nesemu-adapter-headless"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
description = "Headless/null adapter implementations for nesemu adapter API"
|
||||
license = "MIT OR Apache-2.0"
|
||||
rust-version = "1.85"
|
||||
|
||||
[dependencies]
|
||||
nesemu-adapter-api = { path = "../nesemu-adapter-api" }
|
||||
52
crates/nesemu-adapter-headless/src/lib.rs
Normal file
52
crates/nesemu-adapter-headless/src/lib.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use nesemu_adapter_api::{
|
||||
AudioSink, BUTTONS_COUNT, ButtonState, InputSource, TimeSource, VideoSink,
|
||||
};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NullInput;
|
||||
|
||||
impl InputSource for NullInput {
|
||||
fn poll_buttons(&mut self) -> ButtonState {
|
||||
[false; BUTTONS_COUNT]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NullVideo;
|
||||
|
||||
impl VideoSink for NullVideo {
|
||||
fn present_rgba(&mut self, _frame: &[u8], _width: u32, _height: u32) {}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NullAudio;
|
||||
|
||||
impl AudioSink for NullAudio {
|
||||
fn push_samples(&mut self, _samples: &[f32]) {}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct NoopTime;
|
||||
|
||||
impl TimeSource for NoopTime {
|
||||
fn wait_next_frame(&mut self) {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{NoopTime, NullAudio, NullInput, NullVideo};
|
||||
use nesemu_adapter_api::{AudioSink, BUTTONS_COUNT, InputSource, TimeSource, VideoSink};
|
||||
|
||||
#[test]
|
||||
fn null_adapters_are_noop() {
|
||||
let mut input = NullInput;
|
||||
let mut video = NullVideo;
|
||||
let mut audio = NullAudio;
|
||||
let mut time = NoopTime;
|
||||
|
||||
assert_eq!(input.poll_buttons(), [false; BUTTONS_COUNT]);
|
||||
video.present_rgba(&[], 256, 240);
|
||||
audio.push_samples(&[]);
|
||||
time.wait_next_frame();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user