Interpreter

Trait Interpreter 

Source
pub trait Interpreter {
    // Required methods
    fn step(&mut self, keys: &Keys) -> Option<Display>;
    fn speed(&self) -> Duration;
    fn buzzer_active(&self) -> bool;
}
Expand description

CHIP-8 interpreters can be built using this trait. step should be implemented on a type representing a CHIP-8 Interpreter to run the interpreter one clock cycle at a time, such that calling it in a loop runs the interpreter.

Required Methods§

Source

fn step(&mut self, keys: &Keys) -> Option<Display>

Executes the next CHIP-8 Instruction, modifying the state of the virtual machine/CPU accordingly. This is the main driver function, running the interpreter one clock cycle at a time.

§Return

If the instruction modified the state of the display, then an updated Display should be returned.

§Panics

Should panic if an unrecognised instruction is encountered

Source

fn speed(&self) -> Duration

Returns the duration of a single clock cycle, so the interpreter can keep the time steps uniform. See std::time for more information on Duration.

Source

fn buzzer_active(&self) -> bool

Indicates if the sound buzzer is currently active, such that the interpreter can handle sound accordingly.

Implementors§