[][src]Trait libchip8::Hardware

pub trait Hardware: Sized {
    fn rand(&mut self) -> u8;
fn key(&mut self, key: u8) -> bool;
fn vram_set(&mut self, x: usize, y: usize, d: bool);
fn vram_get(&mut self, x: usize, y: usize) -> bool;
fn vram_setsize(&mut self, size: (usize, usize));
fn vram_size(&mut self) -> (usize, usize);
fn clock(&mut self) -> u64;
fn beep(&mut self); fn sched(&mut self) -> bool { ... } }

Represents environment-specific logic.

Library users need to implement this trait to run the interpreter.

Required methods

fn rand(&mut self) -> u8

Return a random value.

fn key(&mut self, key: u8) -> bool

Check if the key is pressed.

fn vram_set(&mut self, x: usize, y: usize, d: bool)

Set the state of a pixel in the screen.

true for white, and false for black.

fn vram_get(&mut self, x: usize, y: usize) -> bool

Get the current state of a pixel in the screen.

fn vram_setsize(&mut self, size: (usize, usize))

Set the size of the screen.

fn vram_size(&mut self) -> (usize, usize)

Get the size of the screen.

fn clock(&mut self) -> u64

Return the current clock value in nanoseconds.

fn beep(&mut self)

Play beep sound.

Loading content...

Provided methods

fn sched(&mut self) -> bool

Called in every step; return true for shutdown.

Loading content...

Implementors

Loading content...