mbc5 ram address fix
This commit is contained in:
parent
9418d1e98a
commit
c925beae8a
|
@ -8,6 +8,7 @@ pub struct Mbc5 {
|
||||||
rom_size: usize,
|
rom_size: usize,
|
||||||
ram: Option<Vec<u8>>,
|
ram: Option<Vec<u8>>,
|
||||||
ram_bank: u8,
|
ram_bank: u8,
|
||||||
|
ram_size: usize,
|
||||||
ram_enabled: bool,
|
ram_enabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ impl Mbc5 {
|
||||||
rom_size: rom_banks(rom_size) * ROM_BANK_SIZE,
|
rom_size: rom_banks(rom_size) * ROM_BANK_SIZE,
|
||||||
ram,
|
ram,
|
||||||
ram_bank: 0,
|
ram_bank: 0,
|
||||||
|
ram_size: ram_size_kb(ram_size).map_or(1, |s| s * KB),
|
||||||
ram_enabled: false,
|
ram_enabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +38,7 @@ impl Mbc5 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_ram_addr(&self, address: Address) -> usize {
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue