Fix offset of RAM in ROM card

This commit is contained in:
pjht 2023-03-23 10:32:53 -05:00
parent 0d5a20c22e
commit 9cdbe2e071
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -54,10 +54,10 @@ impl Card for Rom {
return NullableResult::Null; return NullableResult::Null;
} }
let address = address as u16; let address = address as u16;
if address < 0x4000 { if address < 0x8000 {
self.data.get(address as usize).copied().into() self.data.get(address as usize).copied().into()
} else { } else {
self.ram.get((address - 0x4000) as usize).copied().into() self.ram.get((address - 0x8000) as usize).copied().into()
} }
} }
@ -65,8 +65,8 @@ impl Card for Rom {
if !self.enabled | ((address >> 16) as u16 != self.start) { if !self.enabled | ((address >> 16) as u16 != self.start) {
return NullableResult::Null; return NullableResult::Null;
} }
let address = (address as u16).checked_sub(0x4000)?; let address = (address as u16).checked_sub(0x8000)?;
if address > self.data.len() as u16 { if address > self.ram.len() as u16 {
return NullableResult::Null; return NullableResult::Null;
} }
self.ram[address as usize] = data; self.ram[address as usize] = data;