1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Experiments with a timeout on keyboard interactions.

This commit is contained in:
Thomas Harte 2019-07-07 14:13:55 -04:00
parent a5f0761a43
commit d7329c1bdd
2 changed files with 24 additions and 2 deletions

View File

@ -28,6 +28,7 @@ class Keyboard {
computer signals that it is ready to begin communication by pulling the Keyboard Data line low."
*/
if(!data) {
// printf("Accepting new command\n");
mode_ = Mode::AcceptingCommand;
phase_ = 0;
command_ = 0;
@ -71,7 +72,6 @@ class Keyboard {
void run_for(HalfCycles cycle) {
switch(mode_) {
default:
case Mode::AwaitingEndOfCommand:
case Mode::Waiting: return;
case Mode::AcceptingCommand: {
@ -85,6 +85,7 @@ class Keyboard {
clock_output_ = offset >= 18;
if(offset == 26) {
// printf("Latched %d\n", (data_input_ ? 1 : 0));
command_ = (command_ << 1) | (data_input_ ? 1 : 0);
}
@ -96,6 +97,17 @@ class Keyboard {
}
} break;
case Mode::AwaitingEndOfCommand:
// Time out if the end-of-command seems not to be forthcoming.
++phase_;
if(phase_ == 1000) {
clock_output_ = false;
mode_ = Mode::Waiting;
phase_ = 0;
// printf("Timed out\n");
}
return;
case Mode::PerformingCommand: {
response_ = perform_command(command_);
@ -104,6 +116,7 @@ class Keyboard {
if(phase_ == 25000 || command_ != 0x10 || response_ != 0x7b) {
mode_ = Mode::SendingResponse;
phase_ = 0;
// printf("Starting response\n");
}
} break;
@ -126,6 +139,7 @@ class Keyboard {
clock_output_ = false;
mode_ = Mode::Waiting;
phase_ = 0;
// printf("Waiting\n");
}
} break;
}
@ -140,6 +154,8 @@ class Keyboard {
private:
int perform_command(int command) {
// printf("Keyboard: %02x\n", command);
switch(command) {
case 0x10: // Inquiry.
case 0x14: { // Instant.

View File

@ -376,6 +376,9 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
// As above: flush audio after video.
via_.flush();
audio_.queue.perform();
// Experimental?
iwm_.flush();
}
void set_rom_is_overlay(bool rom_is_overlay) {
@ -507,7 +510,10 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
CA2 is used for receiving RTC interrupts.
CA1 is used for receiving vsync.
*/
if(port == Port::B && line == Line::Two) keyboard_.set_input(value);
if(port == Port::B && line == Line::Two) {
printf("Keyboard input: %c\n", value ? 't' : 'f');
keyboard_.set_input(value);
}
else printf("Unhandled control line output: %c %d\n", port ? 'B' : 'A', int(line));
}