1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use std::rc::Rc;
use std::cell::RefCell;
#[macro_export]
macro_rules! kb {
($x:expr) => {
$x * 1024
};
}
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Interrupt {
Nmi,
Irq,
}
pub trait IoAccess {
#[allow(unused)]
fn read_byte(&self, addr: u16) -> u8 { 0 }
#[allow(unused)]
fn write_byte(&mut self, addr: u16, data: u8) {}
#[allow(unused)]
fn raise_interrupt(&mut self, interrupt_type: Interrupt){}
}
pub type IoAccessRef = Rc<RefCell<dyn IoAccess>>;
pub trait Clockable<T=()> {
fn tick(&mut self) -> T;
}
pub trait Register<T> {
fn new(value: T) -> Self
where Self: Default {
let mut r = Self::default();
r.load(value);
r
}
#[allow(unused)]
fn load(&mut self, value: T){}
fn value(&self) -> T;
}