From 41081e9cceac75dd171516f33b4ebe2a4bf49ba7 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 8 Apr 2021 17:58:20 -0500 Subject: [PATCH] feat(bus): implement echo RAM --- src/bus.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/bus.rs b/src/bus.rs index acfeff4..dd6bde7 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -110,7 +110,19 @@ impl Bus { } 0xE000..=0xFDFF => { // Mirror of 0xC000 to 0xDDFF - unimplemented!("Unable to read {:#06X} in Restricted Mirror", addr); + // ECHO RAM + + match addr { + 0xE000..=0xEFFF => { + // 4KB Work RAM Bank 0 + self.wram.read_byte(addr) + } + 0xF000..=0xFDFF => { + // 4KB Work RAM Bank 1 -> N + self.vwram.read_byte(addr) + } + _ => unreachable!("{:#06X} was incorrectly handled by ECHO RAM", addr), + } } 0xFE00..=0xFE9F => { // Sprite Attribute Table @@ -200,7 +212,19 @@ impl Bus { } 0xE000..=0xFDFF => { // Mirror of 0xC000 to 0xDDFF - unimplemented!("Unable to write to {:#06X} in Restricted Mirror", addr); + // ECHO RAM + + match addr { + 0xE000..=0xEFFF => { + // 4KB Work RAM Bank 0 + self.wram.write_byte(addr, byte); + } + 0xF000..=0xFDFF => { + // 4KB Work RAM Bank 1 -> N + self.vwram.write_byte(addr, byte); + } + _ => unreachable!("{:#06X} was incorrectly handled by ECHO RAM", addr), + } } 0xFE00..=0xFE9F => { // Sprite Attribute Table