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:
|
2020-05-03 19:29:18 +00:00
|
|
|
~ClockedChip() = default;
|
2019-01-10 22:23:51 +00:00
|
|
|
|
|
|
|
Signal<EventArgs> Ticked;
|
|
|
|
|
2019-05-05 09:28:24 +00:00
|
|
|
void tick(const int extra) { for (int i = 0; i < extra; ++i) tick(); }
|
|
|
|
void tick() { ++m_cycles; Ticked.fire(EventArgs::empty()); }
|
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;
|
|
|
|
};
|
|
|
|
}
|