1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-11-02 02:16:18 +00:00

New guess: writing to the keyboard implicitly enables communications.

This commit is contained in:
Thomas Harte
2025-09-09 23:38:21 -04:00
parent 7f4047772c
commit 4765a39759
3 changed files with 33 additions and 30 deletions

View File

@@ -284,7 +284,7 @@ private:
};
enum Control: uint8_t {
AllowInterrupts = 0x01,
AllowKeyboardInterrupts = 0x01,
InhibitKeyboard = 0x10,
};
@@ -323,6 +323,7 @@ private:
// No command => input only, which is a direct-to-device communication.
if(!has_command_) {
log_.info().append("Device command: %02x", input_);
control_ &= ~Control::InhibitKeyboard;
keyboard_.perform(input_);
// TODO: mouse?
has_input_ = false;
@@ -374,6 +375,7 @@ private:
break;
case Command::InterfaceTest:
transmit(0); // i.e. no issues uncovered.
should_log = false;
break;
case Command::ReadTestInputs:
// b0 is the keyboard clock; ensure it's inhibited when asked but otherwise don't attempt realism.
@@ -456,8 +458,14 @@ private:
// output_.append({0xfa});
// break;
case 0xf2: output_.append({0xfa, 0xab, 0x41}); break;
case 0xff: output_.append({0xfa, 0xaa}); break;
case 0xf2:
output_.append({0xfa, 0xab, 0x41});
break;
case 0xff:
output_.append({0xfa, 0xaa});
should_log = true;
break;
}
}
@@ -488,14 +496,13 @@ private:
}
void check_irqs() {
bool new_irq1 = false;
if(output_.empty() && !(control_ & Control::InhibitKeyboard) && !keyboard_.output().empty()) {
output_.append({keyboard_.output().next()});
new_irq1 = control_ & Control::AllowKeyboardInterrupts;
}
const bool new_irq = (control_ & Control::AllowInterrupts) && !output_.empty();
log_.info().append("IRQ1: %d", new_irq);
pics_.pic[0].template apply_edge<1>(new_irq);
pics_.pic[0].template apply_edge<1>(new_irq1);
log_.info().append("IRQ1: %d", new_irq1);
}
};

View File

@@ -951,24 +951,20 @@ public:
// should_log = (decoded_ip_ >= 0x21d0 && decoded_ip_ < 0x221c);
if(should_log) {
const auto next = to_string(decoded_, InstructionSet::x86::Model::i8086);
static std::string previous;
if(next != previous) {
std::cout << std::hex << decoded_ip_ << " " << next;
if(decoded_.second.operation() == InstructionSet::x86::Operation::INT) {
std::cout << " dl:" << std::hex << +context_.registers.dl() << "; ";
std::cout << "ah:" << std::hex << +context_.registers.ah() << "; ";
std::cout << "ch:" << std::hex << +context_.registers.ch() << "; ";
std::cout << "cl:" << std::hex << +context_.registers.cl() << "; ";
std::cout << "dh:" << std::hex << +context_.registers.dh() << "; ";
std::cout << "es:" << std::hex << +context_.registers.es() << "; ";
std::cout << "bx:" << std::hex << +context_.registers.bx();
}
std::cout << std::endl;
previous = next;
}
log.info().append(
"%04x %s",
decoded_ip_,
to_string(decoded_, InstructionSet::x86::Model::i80286).c_str()
).append_if(decoded_.second.operation() == InstructionSet::x86::Operation::INT,
" dl:%02x ah:%02x ch:%02x cl:%02x dh:%02x es:%04x bx:%04x",
context_.registers.dl(),
context_.registers.ah(),
context_.registers.ch(),
context_.registers.cl(),
context_.registers.dh(),
context_.registers.es(),
context_.registers.bx()
);
}
if(decoded_.second.operation() == InstructionSet::x86::Operation::Invalid) {

View File

@@ -176,10 +176,10 @@ public:
~LogLine() {
thread_local RepeatAccumulator accumulator;
if(output_ == accumulator.last && source == accumulator.source && stream_ == accumulator.stream) {
++accumulator.count;
return;
}
// if(output_ == accumulator.last && source == accumulator.source && stream_ == accumulator.stream) {
// ++accumulator.count;
// return;
// }
if(!accumulator.last.empty()) {
const char *const unadorned_prefix = prefix(accumulator.source);