--- nono/vm/sysclk.h 2026/04/29 17:05:25 1.1.1.10 +++ nono/vm/sysclk.h 2026/04/29 17:06:00 1.1.1.14 @@ -11,10 +11,9 @@ #pragma once #include "device.h" -#include "event.h" -#include "monitor.h" class InterruptDevice; +class Syncer; class SysClkDevice : public IODevice { @@ -26,20 +25,21 @@ class SysClkDevice : public IODevice bool Init() override; void ResetHard(bool poweron) override; - int GetFreq() const { return freq; } + uint GetFreq() const { return freq; } protected: // BusIO インタフェース static const uint32 NPORT = 1; - busdata Read(uint32 offset); - busdata Write(uint32 offset, uint32 data); - busdata Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); + bool PokePort(uint32 offset, uint32 data); private: // イベントコールバック - void Callback(Event& ev); + void Callback(Event *ev); - DECLARE_MONITOR_CALLBACK(MonitorUpdate); + DECLARE_MONITOR_SCREEN(MonitorScreen); // 割り込み状態をレジスタイメージにして返す uint8 GetInt() const; @@ -51,7 +51,7 @@ class SysClkDevice : public IODevice bool sysint {}; // 割り込みイベント - Event event { this }; + Event *event {}; // システムクロック周波数 [Hz] uint freq {}; @@ -59,17 +59,21 @@ class SysClkDevice : public IODevice // 本来のイベント間隔。機種によって異なる。 uint64 period {}; - // システムクロックが刻んでいる時刻 + // システムクロックが刻んでいる時刻 [tsec] uint64 stime {}; + // 実時間との差 (表示用) + int64 delta {}; + // システムクロックを実時間に同期する場合 true bool sync_rt {}; InterruptDevice *interrupt {}; + Syncer *syncer {}; - Monitor monitor { this }; + Monitor *monitor {}; }; -static inline SysClkDevice *GetSysClkDevice() { +inline SysClkDevice *GetSysClkDevice() { return Object::GetObject(OBJ_SYSCLK); }