diff --git a/Machines/Apple/AppleIIgs/ADB.cpp b/Machines/Apple/AppleIIgs/ADB.cpp index 402d1ce90..afb859a62 100644 --- a/Machines/Apple/AppleIIgs/ADB.cpp +++ b/Machines/Apple/AppleIIgs/ADB.cpp @@ -199,8 +199,7 @@ void GLU::set_port_output(int port, uint8_t value) { } } break; case 3: -// printf("IIe KWS: %d\n", (value >> 6)&3); -// printf("ADB data line output: %d\n", (value >> 3)&1); + modifier_state_ = value; // Output is inverted respective to input; the microcontroller // sets a value of '1' in order to pull the ADB bus low. @@ -211,6 +210,14 @@ void GLU::set_port_output(int port, uint8_t value) { } } +bool GLU::get_command_button() const { + return modifier_state_ & 0x20; +} + +bool GLU::get_option_button() const { + return modifier_state_ & 0x10; +} + uint8_t GLU::get_port_input(int port) { switch(port) { case 0: return register_latch_; diff --git a/Machines/Apple/AppleIIgs/ADB.hpp b/Machines/Apple/AppleIIgs/ADB.hpp index bf4e4b3a8..8a6bd9617 100644 --- a/Machines/Apple/AppleIIgs/ADB.hpp +++ b/Machines/Apple/AppleIIgs/ADB.hpp @@ -41,6 +41,9 @@ class GLU: public InstructionSet::M50740::PortHandler { void run_for(Cycles cycles); + bool get_command_button() const; + bool get_option_button() const; + private: InstructionSet::M50740::Executor executor_; @@ -59,6 +62,8 @@ class GLU: public InstructionSet::M50740::PortHandler { Apple::ADB::Bus bus_; size_t controller_id_; + uint8_t modifier_state_ = 0; + // For now, attach only a keyboard and mouse. Apple::ADB::Mouse mouse_; Apple::ADB::Keyboard keyboard_; diff --git a/Machines/Apple/AppleIIgs/AppleIIgs.cpp b/Machines/Apple/AppleIIgs/AppleIIgs.cpp index 6295246ae..90f1aff60 100644 --- a/Machines/Apple/AppleIIgs/AppleIIgs.cpp +++ b/Machines/Apple/AppleIIgs/AppleIIgs.cpp @@ -514,9 +514,20 @@ class ConcreteMachine: *value = rom_[rom_.size() - 65536 + address_suffix]; break; - // Analogue inputs. All TODO. - case Read(0xc060): case Read(0xc061): case Read(0xc062): case Read(0xc063): - // Joystick buttons (and keyboard modifiers). + // Analogue inputs. Joystick parts are TODO. + case Read(0xc061): + *value = adb_glu_->get_command_button() ? 0x80 : 0x00; + is_1Mhz = true; + break; + + case Read(0xc062): + *value = adb_glu_->get_option_button() ? 0x80 : 0x00; + is_1Mhz = true; + break; + + case Read(0xc060): + case Read(0xc063): + // Joystick buttons. *value = 0x00; is_1Mhz = true; break;