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.
53 lines
1.2 KiB
Rust
53 lines
1.2 KiB
Rust
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();
|
|
}
|
|
}
|