35 lines
643 B
Rust
35 lines
643 B
Rust
|
use crate::processor::memory::Address;
|
||
|
|
||
|
pub(super) trait MBC {
|
||
|
fn get(&self, address: Address) -> u8;
|
||
|
fn set(&mut self, address: Address, data: u8);
|
||
|
}
|
||
|
|
||
|
pub(super) struct NONE {
|
||
|
pub(super) data: Vec<u8>,
|
||
|
}
|
||
|
|
||
|
impl MBC for NONE {
|
||
|
fn get(&self, address: Address) -> u8 {
|
||
|
self.data[address as usize]
|
||
|
}
|
||
|
|
||
|
fn set(&mut self, address: Address, data: u8) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
pub(super) struct MBC1 {
|
||
|
pub(super) data: Vec<u8>,
|
||
|
}
|
||
|
|
||
|
impl MBC for MBC1 {
|
||
|
fn get(&self, address: Address) -> u8 {
|
||
|
self.data[address as usize]
|
||
|
}
|
||
|
|
||
|
fn set(&mut self, address: Address, data: u8) {
|
||
|
return;
|
||
|
}
|
||
|
}
|