diff --git a/Machines/Apple/Macintosh/Keyboard.hpp b/Machines/Apple/Macintosh/Keyboard.hpp index d2ce08f21..d74358e35 100644 --- a/Machines/Apple/Macintosh/Keyboard.hpp +++ b/Machines/Apple/Macintosh/Keyboard.hpp @@ -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. diff --git a/Machines/Apple/Macintosh/Macintosh.cpp b/Machines/Apple/Macintosh/Macintosh.cpp index 79483ff73..199403411 100644 --- a/Machines/Apple/Macintosh/Macintosh.cpp +++ b/Machines/Apple/Macintosh/Macintosh.cpp @@ -376,6 +376,9 @@ template 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 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)); }