mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-20 14:29:11 +00:00
Mostly but not quite fixes serial work.
This commit is contained in:
parent
3d03cce6b1
commit
9a8352282d
@ -9,6 +9,7 @@
|
|||||||
#include "6850.hpp"
|
#include "6850.hpp"
|
||||||
|
|
||||||
#define LOG_PREFIX "[6850] "
|
#define LOG_PREFIX "[6850] "
|
||||||
|
#define NDEBUG
|
||||||
#include "../../Outputs/Log.hpp"
|
#include "../../Outputs/Log.hpp"
|
||||||
|
|
||||||
using namespace Motorola::ACIA;
|
using namespace Motorola::ACIA;
|
||||||
@ -145,6 +146,7 @@ void ACIA::consider_transmission() {
|
|||||||
// Output all that.
|
// Output all that.
|
||||||
const int total_bits = 1 + data_bits_ + stop_bits_ + (parity_ != Parity::None);
|
const int total_bits = 1 + data_bits_ + stop_bits_ + (parity_ != Parity::None);
|
||||||
transmit.write(divider_ * 2, total_bits, transmission);
|
transmit.write(divider_ * 2, total_bits, transmission);
|
||||||
|
printf("Transmitted %02x [%03x]\n", next_transmission_, transmission);
|
||||||
|
|
||||||
// Mark the transmit register as empty again.
|
// Mark the transmit register as empty again.
|
||||||
next_transmission_ = NoValue;
|
next_transmission_ = NoValue;
|
||||||
|
@ -31,7 +31,7 @@ void Line::advance_writer(int cycles) {
|
|||||||
|
|
||||||
if(old_level != level_) {
|
if(old_level != level_) {
|
||||||
if(read_delegate_) {
|
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;
|
write_cycles_since_delegate_call_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,11 +89,11 @@ void Line::flush_writing() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(new_level != level_) {
|
if(new_level != level_) {
|
||||||
level_ = new_level;
|
|
||||||
if(read_delegate_) {
|
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_), level_);
|
||||||
write_cycles_since_delegate_call_ = 0;
|
write_cycles_since_delegate_call_ = 0;
|
||||||
}
|
}
|
||||||
|
level_ = new_level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
events_.clear();
|
events_.clear();
|
||||||
|
@ -55,7 +55,7 @@ class Line {
|
|||||||
bool read();
|
bool read();
|
||||||
|
|
||||||
struct ReadDelegate {
|
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);
|
void set_read_delegate(ReadDelegate *delegate);
|
||||||
|
|
||||||
|
@ -42,22 +42,23 @@ class IntelligentKeyboard:
|
|||||||
input.set_read_delegate(this);
|
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?
|
// 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_;
|
const float number_of_bits = time_since_last_change.get<float>() * 7812.5f + bit_offset_;
|
||||||
bit_offset_ = fmodf(number_of_bits, 1.0f);
|
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);
|
int bits_remaining = int(number_of_bits);
|
||||||
while(bits_remaining--) {
|
while(bits_remaining--) {
|
||||||
if(!bit_count_) {
|
if(!bit_count_) {
|
||||||
// Check for a potential start bit.
|
// Check for a potential start bit.
|
||||||
if(!new_level) {
|
if(!old_level) {
|
||||||
bit_count_ = 10;
|
bit_count_ = 9;
|
||||||
command_ = 0;
|
command_ = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
command_ >>= 1;
|
command_ >>= 1;
|
||||||
command_ |= new_level ? 0 : 0x200;
|
command_ |= old_level ? 0x200 : 0x000;
|
||||||
--bit_count_;
|
--bit_count_;
|
||||||
|
|
||||||
if(!bit_count_) {
|
if(!bit_count_) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user