EightBit/inc/ClockedChip.h

25 lines
483 B
C
Raw Normal View History

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