This commit is contained in:
Theron 2020-01-20 18:31:08 -06:00
parent 3a5495d93b
commit a03bd6a6c2
2 changed files with 23 additions and 22 deletions

View File

@ -16,14 +16,13 @@ impl Cnrom {
impl Mapper for Cnrom {
fn read(&mut self, address: usize) -> u8 {
let cl = self.cart.chr_rom.len();
let pl = self.cart.prg_rom.len();
let addr = address % 0x4000;
match address {
0x0000..=0x1FFF => self.cart.chr_rom[self.chr_bank_select][address],
0x8000..=0xBFFF => self.cart.prg_rom[0][addr],
0xC000..=0xFFFF => self.cart.prg_rom[pl-1][addr],
_ => panic!("bad address read from CNROM mapper: 0x{:X}", address),
_ => {println!("bad address read from CNROM mapper: 0x{:X}", address); 0},
}
}

View File

@ -180,8 +180,7 @@ impl Mapper for Mmc1 {
}
fn load_battery_backed_ram(&mut self) {
// check for filename, if not there make it
// println!("{}", self.cart.filename);
if self.cart.battery_backed_ram {
let p = Path::new(&self.cart.filename).parent().unwrap();
let stem = Path::new(&self.cart.filename).file_stem().unwrap();
let mut save_file = p.join(stem);
@ -194,8 +193,10 @@ impl Mapper for Mmc1 {
self.prg_ram_bank = battery_backed_ram_data;
}
}
}
fn save_battery_backed_ram(&self) {
if self.cart.battery_backed_ram {
let p = Path::new(&self.cart.filename).parent().unwrap();
let stem = Path::new(&self.cart.filename).file_stem().unwrap();
let mut save_file = p.join(stem);
@ -205,6 +206,7 @@ impl Mapper for Mmc1 {
.expect("could not create output file for battery-backed RAM");
f.write_all(&self.prg_ram_bank).expect("could not write battery-backed RAM to file");
}
}
fn clock(&mut self) {}
fn check_irq(&mut self) -> bool {false}