fix mbc2
This commit is contained in:
parent
1de1d817ce
commit
d96809e7fe
|
@ -40,10 +40,15 @@ impl Mbc for Mbc2 {
|
|||
}
|
||||
|
||||
fn get_ram(&self, address: Address) -> u8 {
|
||||
if self.ram_enabled {
|
||||
0xF0 | (0x0F & self.ram.get((address - 0xA000) as usize % 512))
|
||||
} else {
|
||||
0xFF
|
||||
}
|
||||
}
|
||||
|
||||
fn set(&mut self, address: Address, data: u8) {
|
||||
if address < 0x4000 {
|
||||
if address & (1 << 8) == (1 << 8) {
|
||||
// bit 8 is set - rom bank
|
||||
self.rom_bank = data & 0xF;
|
||||
|
@ -52,13 +57,16 @@ impl Mbc for Mbc2 {
|
|||
}
|
||||
} else {
|
||||
// bit 8 is clear - ram enable
|
||||
self.ram_enabled = data == 0x0A;
|
||||
self.ram_enabled = (data & 0xF) == 0x0A;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_ram(&mut self, address: Address, data: u8) {
|
||||
if self.ram_enabled {
|
||||
self.ram.set((address - 0xA000) as usize % 512, data);
|
||||
}
|
||||
}
|
||||
|
||||
fn mbc_type(&self) -> String {
|
||||
String::from("MBC2")
|
||||
|
|
Loading…
Reference in a new issue