mbc5 ram address fix

This commit is contained in:
Alex Janka 2023-02-23 11:24:27 +11:00
parent 9418d1e98a
commit c925beae8a

View file

@ -8,6 +8,7 @@ pub struct Mbc5 {
rom_size: usize,
ram: Option<Vec<u8>>,
ram_bank: u8,
ram_size: usize,
ram_enabled: bool,
}
@ -20,6 +21,7 @@ impl Mbc5 {
rom_size: rom_banks(rom_size) * ROM_BANK_SIZE,
ram,
ram_bank: 0,
ram_size: ram_size_kb(ram_size).map_or(1, |s| s * KB),
ram_enabled: false,
}
}
@ -36,7 +38,7 @@ impl Mbc5 {
}
fn get_ram_addr(&self, address: Address) -> usize {
address as usize + (RAM_BANK_SIZE * self.ram_bank as usize)
((address as usize - 0xA000) + (RAM_BANK_SIZE * self.ram_bank as usize)) % self.ram_size
}
}