1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-30 04:50:08 +00:00

Mostly but not quite fixes serial work.

This commit is contained in:
Thomas Harte 2019-10-16 23:34:37 -04:00
parent f2e1584275
commit f5a2e180f9
4 changed files with 10 additions and 7 deletions

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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<float>() * 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_) {