From 7101d14f3bcc0af29b8d51b1f5d58689fee1a571 Mon Sep 17 00:00:00 2001 From: Astatin Date: Sat, 14 Sep 2024 23:49:32 +0900 Subject: Add keyboard support & start supporting serial communication (but tetris doesn't work in 2p) --- src/io.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/io.rs') diff --git a/src/io.rs b/src/io.rs index df50c51..2aa8e87 100644 --- a/src/io.rs +++ b/src/io.rs @@ -1,3 +1,4 @@ +use crate::serial::Serial; use crate::state::{MemError, Memory}; impl Memory { @@ -13,6 +14,8 @@ impl Memory { (self.joypad_reg & 0xf) | 0b11100000 } } + 0x01 => self.serial_data, + 0x02 => self.serial_control, 0x04 => self.div, 0x40 => self.display.lcdc, 0x42 => self.display.viewport_y, @@ -57,7 +60,7 @@ impl Memory { } } _ => { - // println!("Reading from 0xff{:02x} not implemented yet", addr); + println!("Reading from 0xff{:02x} not implemented yet", addr); self.io[addr as usize] } } @@ -68,6 +71,19 @@ impl Memory { 0x00 => { self.joypad_is_action = !value & 0b00100000 != 0; } + 0x01 => { + self.serial_data = value; + } + 0x02 => { + if value & 0x01 != 0 { + self.serial.set_clock_master(true); + println!("Set as master"); + } else if value & 0x01 != 0 { + self.serial.set_clock_master(false); + println!("Set as slave"); + } + self.serial_control = value; + } 0x04 => { self.div = 0; } @@ -236,7 +252,7 @@ impl Memory { } } _ => { - if addr >= 0x4d { + if addr != 0x25 && addr != 0x24 && addr != 0x26 && addr < 0x30 && addr > 0x3f { println!( "Writing to 0xff{:02x} not implemented yet ({:02x})", addr, value -- cgit v1.2.3-70-g09d2