--- nono/vm/scc.h 2026/04/29 17:05:09 1.1.1.9 +++ nono/vm/scc.h 2026/04/29 17:05:28 1.1.1.12 @@ -10,38 +10,37 @@ #pragma once -#include "device.h" #include "mpscc.h" +class Keyboard; + class SCCDevice : public MPSCCDevice { using inherited = MPSCCDevice; - static const int baseaddr = 0xe98000; - public: SCCDevice(); - virtual ~SCCDevice() override; + ~SCCDevice() override; + bool Init() override; void ResetHard(bool poweron) override; // 割り込みアクノリッジ - int InterruptAcknowledge(); + busdata InterruptAcknowledge(); protected: // BusIO インタフェース - static const uint32 NPORT = 4; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); void Tx(int ch, uint32 data) override; uint GetHighestInt() const override; private: // 指定のレジスタ名を返す - const char *CRName(const MPSCCChan&, int n) const override; - const char *SRName(const MPSCCChan&, int n) const override; + const char *CRName(const MPSCCChan&, uint n) const override; + const char *SRName(const MPSCCChan&, uint n) const override; // WR, RR のほうが通りがいいので結局用意する const char *WRName(const MPSCCChan& chan, int n) const { @@ -86,8 +85,15 @@ class SCCDevice : public MPSCCDevice DECLARE_MONITOR_CALLBACK(MonitorUpdate); void MonitorUpdateCh(TextScreen&, int ch, int xbase, int ybase); + // PCLK (入力クロック) の時間表現 + uint64 pclk_ns {}; + + Keyboard *keyboard {}; + static const char * const wrnames[32]; static const char * const rrnames[32]; }; -extern SCCDevice *gSCC; +static inline SCCDevice *GetSCCDevice() { + return Object::GetObject(OBJ_MPSCC); +}