mirror of
https://github.com/TomHarte/CLK.git
synced 2025-03-04 17:34:50 +00:00
Experiments with a timeout on keyboard interactions.
This commit is contained in:
parent
a5f0761a43
commit
d7329c1bdd
@ -28,6 +28,7 @@ class Keyboard {
|
|||||||
computer signals that it is ready to begin communication by pulling the Keyboard Data line low."
|
computer signals that it is ready to begin communication by pulling the Keyboard Data line low."
|
||||||
*/
|
*/
|
||||||
if(!data) {
|
if(!data) {
|
||||||
|
// printf("Accepting new command\n");
|
||||||
mode_ = Mode::AcceptingCommand;
|
mode_ = Mode::AcceptingCommand;
|
||||||
phase_ = 0;
|
phase_ = 0;
|
||||||
command_ = 0;
|
command_ = 0;
|
||||||
@ -71,7 +72,6 @@ class Keyboard {
|
|||||||
void run_for(HalfCycles cycle) {
|
void run_for(HalfCycles cycle) {
|
||||||
switch(mode_) {
|
switch(mode_) {
|
||||||
default:
|
default:
|
||||||
case Mode::AwaitingEndOfCommand:
|
|
||||||
case Mode::Waiting: return;
|
case Mode::Waiting: return;
|
||||||
|
|
||||||
case Mode::AcceptingCommand: {
|
case Mode::AcceptingCommand: {
|
||||||
@ -85,6 +85,7 @@ class Keyboard {
|
|||||||
clock_output_ = offset >= 18;
|
clock_output_ = offset >= 18;
|
||||||
|
|
||||||
if(offset == 26) {
|
if(offset == 26) {
|
||||||
|
// printf("Latched %d\n", (data_input_ ? 1 : 0));
|
||||||
command_ = (command_ << 1) | (data_input_ ? 1 : 0);
|
command_ = (command_ << 1) | (data_input_ ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +97,17 @@ class Keyboard {
|
|||||||
}
|
}
|
||||||
} break;
|
} 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: {
|
case Mode::PerformingCommand: {
|
||||||
response_ = perform_command(command_);
|
response_ = perform_command(command_);
|
||||||
|
|
||||||
@ -104,6 +116,7 @@ class Keyboard {
|
|||||||
if(phase_ == 25000 || command_ != 0x10 || response_ != 0x7b) {
|
if(phase_ == 25000 || command_ != 0x10 || response_ != 0x7b) {
|
||||||
mode_ = Mode::SendingResponse;
|
mode_ = Mode::SendingResponse;
|
||||||
phase_ = 0;
|
phase_ = 0;
|
||||||
|
// printf("Starting response\n");
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
@ -126,6 +139,7 @@ class Keyboard {
|
|||||||
clock_output_ = false;
|
clock_output_ = false;
|
||||||
mode_ = Mode::Waiting;
|
mode_ = Mode::Waiting;
|
||||||
phase_ = 0;
|
phase_ = 0;
|
||||||
|
// printf("Waiting\n");
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
@ -140,6 +154,8 @@ class Keyboard {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
int perform_command(int command) {
|
int perform_command(int command) {
|
||||||
|
// printf("Keyboard: %02x\n", command);
|
||||||
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 0x10: // Inquiry.
|
case 0x10: // Inquiry.
|
||||||
case 0x14: { // Instant.
|
case 0x14: { // Instant.
|
||||||
|
@ -376,6 +376,9 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
|||||||
// As above: flush audio after video.
|
// As above: flush audio after video.
|
||||||
via_.flush();
|
via_.flush();
|
||||||
audio_.queue.perform();
|
audio_.queue.perform();
|
||||||
|
|
||||||
|
// Experimental?
|
||||||
|
iwm_.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_rom_is_overlay(bool rom_is_overlay) {
|
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.
|
CA2 is used for receiving RTC interrupts.
|
||||||
CA1 is used for receiving vsync.
|
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));
|
else printf("Unhandled control line output: %c %d\n", port ? 'B' : 'A', int(line));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user