From 23de87e4823146a4cb48bca75df6086f691617c9 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Thu, 8 Apr 2021 19:22:55 -0500 Subject: [PATCH] chore: remove panics when gameboy performs certain actions --- src/bus.rs | 11 +++++++++-- src/cartridge.rs | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/bus.rs b/src/bus.rs index dd6bde7..84f4445 100644 --- a/src/bus.rs +++ b/src/bus.rs @@ -128,7 +128,11 @@ impl Bus { // Sprite Attribute Table unimplemented!("Unable to read {:#06X} in the Sprite Attribute Table", addr); } - 0xFEA0..=0xFEFF => unreachable!("{:#06X} is not allowed to be read from", addr), + 0xFEA0..=0xFEFF => { + eprintln!("Read from {:#06X}, which is prohibited", addr); + // TODO: Properly Emulate what can happen here + 0x00 + } 0xFF00..=0xFF7F => { // IO Registers match addr { @@ -230,7 +234,10 @@ impl Bus { // Sprite Attribute Table unimplemented!("Unable to write to {:#06X} in Sprite Attribute Table", addr); } - 0xFEA0..=0xFEFF => unreachable!("{:#06X} is not allowed to be written to", addr), + 0xFEA0..=0xFEFF => { + eprintln!("Wrote {:#04X} to {:#06X}, which is prohibited", byte, addr); + // TODO: Properly emulate what can happen here + } 0xFF00..=0xFF7F => { // IO Registers match addr { diff --git a/src/cartridge.rs b/src/cartridge.rs index 2138348..6042310 100644 --- a/src/cartridge.rs +++ b/src/cartridge.rs @@ -221,8 +221,8 @@ impl MemoryBankController for NoMbc { MbcResult::Address(addr) } - fn handle_write(&mut self, _addr: u16, _byte: u8) { - panic!("A MBC-less cartridge is read only") + fn handle_write(&mut self, _addr: u16, byte: u8) { + eprintln!("Tried to write {:#04X} to a read-only cartridge", byte); } }