--- nono/vm/mk48t02.h 2026/04/29 17:05:18 1.1.1.13 +++ nono/vm/mk48t02.h 2026/04/29 17:06:01 1.1.1.17 @@ -10,10 +10,8 @@ #pragma once -#include "device.h" -#include "mappedfile.h" -#include "monitor.h" #include "rtc.h" +#include "mappedfile.h" // MK48T02 の時計部分のレジスタと内部状態 struct MK48T02Clock @@ -80,7 +78,7 @@ struct MK48T02Clock static const uint8 WRITE = 0x80; // WRITE BIT static const uint8 READ = 0x40; // READ BIT - // 内部のカウンタと毎秒ラッチされるレジスタの2ステージ構成になっている + // 内部のカウンタと毎秒ラッチされるレジスタの2ステージ構成になっている。 // ここには制御ビット部分は含まない。 struct calendar { uint8 sec; // BCD 秒(00-59) @@ -93,20 +91,19 @@ struct MK48T02Clock }; calendar in {}; // 内部カウンタ - // 秒カウンタの bit7 が STOP ビット + // 秒カウンタの bit7 が STOP ビット。 static const uint8 STOP = 0x80; - // STOP 状態を保持 + // STOP 状態を保持。 uint8 stop {}; - // 時カウンタの bit7 が KICKSTART ビット + // 時カウンタの bit7 が KICKSTART ビット。 // KICKSTART は内部発振器のスタートに使用するが、改良版である - // M48T02 (K なし)では廃止された。動作は実装しない。 + // M48T02 (K なし)では廃止された。動作は実装しない。 static const uint8 KICKSTART = 0x80; // KICKSTART 状態を保持 uint8 kickstart {}; - // 曜日カウンタの bit6 が Frequency Test ビット - // 動作は実装しない。 + // 曜日カウンタの bit6 が Frequency Test ビット。動作は実装しない。 static const uint8 FREQTEST = 0x40; // FreqTest 状態を保持 uint8 freqtest {}; @@ -117,7 +114,7 @@ class MK48T02Device : public RTCDevice using inherited = RTCDevice; public: MK48T02Device(); - virtual ~MK48T02Device() override; + ~MK48T02Device() override; bool Init() override; @@ -130,13 +127,6 @@ class MK48T02Device : public RTCDevice // 全域をゼロクリアする (内蔵 ROM からのアクセス用) void ClearAll(); - // BusIO インタフェース - // (内蔵 ROM からのアクセス用に特別に public にしてある) - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); - uint64 Poke(uint32 offset, uint32 data) override; - // 内蔵カウンタへのアクセス。 // ラッチカウンタではないことに注意。 uint GetSec() const override; // 秒(0-59) @@ -148,9 +138,14 @@ class MK48T02Device : public RTCDevice uint GetYear() const override; // 年(西暦) uint GetLeap() const override; // うるう年カウンタ(0..3) - protected: // BusIO インタフェース + // (内蔵 ROM からのアクセス用に特別に public にしてある) + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); + protected: static const uint32 NPORT = 2048; + bool PokePort(uint32 offset, uint32 data); // 仮想RTCからのクロック void Tick1Hz() override; @@ -182,7 +177,7 @@ class MK48T02Device : public RTCDevice // カレンダを NVRAM にストア void Store(const MK48T02Clock::calendar& cal); - DECLARE_MONITOR_CALLBACK(MonitorUpdate); + DECLARE_MONITOR_SCREEN(MonitorScreen); // ファイル std::string filename {}; @@ -198,9 +193,9 @@ class MK48T02Device : public RTCDevice // 外部レジスタをホールド(更新停止)しているときは true bool hold {}; - Monitor monitor { this }; + Monitor *monitor {}; }; -static inline MK48T02Device *GetMK48T02Device() { +inline MK48T02Device *GetMK48T02Device() { return Object::GetObject(OBJ_RTC); }