diff --git a/Components/6850/6850.cpp b/Components/6850/6850.cpp index 4776cb1a8..d59f5c971 100644 --- a/Components/6850/6850.cpp +++ b/Components/6850/6850.cpp @@ -9,6 +9,7 @@ #include "6850.hpp" #define LOG_PREFIX "[6850] " +#define NDEBUG #include "../../Outputs/Log.hpp" using namespace Motorola::ACIA; @@ -145,6 +146,7 @@ void ACIA::consider_transmission() { // Output all that. const int total_bits = 1 + data_bits_ + stop_bits_ + (parity_ != Parity::None); transmit.write(divider_ * 2, total_bits, transmission); + printf("Transmitted %02x [%03x]\n", next_transmission_, transmission); // Mark the transmit register as empty again. next_transmission_ = NoValue; diff --git a/Components/SerialPort/SerialPort.cpp b/Components/SerialPort/SerialPort.cpp index 3d903154d..5e80b4be9 100644 --- a/Components/SerialPort/SerialPort.cpp +++ b/Components/SerialPort/SerialPort.cpp @@ -31,7 +31,7 @@ void Line::advance_writer(int cycles) { if(old_level != level_) { if(read_delegate_) { - read_delegate_->serial_line_did_change_output(this, Storage::Time(write_cycles_since_delegate_call_, clock_rate_), level_); + read_delegate_->serial_line_did_change_output(this, Storage::Time(write_cycles_since_delegate_call_, clock_rate_), old_level); write_cycles_since_delegate_call_ = 0; } } @@ -89,11 +89,11 @@ void Line::flush_writing() { } if(new_level != level_) { - level_ = new_level; if(read_delegate_) { read_delegate_->serial_line_did_change_output(this, Storage::Time(write_cycles_since_delegate_call_, clock_rate_), level_); write_cycles_since_delegate_call_ = 0; } + level_ = new_level; } } events_.clear(); diff --git a/Components/SerialPort/SerialPort.hpp b/Components/SerialPort/SerialPort.hpp index 5f8628588..d4a2ac98a 100644 --- a/Components/SerialPort/SerialPort.hpp +++ b/Components/SerialPort/SerialPort.hpp @@ -55,7 +55,7 @@ class Line { bool read(); struct ReadDelegate { - virtual void serial_line_did_change_output(Line *line, Storage::Time time_since_last_change, bool new_level) = 0; + virtual void serial_line_did_change_output(Line *line, Storage::Time time_since_last_change, bool old_level) = 0; }; void set_read_delegate(ReadDelegate *delegate); diff --git a/Machines/AtariST/AtariST.cpp b/Machines/AtariST/AtariST.cpp index c13c352bc..a5ccfe9c8 100644 --- a/Machines/AtariST/AtariST.cpp +++ b/Machines/AtariST/AtariST.cpp @@ -42,22 +42,23 @@ class IntelligentKeyboard: input.set_read_delegate(this); } - void serial_line_did_change_output(Serial::Line *, Storage::Time time_since_last_change, bool new_level) final { + void serial_line_did_change_output(Serial::Line *, Storage::Time time_since_last_change, bool old_level) final { // Figure out how many bits have passed. TODO: in fixed point? const float number_of_bits = time_since_last_change.get() * 7812.5f + bit_offset_; bit_offset_ = fmodf(number_of_bits, 1.0f); + printf("Changed from %d after %d bits\n", old_level, int(number_of_bits)); int bits_remaining = int(number_of_bits); while(bits_remaining--) { if(!bit_count_) { // Check for a potential start bit. - if(!new_level) { - bit_count_ = 10; + if(!old_level) { + bit_count_ = 9; command_ = 0; } } else { command_ >>= 1; - command_ |= new_level ? 0 : 0x200; + command_ |= old_level ? 0x200 : 0x000; --bit_count_; if(!bit_count_) {