diff options
Diffstat (limited to 'src/cartridge.rs')
-rw-r--r-- | src/cartridge.rs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/src/cartridge.rs b/src/cartridge.rs index b8d2b68..0d21a42 100644 --- a/src/cartridge.rs +++ b/src/cartridge.rs @@ -1,5 +1,4 @@ #![allow(dead_code)] -use core::cell::RefCell; #[derive(Copy, Clone)] pub enum MirrorType { @@ -17,33 +16,31 @@ pub enum BankType { } pub struct Cartridge { - chr_rom: RefCell<Vec<u8>>, - prg_rom: RefCell<Vec<u8>>, - sram: RefCell<Vec<u8>>, + chr_rom: Vec<u8>, + prg_rom: Vec<u8>, + sram: Vec<u8>, pub mirror_type: MirrorType } impl Cartridge { pub fn get_size(&self, kind: BankType) -> usize { match kind { - BankType::PrgRom => self.prg_rom.borrow().len(), - BankType::ChrRom => self.chr_rom.borrow().len(), - BankType::Sram => self.sram.borrow().len() + BankType::PrgRom => self.prg_rom.len(), + BankType::ChrRom => self.chr_rom.len(), + BankType::Sram => self.sram.len() } } - pub fn get_bank(&self, base: usize, size: usize, kind: BankType) -> *mut [u8] { + pub fn get_bank(&mut self, base: usize, size: usize, kind: BankType) -> *mut [u8] { &mut (match kind { - BankType::PrgRom => self.prg_rom.borrow_mut(), - BankType::ChrRom => self.chr_rom.borrow_mut(), - BankType::Sram => self.sram.borrow_mut(), + BankType::PrgRom => &mut self.prg_rom, + BankType::ChrRom => &mut self.chr_rom, + BankType::Sram => &mut self.sram, })[base..base + size] } pub fn new(chr_rom: Vec<u8>, prg_rom: Vec<u8>, sram: Vec<u8>, mirror_type: MirrorType) -> Self { - Cartridge{chr_rom: RefCell::new(chr_rom), - prg_rom: RefCell::new(prg_rom), - sram: RefCell::new(sram), mirror_type} + Cartridge{chr_rom, prg_rom, sram, mirror_type} } } |