mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-26 15:32:04 +00:00
Okay, so it seems that sync also works the other way around.
This commit is contained in:
parent
693c8b2438
commit
f589d639db
@ -30,7 +30,7 @@ void Machine::set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bu
|
||||
|
||||
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
|
||||
{
|
||||
// if(operation == CPU6502::BusOperation::ReadOpcode && (address >= 0xE9C9 && address <= 0xEA2D)) printf("%04x\n", address);
|
||||
if(operation == CPU6502::BusOperation::ReadOpcode && (address >= 0xF556 && address <= 0xF56D)) printf("%04x\n", address);
|
||||
// if(operation == CPU6502::BusOperation::ReadOpcode && (address == 0xE887)) printf("A: %02x\n", get_value_of_register(CPU6502::Register::A));
|
||||
|
||||
/* static bool log = false;
|
||||
@ -56,10 +56,6 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
}
|
||||
else if(address >= 0x1800 && address <= 0x180f)
|
||||
{
|
||||
if(address == 0x1805)
|
||||
{
|
||||
printf("Timer\n");
|
||||
}
|
||||
if(isReadOperation(operation))
|
||||
*value = _serialPortVIA->get_register(address);
|
||||
else
|
||||
|
@ -91,10 +91,23 @@ class DriveVIA: public MOS::MOS6522<DriveVIA>, public MOS::MOS6522IRQDelegate {
|
||||
uint8_t get_port_input(Port port) {
|
||||
if(port)
|
||||
{
|
||||
return 0x7f; // imply not sync, write protect tab uncovered
|
||||
return 0xff; // imply not sync, write protect tab uncovered
|
||||
}
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
void set_port_output(Port port, uint8_t value, uint8_t direction_mask) {
|
||||
if(port)
|
||||
{
|
||||
if(value&4)
|
||||
{
|
||||
printf("Head step: %d\n", value&3);
|
||||
printf("Motor: %s\n", value&4 ? "On" : "Off");
|
||||
printf("LED: %s\n", value&8 ? "On" : "Off");
|
||||
printf("Density: %d\n", (value >> 5)&3);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class SerialPort : public ::Commodore::Serial::Port {
|
||||
|
@ -45,14 +45,12 @@ void Bus::set_line_output_did_change(Line line)
|
||||
if(locked_port)
|
||||
{
|
||||
new_line_level = (LineLevel)((bool)new_line_level & (bool)locked_port->get_output(line));
|
||||
// printf("[%s] %s is now %s\n", typeid(locked_port).name(), (bool)locked_port->get_output(line) ? "high" : "low");
|
||||
}
|
||||
}
|
||||
|
||||
// post an update only if one occurred
|
||||
if(new_line_level != _line_levels[line])
|
||||
{
|
||||
printf("[Bus] %s is %s\n", StringForLine(line), new_line_level ? "high" : "low");
|
||||
_line_levels[line] = new_line_level;
|
||||
|
||||
for(std::weak_ptr<Port> port : _ports)
|
||||
@ -65,3 +63,25 @@ void Bus::set_line_output_did_change(Line line)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - The debug port
|
||||
|
||||
void DebugPort::set_input(Line line, LineLevel value)
|
||||
{
|
||||
_input_levels[line] = value;
|
||||
|
||||
printf("[Bus] %s is %s\n", StringForLine(line), value ? "high" : "low");
|
||||
if(!_incoming_count)
|
||||
{
|
||||
_incoming_count = (!_input_levels[Line::Clock] && !_input_levels[Line::Data]) ? 8 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(line == Line::Clock && value)
|
||||
{
|
||||
_incoming_byte = (_incoming_byte >> 1) | (_input_levels[Line::Data] ? 0x80 : 0x00);
|
||||
}
|
||||
_incoming_count--;
|
||||
if(_incoming_count == 0) printf("[Bus] Observed %02x\n", _incoming_byte);
|
||||
}
|
||||
}
|
||||
|
@ -71,6 +71,18 @@ namespace Serial {
|
||||
LineLevel _line_levels[5];
|
||||
};
|
||||
|
||||
class DebugPort: public Port {
|
||||
public:
|
||||
void set_input(Line line, LineLevel value);
|
||||
|
||||
DebugPort() : _incoming_count(0) {}
|
||||
|
||||
private:
|
||||
uint8_t _incoming_byte;
|
||||
int _incoming_count;
|
||||
LineLevel _input_levels[5];
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,10 @@ Machine::Machine() :
|
||||
|
||||
// TEMPORARY: attach a [diskless] 1540
|
||||
set_disc();
|
||||
|
||||
_debugPort.reset(new ::Commodore::Serial::DebugPort);
|
||||
_debugPort->set_serial_bus(_serialBus);
|
||||
_serialBus->add_port(_debugPort);
|
||||
}
|
||||
|
||||
void Machine::write_to_map(uint8_t **map, uint8_t *area, uint16_t address, uint16_t length)
|
||||
|
@ -295,6 +295,7 @@ class Machine:
|
||||
std::shared_ptr<KeyboardVIA> _keyboardVIA;
|
||||
std::shared_ptr<SerialPort> _serialPort;
|
||||
std::shared_ptr<::Commodore::Serial::Bus> _serialBus;
|
||||
std::shared_ptr<::Commodore::Serial::DebugPort> _debugPort;
|
||||
|
||||
// Tape
|
||||
Tape _tape;
|
||||
|
Loading…
x
Reference in New Issue
Block a user