mirror of
				https://github.com/TomHarte/CLK.git
				synced 2025-11-04 00:16:26 +00:00 
			
		
		
		
	New guess: writing to the keyboard implicitly enables communications.
This commit is contained in:
		@@ -284,7 +284,7 @@ private:
 | 
				
			|||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	enum Control: uint8_t {
 | 
						enum Control: uint8_t {
 | 
				
			||||||
		AllowInterrupts = 0x01,
 | 
							AllowKeyboardInterrupts = 0x01,
 | 
				
			||||||
		InhibitKeyboard = 0x10,
 | 
							InhibitKeyboard = 0x10,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -323,6 +323,7 @@ private:
 | 
				
			|||||||
		// No command => input only, which is a direct-to-device communication.
 | 
							// No command => input only, which is a direct-to-device communication.
 | 
				
			||||||
		if(!has_command_) {
 | 
							if(!has_command_) {
 | 
				
			||||||
			log_.info().append("Device command: %02x", input_);
 | 
								log_.info().append("Device command: %02x", input_);
 | 
				
			||||||
 | 
								control_ &= ~Control::InhibitKeyboard;
 | 
				
			||||||
			keyboard_.perform(input_);
 | 
								keyboard_.perform(input_);
 | 
				
			||||||
			// TODO: mouse?
 | 
								// TODO: mouse?
 | 
				
			||||||
			has_input_ = false;
 | 
								has_input_ = false;
 | 
				
			||||||
@@ -374,6 +375,7 @@ private:
 | 
				
			|||||||
			break;
 | 
								break;
 | 
				
			||||||
			case Command::InterfaceTest:
 | 
								case Command::InterfaceTest:
 | 
				
			||||||
				transmit(0);	// i.e. no issues uncovered.
 | 
									transmit(0);	// i.e. no issues uncovered.
 | 
				
			||||||
 | 
									should_log = false;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
			case Command::ReadTestInputs:
 | 
								case Command::ReadTestInputs:
 | 
				
			||||||
				// b0 is the keyboard clock; ensure it's inhibited when asked but otherwise don't attempt realism.
 | 
									// b0 is the keyboard clock; ensure it's inhibited when asked but otherwise don't attempt realism.
 | 
				
			||||||
@@ -456,8 +458,14 @@ private:
 | 
				
			|||||||
//					output_.append({0xfa});
 | 
					//					output_.append({0xfa});
 | 
				
			||||||
//				break;
 | 
					//				break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				case 0xf2:	output_.append({0xfa, 0xab, 0x41});	break;
 | 
									case 0xf2:
 | 
				
			||||||
				case 0xff:	output_.append({0xfa, 0xaa});		break;
 | 
										output_.append({0xfa, 0xab, 0x41});
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									case 0xff:
 | 
				
			||||||
 | 
										output_.append({0xfa, 0xaa});
 | 
				
			||||||
 | 
										should_log = true;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -488,14 +496,13 @@ private:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void check_irqs() {
 | 
						void check_irqs() {
 | 
				
			||||||
 | 
							bool new_irq1 = false;
 | 
				
			||||||
		if(output_.empty() && !(control_ & Control::InhibitKeyboard) && !keyboard_.output().empty()) {
 | 
							if(output_.empty() && !(control_ & Control::InhibitKeyboard) && !keyboard_.output().empty()) {
 | 
				
			||||||
			output_.append({keyboard_.output().next()});
 | 
								output_.append({keyboard_.output().next()});
 | 
				
			||||||
 | 
								new_irq1 = control_ & Control::AllowKeyboardInterrupts;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							pics_.pic[0].template apply_edge<1>(new_irq1);
 | 
				
			||||||
		const bool new_irq = (control_ & Control::AllowInterrupts) && !output_.empty();
 | 
							log_.info().append("IRQ1: %d", new_irq1);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		log_.info().append("IRQ1: %d", new_irq);
 | 
					 | 
				
			||||||
		pics_.pic[0].template apply_edge<1>(new_irq);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -951,24 +951,20 @@ public:
 | 
				
			|||||||
//		should_log = (decoded_ip_ >= 0x21d0 && decoded_ip_ < 0x221c);
 | 
					//		should_log = (decoded_ip_ >= 0x21d0 && decoded_ip_ < 0x221c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(should_log) {
 | 
							if(should_log) {
 | 
				
			||||||
			const auto next = to_string(decoded_, InstructionSet::x86::Model::i8086);
 | 
								log.info().append(
 | 
				
			||||||
			static std::string previous;
 | 
									"%04x %s",
 | 
				
			||||||
			if(next != previous) {
 | 
										decoded_ip_,
 | 
				
			||||||
				std::cout << std::hex << decoded_ip_ << " " << next;
 | 
										to_string(decoded_, InstructionSet::x86::Model::i80286).c_str()
 | 
				
			||||||
 | 
								).append_if(decoded_.second.operation() == InstructionSet::x86::Operation::INT,
 | 
				
			||||||
				if(decoded_.second.operation() == InstructionSet::x86::Operation::INT) {
 | 
									" dl:%02x ah:%02x ch:%02x cl:%02x dh:%02x es:%04x bx:%04x",
 | 
				
			||||||
					std::cout << " dl:" << std::hex << +context_.registers.dl() << "; ";
 | 
										context_.registers.dl(),
 | 
				
			||||||
					std::cout << "ah:" << std::hex << +context_.registers.ah() << "; ";
 | 
										context_.registers.ah(),
 | 
				
			||||||
					std::cout << "ch:" << std::hex << +context_.registers.ch() << "; ";
 | 
										context_.registers.ch(),
 | 
				
			||||||
					std::cout << "cl:" << std::hex << +context_.registers.cl() << "; ";
 | 
										context_.registers.cl(),
 | 
				
			||||||
					std::cout << "dh:" << std::hex << +context_.registers.dh() << "; ";
 | 
										context_.registers.dh(),
 | 
				
			||||||
					std::cout << "es:" << std::hex << +context_.registers.es() << "; ";
 | 
										context_.registers.es(),
 | 
				
			||||||
					std::cout << "bx:" << std::hex << +context_.registers.bx();
 | 
										context_.registers.bx()
 | 
				
			||||||
				}
 | 
								);
 | 
				
			||||||
 | 
					 | 
				
			||||||
				std::cout << std::endl;
 | 
					 | 
				
			||||||
				previous = next;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(decoded_.second.operation() == InstructionSet::x86::Operation::Invalid) {
 | 
							if(decoded_.second.operation() == InstructionSet::x86::Operation::Invalid) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -176,10 +176,10 @@ public:
 | 
				
			|||||||
	~LogLine() {
 | 
						~LogLine() {
 | 
				
			||||||
		thread_local RepeatAccumulator accumulator;
 | 
							thread_local RepeatAccumulator accumulator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(output_ == accumulator.last && source == accumulator.source && stream_ == accumulator.stream) {
 | 
					//		if(output_ == accumulator.last && source == accumulator.source && stream_ == accumulator.stream) {
 | 
				
			||||||
			++accumulator.count;
 | 
					//			++accumulator.count;
 | 
				
			||||||
			return;
 | 
					//			return;
 | 
				
			||||||
		}
 | 
					//		}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if(!accumulator.last.empty()) {
 | 
							if(!accumulator.last.empty()) {
 | 
				
			||||||
			const char *const unadorned_prefix = prefix(accumulator.source);
 | 
								const char *const unadorned_prefix = prefix(accumulator.source);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user