1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-30 07:55:01 +00:00

Further fleshing out: added a serial port for the serial bus.

This commit is contained in:
Thomas Harte 2016-07-05 17:27:02 -04:00
parent d1eea6943d
commit d16b79073e
4 changed files with 50 additions and 3 deletions

View File

@ -11,6 +11,19 @@
using namespace Commodore::C1540;
Machine::Machine()
{
_serialPortVIA.reset(new SerialPortVIA);
_serialPort.reset(new SerialPort);
_serialPort->set_serial_port_via(_serialPortVIA);
}
void Machine::set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus)
{
_serialPort->set_serial_bus(serial_bus);
serial_bus->add_port(_serialPort);
}
unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value)
{
if(address < 0x800)
@ -25,6 +38,15 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
if(isReadOperation(operation))
*value = _rom[address & 0x3fff];
}
else if(address >= 0x1800 && address <= 0x180f)
{
if(isReadOperation(operation))
*value = _serialPortVIA->get_register(address);
else
_serialPortVIA->set_register(address, *value);
}
_serialPortVIA->run_for_half_cycles(2);
return 1;
}

View File

@ -11,21 +11,45 @@
#include "../../../Processors/6502/CPU6502.hpp"
#include "../../../Components/6522/6522.hpp"
#include "../SerialBus.hpp"
namespace Commodore {
namespace C1540 {
class SerialPortVIA: public MOS::MOS6522<SerialPortVIA>, public MOS::MOS6522IRQDelegate {
public:
using MOS6522IRQDelegate::set_interrupt_status;
};
class SerialPort : public ::Commodore::Serial::Port {
public:
void set_input(::Commodore::Serial::Line line, bool value) {
}
void set_serial_port_via(std::shared_ptr<SerialPortVIA> serialPortVIA) {
_serialPortVIA = serialPortVIA;
}
private:
std::weak_ptr<SerialPortVIA> _serialPortVIA;
};
class Machine:
public CPU6502::Processor<Machine> {
public:
Machine();
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
void set_rom(const uint8_t *rom);
void set_serial_bus(std::shared_ptr<::Commodore::Serial::Bus> serial_bus);
private:
uint8_t _ram[0x800];
uint8_t _rom[0x4000];
std::shared_ptr<SerialPortVIA> _serialPortVIA;
std::shared_ptr<SerialPort> _serialPort;
};
}

View File

@ -335,5 +335,9 @@ void Tape::process_input_pulse(Storage::Tape::Pulse pulse)
void Machine::set_disc()
{
// construct the 1540
_c1540.reset(new ::Commodore::C1540::Machine);
// attach it to the serial bus
_c1540->set_serial_bus(_serialBus);
}

View File

@ -60,9 +60,6 @@ enum JoystickInput {
Fire = 0x20
};
class UserPortVIA;
class KeyboardVIA;
class UserPortVIA: public MOS::MOS6522<UserPortVIA>, public MOS::MOS6522IRQDelegate {
public:
uint8_t get_port_input(Port port) {