serial: dont fake a connection if it's not there

This commit is contained in:
Alex Janka 2023-02-22 10:12:35 +11:00
parent a9886a773a
commit 932e70a443

View file

@ -35,11 +35,15 @@ pub struct Serial {
output_byte: u8, output_byte: u8,
bits_remaining: u8, bits_remaining: u8,
control: SerialControl, control: SerialControl,
is_connected: bool,
} }
impl Serial { impl Serial {
pub fn tick(&mut self, steps: usize) -> bool { pub fn tick(&mut self, steps: usize) -> bool {
let mut will_interrupt = false; let mut will_interrupt = false;
if !self.is_connected {
return false;
}
for _ in 0..steps { for _ in 0..steps {
if self.control.transfer_in_progress { if self.control.transfer_in_progress {
self.output_byte = self.output_byte << 1 | self.byte >> 7; self.output_byte = self.output_byte << 1 | self.byte >> 7;
@ -98,6 +102,7 @@ impl Default for Serial {
output_byte: 0, output_byte: 0,
bits_remaining: 7, bits_remaining: 7,
control: SerialControl::default(), control: SerialControl::default(),
is_connected: false,
} }
} }
} }