diff options
author | Astatin <[email protected]> | 2024-09-14 23:49:32 +0900 |
---|---|---|
committer | Astatin <astatin@redacted> | 2024-09-14 23:49:32 +0900 |
commit | 7101d14f3bcc0af29b8d51b1f5d58689fee1a571 (patch) | |
tree | f0d24574e6ec3153a3f4a5969233946be43719a6 /src/io.rs | |
parent | 249921a2094d172e94543446e2af11dcba5075e8 (diff) |
Add keyboard support & start supporting serial communication (but tetris doesn't work in 2p)
Diffstat (limited to 'src/io.rs')
-rw-r--r-- | src/io.rs | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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 |