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§
Sourcefn step(&mut self, keys: &Keys) -> Option<Display>
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
Sourcefn buzzer_active(&self) -> bool
fn buzzer_active(&self) -> bool
Indicates if the sound buzzer is currently active, such that the interpreter can handle sound accordingly.