diff --git a/src/emucore/tia/core_6502ts/DelayQueue.cxx b/src/emucore/tia/core_6502ts/DelayQueue.cxx index 52c16556d..8617cfaf9 100644 --- a/src/emucore/tia/core_6502ts/DelayQueue.cxx +++ b/src/emucore/tia/core_6502ts/DelayQueue.cxx @@ -51,17 +51,4 @@ namespace TIA6502tsCore { myIndices[address] = index; } - void DelayQueue::execute(Executor& executor) { - DelayQueueMember& currentMember = myMembers.at(myIndex); - - for (auto&& entry : currentMember) { - executor(entry.address, entry.value); - myIndices[entry.address] = 0xFF; - } - - currentMember.clear(); - - myIndex = (myIndex + 1) & myMembers.size(); - } - } // namespace TIA6502tsCore \ No newline at end of file diff --git a/src/emucore/tia/core_6502ts/DelayQueue.hxx b/src/emucore/tia/core_6502ts/DelayQueue.hxx index ba78827dd..37713c639 100644 --- a/src/emucore/tia/core_6502ts/DelayQueue.hxx +++ b/src/emucore/tia/core_6502ts/DelayQueue.hxx @@ -27,18 +27,6 @@ namespace TIA6502tsCore { class DelayQueue { - public: - - class Executor { - - public: - - virtual void operator()(uInt8 address, uInt8 value) = 0; - - virtual ~Executor() = default; - - }; - public: DelayQueue(uInt8 length, uInt8 size); @@ -47,7 +35,7 @@ class DelayQueue { void push(uInt8 address, uInt8 value, uInt8 delay); - void execute(Executor& executor); + template void execute(T executor); private: @@ -67,6 +55,23 @@ class DelayQueue { }; +// ############################################################################ +// Implementation +// ############################################################################ + +template void DelayQueue::execute(T executor) { + DelayQueueMember& currentMember = myMembers.at(myIndex); + + for (auto&& entry : currentMember) { + executor(entry.address, entry.value); + myIndices[entry.address] = 0xFF; + } + + currentMember.clear(); + + myIndex = (myIndex + 1) & myMembers.size(); +} + } // namespace TIA6502tsCore #endif // TIA_6502TS_CORE_DELAY_QUEUE \ No newline at end of file diff --git a/src/emucore/tia/core_6502ts/TIA.cxx b/src/emucore/tia/core_6502ts/TIA.cxx index 4ecdd330f..b25f53f30 100644 --- a/src/emucore/tia/core_6502ts/TIA.cxx +++ b/src/emucore/tia/core_6502ts/TIA.cxx @@ -28,27 +28,7 @@ namespace TIA6502tsCore { mySound(sound), mySettings(settings), myDelayQueue(10, 20) - { - class DelayedWriteExecutor : public DelayQueue::Executor { - - public: - - DelayedWriteExecutor(TIA& tia) : myTia(tia) - {} - - void operator()(uInt8 address, uInt8 value) override - { - myTia.delayedWrite(address, value); - } - - private: - - TIA& myTia; - - }; - - myDelayQueueExecutor.reset(new DelayedWriteExecutor(*this)); - } + {} // TODO: stub void TIA::reset() diff --git a/src/emucore/tia/core_6502ts/TIA.hxx b/src/emucore/tia/core_6502ts/TIA.hxx index a1ddba8a3..eeef1e3ca 100644 --- a/src/emucore/tia/core_6502ts/TIA.hxx +++ b/src/emucore/tia/core_6502ts/TIA.hxx @@ -128,7 +128,6 @@ class TIA : public AbstractTIA { Settings& mySettings; DelayQueue myDelayQueue; - unique_ptr myDelayQueueExecutor; private: