From 9566c875328b58b28dd68c3a68eda2e425b0ccd1 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 5 Jun 2016 12:11:12 -0400 Subject: [PATCH] Added enough to the machine that the 6560 can now produce output if it wishes. --- Components/6560/6560.cpp | 14 ++++++++++++++ Components/6560/6560.hpp | 5 +++++ Machines/Vic-20/Vic20.cpp | 28 +++++++++++----------------- Machines/Vic-20/Vic20.hpp | 8 ++++++++ 4 files changed, 38 insertions(+), 17 deletions(-) diff --git a/Components/6560/6560.cpp b/Components/6560/6560.cpp index 7573de2d9..f1fa17ce4 100644 --- a/Components/6560/6560.cpp +++ b/Components/6560/6560.cpp @@ -19,3 +19,17 @@ MOS6560::MOS6560() : "return vec3(1.0);" "}"); } + +void MOS6560::set_register(int address, uint8_t value) +{ + printf("%02x -> %d\n", value, address); +} + +uint16_t MOS6560::get_address() +{ + return 0; +} + +void MOS6560::set_graphics_value(uint8_t value) +{ +} diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 60d71395e..027e69bfd 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -18,6 +18,11 @@ class MOS6560 { MOS6560(); Outputs::CRT::CRT *get_crt() { return _crt.get(); } + uint16_t get_address(); + void set_graphics_value(uint8_t value); + + void set_register(int address, uint8_t value); + private: std::unique_ptr _crt; }; diff --git a/Machines/Vic-20/Vic20.cpp b/Machines/Vic-20/Vic20.cpp index 74d0fa12c..38217047f 100644 --- a/Machines/Vic-20/Vic20.cpp +++ b/Machines/Vic-20/Vic20.cpp @@ -21,28 +21,22 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin { set_reset_line(false); + // run the phase-1 part of this cycle, in which the VIC accesses memory + _mos6560->set_graphics_value(read_memory(_mos6560->get_address())); + + // run the phase-2 part of the cycle, which is whatever the 6502 said it should be if(isReadOperation(operation)) { - uint8_t returnValue = 0xff; - - if(address < sizeof(_ram)) - returnValue &= _ram[address]; - - if(address >= 0x8000 && address < 0x9000) - returnValue &= _characterROM[address&0x0fff]; - - if(address >= 0xc000 && address < 0xe000) - returnValue &= _basicROM[address&0x1fff]; - - if(address >= 0xe000) - returnValue &= _kernelROM[address&0x1fff]; - - *value = returnValue; + *value = read_memory(address); } else { - if(address < sizeof(_ram)) - _ram[address] = *value; + if(address < sizeof(_ram)) _ram[address] = *value; + else if((address&0xfff0) == 0x9000) + { + _mos6560->set_register(address - 0x9000, *value); + } + // TODO: the 6522 } return 1; diff --git a/Machines/Vic-20/Vic20.hpp b/Machines/Vic-20/Vic20.hpp index 4c6f81416..1d528977f 100644 --- a/Machines/Vic-20/Vic20.hpp +++ b/Machines/Vic-20/Vic20.hpp @@ -45,6 +45,14 @@ class Machine: public CPU6502::Processor, public CRTMachine::Machine { uint8_t _kernelROM[0x2000]; uint8_t _ram[0x2000]; + inline uint8_t read_memory(uint16_t address) { + if(address < sizeof(_ram)) return _ram[address]; + else if(address >= 0x8000 && address < 0x9000) return _characterROM[address&0x0fff]; + else if(address >= 0xc000 && address < 0xe000) return _basicROM[address&0x1fff]; + else if(address >= 0xe000) return _kernelROM[address&0x1fff]; + return 0xff; + } + std::unique_ptr _mos6560; };