1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::trace::TraceHandler;

pub mod mos6502;

pub trait Cpu {
  /// Reset this CPU, clearing internal state.
  fn reset(&mut self);

  /// Attach the given handler to receive trace events from this CPU.
  fn attach_trace_handler(&mut self, trace: Box<dyn TraceHandler>);

  /// Return the number of cycles elapsed since the system last reset.
  fn get_cycle_count(&self) -> u64;

  /// Execute a single instruction. Return the number of cycles elapsed.
  fn tick(&mut self) -> u8;

  /// Clean up any resources used by this CPU.
  fn cleanup(&mut self) -> Result<(), &str>;
}