From c77a83d86f30a72d3939fd8b789d9011577232f9 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 24 Jul 2017 22:38:35 -0400 Subject: [PATCH] The 6560 is now a `ClockReceiver`. This reduces to zero the number of remaining instances of the text run_for_cycles in this codebase. --- Components/6560/6560.hpp | 7 +++++-- Machines/Commodore/Vic-20/Vic20.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Components/6560/6560.hpp b/Components/6560/6560.hpp index 8b0c1ad4c..2793b981f 100644 --- a/Components/6560/6560.hpp +++ b/Components/6560/6560.hpp @@ -11,6 +11,7 @@ #include "../../Outputs/CRT/CRT.hpp" #include "../../Outputs/Speaker.hpp" +#include "../ClockReceiver.hpp" namespace MOS { @@ -40,7 +41,7 @@ class Speaker: public ::Outputs::Filter { @c set_register and @c get_register provide register access. */ -template class MOS6560 { +template class MOS6560: public ClockReceiver> { public: MOS6560() : crt_(new Outputs::CRT::CRT(65*4, 4, Outputs::CRT::NTSC60, 2)), @@ -149,7 +150,9 @@ template class MOS6560 { /*! Runs for cycles. Derr. */ - inline void run_for_cycles(unsigned int number_of_cycles) { + inline void run_for(const Cycles &cycles) { + int number_of_cycles = cycles.as_int(); + // keep track of the amount of time since the speaker was updated; lazy updates are applied cycles_since_speaker_update_ += number_of_cycles; diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index b70d393e1..e9ba16e8c 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -99,7 +99,7 @@ Machine::~Machine() { unsigned int Machine::perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) { // run the phase-1 part of this cycle, in which the VIC accesses memory - if(!is_running_at_zero_cost_) mos6560_->run_for_cycles(1); + if(!is_running_at_zero_cost_) mos6560_->run_for(Cycles(1)); // run the phase-2 part of the cycle, which is whatever the 6502 said it should be if(isReadOperation(operation)) {