mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-09-01 00:28:55 +00:00
36 lines
629 B
C++
36 lines
629 B
C++
#pragma once
|
|
|
|
#include "Chip.h"
|
|
#include "EventArgs.h"
|
|
#include "Signal.h"
|
|
|
|
namespace EightBit {
|
|
class ClockedChip : public Chip {
|
|
public:
|
|
ClockedChip(const ClockedChip& rhs) noexcept;
|
|
bool operator==(const ClockedChip& rhs) const noexcept;
|
|
|
|
Signal<EventArgs> Ticked;
|
|
|
|
[[nodiscard]] constexpr auto cycles() const noexcept { return m_cycles; }
|
|
|
|
void tick() {
|
|
++m_cycles;
|
|
Ticked.fire();
|
|
}
|
|
|
|
void tick(int extra) {
|
|
for (int i = 0; i < extra; ++i)
|
|
tick();
|
|
}
|
|
|
|
protected:
|
|
ClockedChip() noexcept = default;
|
|
|
|
constexpr void resetCycles() noexcept { m_cycles = 0; }
|
|
|
|
private:
|
|
int m_cycles = 0;
|
|
};
|
|
}
|