diff --git a/Components/6522/6522.cpp b/Components/6522/6522.cpp index 2e302b645..412cf4791 100644 --- a/Components/6522/6522.cpp +++ b/Components/6522/6522.cpp @@ -10,15 +10,3 @@ using namespace MOS; -MOS6522::MOS6522() -{ -} - -void MOS6522::set_register(int address, uint8_t value) -{ -} - -uint8_t MOS6522::get_register(int address) -{ - return 0xff; -} diff --git a/Components/6522/6522.hpp b/Components/6522/6522.hpp index 834c58e49..a519107a9 100644 --- a/Components/6522/6522.hpp +++ b/Components/6522/6522.hpp @@ -13,12 +13,18 @@ namespace MOS { -class MOS6522 { +template class MOS6522 { public: - MOS6522(); + MOS6522() : _data_direction{0, 0} {} - void set_register(int address, uint8_t value); - uint8_t get_register(int address); + void set_register(int address, uint8_t value) {} + uint8_t get_register(int address) {return 0xff;} + + private: + uint16_t _interval_timers[2]; + uint8_t _shift_register; + uint8_t _input_latches[2]; + uint8_t _data_direction[2]; }; } diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index 11c48b40f..2581b7553 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -43,7 +43,7 @@ using namespace MOS; */ MOS6560::MOS6560() : - _crt(new Outputs::CRT::CRT(65*4, 4, 261, Outputs::CRT::ColourSpace::YIQ, 65*4, 1, 1)), // TODO: turn 261 back into 263 once vertical sync exists + _crt(new Outputs::CRT::CRT(65*4, 4, 261, Outputs::CRT::ColourSpace::YIQ, 228, 1, 1)), // TODO: turn 261 back into 263 once vertical sync exists _horizontal_counter(0), _vertical_counter(0) { diff --git a/Machines/Vic-20/Vic20.cpp b/Machines/Vic-20/Vic20.cpp index 249d16cd2..1b9724487 100644 --- a/Machines/Vic-20/Vic20.cpp +++ b/Machines/Vic-20/Vic20.cpp @@ -33,6 +33,14 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin { *value = _mos6560->get_register(address - 0x9000); } + else if((address&0xfff0) == 0x9110) + { + *value = _userPortVIA->get_register(address - 0x9110); + } + else if((address&0xfff0) == 0x9120) + { + *value = _keyboardVIA->get_register(address - 0x9120); + } } else { @@ -42,6 +50,15 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin { _mos6560->set_register(address - 0x9000, *value); } + else if((address&0xfff0) == 0x9110) + { + _userPortVIA->set_register(address - 0x9110, *value); + } + else if((address&0xfff0) == 0x9120) + { + _keyboardVIA->set_register(address - 0x9120, *value); + } + // TODO: the 6522 } diff --git a/Machines/Vic-20/Vic20.hpp b/Machines/Vic-20/Vic20.hpp index 460355d8d..c82e6b60f 100644 --- a/Machines/Vic-20/Vic20.hpp +++ b/Machines/Vic-20/Vic20.hpp @@ -11,6 +11,7 @@ #include "../../Processors/6502/CPU6502.hpp" #include "../../Components/6560/6560.hpp" +#include "../../Components/6522/6522.hpp" #include "../CRTMachine.hpp" namespace Vic20 { @@ -21,6 +22,12 @@ enum ROMSlot { ROMSlotCharacters, }; +class UserPortVIA: public MOS::MOS6522 { +}; + +class KeyboardVIA: public MOS::MOS6522 { +}; + class Machine: public CPU6502::Processor, public CRTMachine::Machine { public: Machine(); @@ -65,6 +72,8 @@ class Machine: public CPU6502::Processor, public CRTMachine::Machine { } std::unique_ptr _mos6560; + std::unique_ptr _userPortVIA; + std::unique_ptr _keyboardVIA; }; }