EightBit/inc/ClockedChip.h

25 lines
494 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() {};
Signal<EventArgs> Ticked;
[[nodiscard]] auto cycles() const noexcept { return m_cycles; }
protected:
void resetCycles() noexcept { m_cycles = 0; }
void tick(const int extra) { for (int i = 0; i < extra; ++i) tick(); }
void tick() { ++m_cycles; Ticked.fire(EventArgs::empty()); }
private:
int m_cycles = 0;
};
}