From 9cdbe2e071413b548a7c05b4a0f54b53b3fcc5cf Mon Sep 17 00:00:00 2001 From: pjht Date: Thu, 23 Mar 2023 10:32:53 -0500 Subject: [PATCH] Fix offset of RAM in ROM card --- src/rom.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rom.rs b/src/rom.rs index 2e86a5d..68b2ddc 100644 --- a/src/rom.rs +++ b/src/rom.rs @@ -54,10 +54,10 @@ impl Card for Rom { return NullableResult::Null; } let address = address as u16; - if address < 0x4000 { + if address < 0x8000 { self.data.get(address as usize).copied().into() } 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) { return NullableResult::Null; } - let address = (address as u16).checked_sub(0x4000)?; - if address > self.data.len() as u16 { + let address = (address as u16).checked_sub(0x8000)?; + if address > self.ram.len() as u16 { return NullableResult::Null; } self.ram[address as usize] = data;