mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Made a first attempt at wiring back serial port input.
This commit is contained in:
parent
d2cded7b59
commit
a25fcc7190
@ -28,7 +28,7 @@ Machine::Machine() :
|
|||||||
// wire up 6522s and serial port
|
// wire up 6522s and serial port
|
||||||
_userPortVIA->set_serial_port(_serialPort);
|
_userPortVIA->set_serial_port(_serialPort);
|
||||||
_keyboardVIA->set_serial_port(_serialPort);
|
_keyboardVIA->set_serial_port(_serialPort);
|
||||||
_serialPort->set_vias(_userPortVIA, _keyboardVIA);
|
_serialPort->set_user_port_via(_userPortVIA);
|
||||||
|
|
||||||
// wire up the 6522s, tape and machine
|
// wire up the 6522s, tape and machine
|
||||||
_userPortVIA->set_delegate(this);
|
_userPortVIA->set_delegate(this);
|
||||||
@ -323,10 +323,3 @@ void Tape::process_input_pulse(Storage::Tape::Pulse pulse)
|
|||||||
if(_delegate) _delegate->tape_did_change_input(this);
|
if(_delegate) _delegate->tape_did_change_input(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Serial Port
|
|
||||||
|
|
||||||
void SerialPort::set_input(::Commodore::Serial::Line line, bool value)
|
|
||||||
{
|
|
||||||
printf("Serial port line %d: %s\n", line, value ? "on" : "off");
|
|
||||||
}
|
|
||||||
|
@ -61,20 +61,6 @@ enum JoystickInput {
|
|||||||
class UserPortVIA;
|
class UserPortVIA;
|
||||||
class KeyboardVIA;
|
class KeyboardVIA;
|
||||||
|
|
||||||
class SerialPort : public ::Commodore::Serial::Port {
|
|
||||||
public:
|
|
||||||
void set_input(::Commodore::Serial::Line line, bool value);
|
|
||||||
|
|
||||||
void set_vias(std::shared_ptr<UserPortVIA> userPortVIA, std::shared_ptr<KeyboardVIA> keyboardVIA) {
|
|
||||||
_userPortVIA = userPortVIA;
|
|
||||||
_keyboardVIA = keyboardVIA;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::weak_ptr<UserPortVIA> _userPortVIA;
|
|
||||||
std::weak_ptr<KeyboardVIA> _keyboardVIA;
|
|
||||||
};
|
|
||||||
|
|
||||||
class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDelegate {
|
class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDelegate {
|
||||||
public:
|
public:
|
||||||
uint8_t get_port_input(Port port) {
|
uint8_t get_port_input(Port port) {
|
||||||
@ -90,6 +76,15 @@ class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_serial_line_state(::Commodore::Serial::Line line, bool value) {
|
||||||
|
printf("Serial port line %d: %s\n", line, value ? "on" : "off");
|
||||||
|
switch(line) {
|
||||||
|
default: break;
|
||||||
|
case ::Commodore::Serial::Line::Data: _portA = (_portA & ~0x02) | (value ? 0 : 0x02); break;
|
||||||
|
case ::Commodore::Serial::Line::Clock: _portA = (_portA & ~0x01) | (value ? 0 : 0x01); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void set_joystick_state(JoystickInput input, bool value) {
|
void set_joystick_state(JoystickInput input, bool value) {
|
||||||
if(input != JoystickInput::Right)
|
if(input != JoystickInput::Right)
|
||||||
{
|
{
|
||||||
@ -99,7 +94,7 @@ class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
|
|
||||||
void set_port_output(Port port, uint8_t value, uint8_t mask) {
|
void set_port_output(Port port, uint8_t value, uint8_t mask) {
|
||||||
if(!port) {
|
if(!port) {
|
||||||
std::shared_ptr<SerialPort> serialPort = _serialPort.lock();
|
std::shared_ptr<::Commodore::Serial::Port> serialPort = _serialPort.lock();
|
||||||
if(serialPort) serialPort->set_output(::Commodore::Serial::Line::Attention, !(value&0x80));
|
if(serialPort) serialPort->set_output(::Commodore::Serial::Line::Attention, !(value&0x80));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,13 +103,13 @@ class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
|
|
||||||
UserPortVIA() : _portA(0xbf) {}
|
UserPortVIA() : _portA(0xbf) {}
|
||||||
|
|
||||||
void set_serial_port(std::shared_ptr<SerialPort> serialPort) {
|
void set_serial_port(std::shared_ptr<::Commodore::Serial::Port> serialPort) {
|
||||||
_serialPort = serialPort;
|
_serialPort = serialPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t _portA;
|
uint8_t _portA;
|
||||||
std::weak_ptr<SerialPort> _serialPort;
|
std::weak_ptr<::Commodore::Serial::Port> _serialPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDelegate {
|
class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDelegate {
|
||||||
@ -156,7 +151,7 @@ class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
|
|
||||||
void set_control_line_output(Port port, Line line, bool value) {
|
void set_control_line_output(Port port, Line line, bool value) {
|
||||||
if(line == Line::Two) {
|
if(line == Line::Two) {
|
||||||
std::shared_ptr<SerialPort> serialPort = _serialPort.lock();
|
std::shared_ptr<::Commodore::Serial::Port> serialPort = _serialPort.lock();
|
||||||
if(serialPort) {
|
if(serialPort) {
|
||||||
if(port == Port::A) {
|
if(port == Port::A) {
|
||||||
serialPort->set_output(::Commodore::Serial::Line::Clock, value);
|
serialPort->set_output(::Commodore::Serial::Line::Clock, value);
|
||||||
@ -176,7 +171,7 @@ class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
|
|
||||||
using MOS6522IRQDelegate::set_interrupt_status;
|
using MOS6522IRQDelegate::set_interrupt_status;
|
||||||
|
|
||||||
void set_serial_port(std::shared_ptr<SerialPort> serialPort) {
|
void set_serial_port(std::shared_ptr<::Commodore::Serial::Port> serialPort) {
|
||||||
_serialPort = serialPort;
|
_serialPort = serialPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +179,22 @@ class KeyboardVIA: public MOS::MOS6522<KeyboardVIA>, public MOS::MOS6522IRQDeleg
|
|||||||
uint8_t _portB;
|
uint8_t _portB;
|
||||||
uint8_t _columns[8];
|
uint8_t _columns[8];
|
||||||
uint8_t _activation_mask;
|
uint8_t _activation_mask;
|
||||||
std::weak_ptr<SerialPort> _serialPort;
|
std::weak_ptr<::Commodore::Serial::Port> _serialPort;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SerialPort : public ::Commodore::Serial::Port {
|
||||||
|
public:
|
||||||
|
void set_input(::Commodore::Serial::Line line, bool value) {
|
||||||
|
std::shared_ptr<UserPortVIA> userPortVIA = _userPortVIA.lock();
|
||||||
|
if(userPortVIA) userPortVIA->set_serial_line_state(line, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_user_port_via(std::shared_ptr<UserPortVIA> userPortVIA) {
|
||||||
|
_userPortVIA = userPortVIA;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::weak_ptr<UserPortVIA> _userPortVIA;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Tape: public Storage::TapePlayer {
|
class Tape: public Storage::TapePlayer {
|
||||||
|
Loading…
Reference in New Issue
Block a user