1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-06 01:28:57 +00:00

Messier and messier, but I've at least attempted to implement hardware attention acknowledge.

This commit is contained in:
Thomas Harte 2016-07-08 19:00:39 -04:00
parent 9a08ef61cb
commit 8827597363
2 changed files with 32 additions and 6 deletions

View File

@ -30,7 +30,14 @@ 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) printf("%04x\n", address);
static bool log = false;
if(operation == CPU6502::BusOperation::ReadOpcode)
{
log = (address >= 0xE85B && address <= 0xE907) || (address >= 0xE9C9 && address <= 0xEA2D);
if(log) printf("\n%04x: ", address);
}
if(log) printf("[%c %04x] ", isReadOperation(operation) ? 'r' : 'w', address);
if(address < 0x800)
{
@ -46,6 +53,10 @@ 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

View File

@ -20,7 +20,7 @@ class SerialPortVIA: public MOS::MOS6522<SerialPortVIA>, public MOS::MOS6522IRQD
public:
using MOS6522IRQDelegate::set_interrupt_status;
SerialPortVIA() : _portB(0x9f), _attention_acknowledge_level(false) {}
SerialPortVIA() : _portB(0x00), _attention_acknowledge_level(false), _attention_level_input(true), _data_level_output(false) {}
uint8_t get_port_input(Port port) {
if(port) {
@ -37,10 +37,10 @@ class SerialPortVIA: public MOS::MOS6522<SerialPortVIA>, public MOS::MOS6522IRQD
printf("1540 output: %02x\n", value);
// "ATNA (Attention Acknowledge) is an output from PB4 which is sensed on the serial data line after being exclusively "ored" by the attention line and inverted"
_attention_acknowledge_level = !(value&0x10);
serialPort->set_output(::Commodore::Serial::Line::Clock, (::Commodore::Serial::LineLevel)!(value&0x08));
serialPort->set_output(::Commodore::Serial::Line::Data, (::Commodore::Serial::LineLevel)!(value&0x02));
_data_level_output = (value&0x02);
// serialPort->set_output(::Commodore::Serial::Line::Data, _attention_acknowledge_level )
serialPort->set_output(::Commodore::Serial::Line::Clock, (::Commodore::Serial::LineLevel)!(value&0x08));
update_data_line();
}
// printf("1540 serial port VIA port B: %02x\n", value);
}
@ -56,8 +56,10 @@ class SerialPortVIA: public MOS::MOS6522<SerialPortVIA>, public MOS::MOS6522IRQD
case ::Commodore::Serial::Line::Clock: _portB = (_portB & ~0x04) | (value ? 0x00 : 0x04); break;
case ::Commodore::Serial::Line::Attention:
// "ATN (Attention) is an input on pin 3 of P2 and P3 that is sensed at PB7 and CA1 of UC3 after being inverted by UA1"
_attention_level_input = !value;
_portB = (_portB & ~0x80) | (value ? 0x00 : 0x80);
set_control_line_input(Port::A, Line::One, !value);
update_data_line();
break;
}
}
@ -69,7 +71,20 @@ class SerialPortVIA: public MOS::MOS6522<SerialPortVIA>, public MOS::MOS6522IRQD
private:
uint8_t _portB;
std::weak_ptr<::Commodore::Serial::Port> _serialPort;
bool _attention_acknowledge_level;
bool _attention_acknowledge_level, _attention_level_input, _data_level_output;
void update_data_line()
{
std::shared_ptr<::Commodore::Serial::Port> serialPort = _serialPort.lock();
if(serialPort) {
serialPort->set_output(::Commodore::Serial::Line::Data,
(::Commodore::Serial::LineLevel)!(_data_level_output
|| (_attention_level_input == _attention_acknowledge_level))
);
//
}
}
};
class DriveVIA: public MOS::MOS6522<DriveVIA>, public MOS::MOS6522IRQDelegate {