Skip to content
Snippets Groups Projects
Verified Commit c9271834 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: made receive a delayed operation

This changes the way the device is called.
parent 5256bb2a
No related branches found
No related tags found
1 merge request!16Support for Game Boy Color (CGB) 😎🖍️
Pipeline #2595 failed
......@@ -22,6 +22,7 @@ pub struct Serial {
timer: i16,
length: u16,
bit_count: u8,
byte_send: u8,
byte_receive: u8,
int_serial: bool,
device: Box<dyn SerialDevice>,
......@@ -38,6 +39,7 @@ impl Serial {
timer: 0,
length: 512,
bit_count: 0,
byte_send: 0x0,
byte_receive: 0x0,
int_serial: false,
device: Box::<NullDevice>::default(),
......@@ -53,6 +55,7 @@ impl Serial {
self.timer = 0;
self.length = 512;
self.bit_count = 0;
self.byte_send = 0x0;
self.byte_receive = 0x0;
self.int_serial = false;
}
......@@ -120,8 +123,10 @@ impl Serial {
// executes the send and receive operation immediately
// this is considered an operational optimization with
// no real effect on the emulation (ex: no timing issues)
// then stores the byte to be sent to the device so that
// it's sent by the end of the send cycle
self.byte_receive = self.device.send();
self.device.receive(self.data);
self.byte_send = self.data;
}
}
_ => warnln!("Writing to unknown Serial location 0x{:04x}", addr),
......@@ -173,6 +178,10 @@ impl Serial {
self.length = 0;
self.bit_count = 0;
// received the byte on the device as the
// complete send operation has been performed
self.device.receive(self.byte_send);
// signals the interrupt for the serial
// transfer completion, indicating that
// a new byte is ready to be read
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment