From f7dc417e948468ad38b285b1f02f0f1c138f0adc Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Sat, 16 Nov 2019 18:06:49 +0200 Subject: [PATCH] Fix accesses outside of IO region Former-commit-id: dc874b6d28370cf7256156f2502bd2dc56a0a3fd --- src/core/iodev.rs | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/core/iodev.rs b/src/core/iodev.rs index 8f7367b..b3ed5e4 100644 --- a/src/core/iodev.rs +++ b/src/core/iodev.rs @@ -54,6 +54,9 @@ impl Bus for IoDevices { fn read_16(&self, addr: Addr) -> u16 { let io = self; let io_addr = addr + IO_BASE; + if addr > 0x0800 { + return 0; + } match io_addr { REG_DISPCNT => io.gpu.dispcnt.0, REG_DISPSTAT => io.gpu.dispstat.0, @@ -99,12 +102,12 @@ impl Bus for IoDevices { REG_HALTCNT => 0, REG_KEYINPUT => io.keyinput as u16, _ => { - println!( - "Unimplemented read from {:x} {}", - io_addr, - io_reg_string(io_addr) - ); - io.mem.read_16(addr) + // println!( + // "Unimplemented read from {:x} {}", + // io_addr, + // io_reg_string(io_addr) + // ); + 0 } } } @@ -125,7 +128,9 @@ impl Bus for IoDevices { fn write_16(&mut self, addr: Addr, value: u16) { let mut io = self; - io.mem.write_16(addr, value); + if addr > 0x0800 { + return; + } let io_addr = addr + IO_BASE; match io_addr { REG_DISPCNT => io.gpu.dispcnt.0 = value, @@ -241,11 +246,11 @@ impl Bus for IoDevices { } } _ => { - println!( - "Unimplemented write to {:x} {}", - io_addr, - io_reg_string(io_addr) - ); + // println!( + // "Unimplemented write to {:x} {}", + // io_addr, + // io_reg_string(io_addr) + // ); } } }