1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-22 09:37:21 +00:00

Flip input/output, perform commands instantly.

This commit is contained in:
Thomas Harte 2025-03-07 23:32:07 -05:00
parent 93078abe87
commit cee2484108

View File

@ -141,9 +141,28 @@ public:
break;
case 0x0064:
has_output_ = true;
is_command_ = true;
parameter_ = value;
const auto set_input = [&](const uint8_t input) {
parameter_ = input;
has_input_ = true;
is_command_ = false;
};
auto info = log_.info();
info.append("AT keyboard command %04x", value);
switch(value) {
default:
info.append("; unimplemented");
break;
case 0xaa: // Self-test; 0x55 => no issues found.
log_.error().append("Keyboard self-test");
set_input(0x55);
break;
case 0xd1: // Set output byte. b0 = the A20 gate.
break;
}
break;
}
}
@ -177,15 +196,13 @@ public:
// b4 = 1 => keyboard active;
// b3 = 1 = data at 0060 is command, 0 = data;
// b2 = 1 = selftest OK; 0 = just powered up or reset;
// b1 = 1 => input buffer has data;
// b0 = 1 => output data is full.
// b1 = 1 => 'input' buffer full (i.e. don't write 0x60 or 0x64 now — this is input to the controller);
// b0 = 1 => 'output' data is full (i.e. reading from 0x60 now makes sense — output is to PC).
const uint8_t status =
(is_command_ ? 0x08 : 0x00) |
(is_tested_ ? 0x04 : 0x00) |
(has_input_ ? 0x02 : 0x00) |
(has_output_ ? 0x01 : 0x00);
(has_output_ ? 0x02 : 0x00) |
(has_input_ ? 0x01 : 0x00);
log_.error().append("Reading status: %02x", status);
perform_command();
return status;
}
}
@ -195,47 +212,15 @@ public:
private:
Log::Logger<Log::Source::PCCompatible> log_;
void perform_command() {
if(!is_command_) {
return;
}
has_output_ = false;
is_command_ = false;
const auto set_input = [&](const uint8_t input) {
parameter_ = input;
has_input_ = true;
is_command_ = false;
};
auto info = log_.info();
info.append("AT keyboard command %04x", command_);
switch(command_) {
default:
info.append("; unimplemented");
break;
case 0xaa: // Self-test; 0x55 => no issues found.
log_.error().append("Keyboard self-test");
is_tested_ = true;
set_input(0x55);
break;
case 0xd1: // Set output byte. b0 = the A20 gate.
break;
}
}
PICs<model> &pics_;
Speaker &speaker_;
uint8_t refresh_toggle_ = 0;
bool is_tested_ = false;
bool has_input_ = false;
bool has_output_ = false;
bool is_command_ = false;
uint8_t parameter_;
uint8_t command_;
};
}