From c7c55528e2658328bc49cd81d3c1ed1090c3472d Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 6 Jun 2016 20:29:39 -0400 Subject: [PATCH] Realised that registers appear also to be readable. --- Components/6560/6560.cpp | 7 +++++++ Components/6560/6560.hpp | 3 +++ Machines/Vic-20/Vic20.cpp | 4 ++++ Machines/Vic-20/Vic20.hpp | 4 ++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index a4f34c121..9781f5657 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -50,6 +50,7 @@ MOS6560::MOS6560() : void MOS6560::set_register(int address, uint8_t value) { + _registers[address] = value; switch(address) { case 0x0: @@ -99,6 +100,12 @@ void MOS6560::set_register(int address, uint8_t value) } } +uint8_t MOS6560::get_register(int address) +{ + return _registers[address]; +} + + void MOS6560::output_border(unsigned int number_of_cycles) { uint8_t *colour_pointer = _crt->allocate_write_area(1); diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 554ea8b7a..21a7da4f3 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -22,6 +22,7 @@ class MOS6560 { void set_graphics_value(uint8_t value, uint8_t colour_value); void set_register(int address, uint8_t value); + uint8_t get_register(int address); private: std::unique_ptr _crt; @@ -47,6 +48,8 @@ class MOS6560 { uint8_t *pixel_pointer; + uint8_t _registers[16]; + void output_border(unsigned int number_of_cycles); }; diff --git a/Machines/Vic-20/Vic20.cpp b/Machines/Vic-20/Vic20.cpp index ed3b72ca6..249d16cd2 100644 --- a/Machines/Vic-20/Vic20.cpp +++ b/Machines/Vic-20/Vic20.cpp @@ -29,6 +29,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(isReadOperation(operation)) { *value = read_memory(address); + if((address&0xfff0) == 0x9000) + { + *value = _mos6560->get_register(address - 0x9000); + } } else { diff --git a/Machines/Vic-20/Vic20.hpp b/Machines/Vic-20/Vic20.hpp index b4af33e4b..460355d8d 100644 --- a/Machines/Vic-20/Vic20.hpp +++ b/Machines/Vic-20/Vic20.hpp @@ -46,12 +46,12 @@ class Machine: public CPU6502::Processor, public CRTMachine::Machine { uint8_t _userBASICMemory[0x0400]; uint8_t _screenMemory[0x1000]; - uint8_t _colorMemory[0x0200]; + uint8_t _colorMemory[0x0400]; inline uint8_t *ram_pointer(uint16_t address) { if(address < sizeof(_userBASICMemory)) return &_userBASICMemory[address]; if(address >= 0x1000 && address < 0x2000) return &_screenMemory[address&0x0fff]; - if(address >= 0x9400 && address < 0x9600) return &_colorMemory[0x01ff]; + if(address >= 0x9400 && address < 0x9800) return &_colorMemory[0x03ff]; // TODO: make this 4-bit return nullptr; }