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:
|
2022-03-26 16:06:29 +00:00
|
|
|
ClockedChip(const ClockedChip& rhs) noexcept;
|
|
|
|
bool operator==(const ClockedChip& rhs) const noexcept;
|
2021-12-27 14:24:38 +00:00
|
|
|
|
2019-01-10 22:23:51 +00:00
|
|
|
Signal<EventArgs> Ticked;
|
|
|
|
|
2021-07-18 13:28:40 +00:00
|
|
|
[[nodiscard]] constexpr auto cycles() const noexcept { return m_cycles; }
|
2019-01-10 22:23:51 +00:00
|
|
|
|
2024-01-11 09:16:40 +00:00
|
|
|
void tick(int extra = 1) {
|
2022-01-17 19:10:15 +00:00
|
|
|
for (int i = 0; i < extra; ++i) {
|
|
|
|
++m_cycles;
|
|
|
|
Ticked.fire();
|
|
|
|
}
|
|
|
|
}
|
2021-01-09 08:41:48 +00:00
|
|
|
|
2019-01-10 22:23:51 +00:00
|
|
|
protected:
|
2021-07-18 13:28:40 +00:00
|
|
|
ClockedChip() noexcept = default;
|
|
|
|
|
2022-01-17 19:10:15 +00:00
|
|
|
constexpr void resetCycles() noexcept { m_cycles = 0; }
|
2019-01-10 22:23:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int m_cycles = 0;
|
|
|
|
};
|
|
|
|
}
|