EightBit/inc/ClockedChip.h
Adrian Conlon 2c23289caa Expose the clock tick as an externally driven action.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
2019-05-05 10:28:24 +01:00

25 lines
494 B
C++

#pragma once
#include "Chip.h"
#include "EventArgs.h"
#include "Signal.h"
namespace EightBit {
class ClockedChip : public Chip {
public:
~ClockedChip() {};
Signal<EventArgs> Ticked;
void tick(const int extra) { for (int i = 0; i < extra; ++i) tick(); }
void tick() { ++m_cycles; Ticked.fire(EventArgs::empty()); }
[[nodiscard]] auto cycles() const noexcept { return m_cycles; }
protected:
void resetCycles() noexcept { m_cycles = 0; }
private:
int m_cycles = 0;
};
}