mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-01-15 12:30:51 +00:00
25 lines
494 B
C
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;
|
||
|
|
||
|
[[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;
|
||
|
};
|
||
|
}
|