--- nono/vm/sio.h 2026/04/29 17:04:56 1.1.1.7 +++ nono/vm/sio.h 2026/04/29 17:05:10 1.1.1.9 @@ -4,18 +4,24 @@ // Licensed under nono-license.txt // +// +// SIO (uPD7201) +// + #pragma once #include "device.h" -#include "upd7201.h" +#include "mpscc.h" -class SIODevice : public uPD7201Device +class SIODevice : public MPSCCDevice { - using inherited = uPD7201Device; + using inherited = MPSCCDevice; public: SIODevice(); virtual ~SIODevice() override; + void ResetHard(bool poweron) override; + // BusIO インタフェース // (内蔵 ROM からのアクセス用に特別に public にしてある) uint64 Read(uint32 offset); @@ -26,8 +32,44 @@ class SIODevice : public uPD7201Device static const uint32 NPORT = 4; uint64 Peek(uint32 offset); + void Tx(int ch, uint32 data) override; + uint GetHighestInt() const override; + private: - void Interrupt() override; + // 指定のレジスタ名を返す + const char *CRName(const MPSCCChan&, int n) const override; + const char *SRName(const MPSCCChan&, int n) const override; + // 現在のレジスタ名を返す + const char *CRName(const MPSCCChan& chan) const { + return CRName(chan, chan.ptr); + } + const char *SRName(const MPSCCChan& chan) const { + return SRName(chan, chan.ptr); + } + + void ResetChannel(MPSCCChan&); + + uint8 ReadCtrl(MPSCCChan&); + void WriteCtrl(MPSCCChan&, uint32 data); + uint8 PeekCtrl(const MPSCCChan&) const; + + uint8 GetCR1(const MPSCCChan&) const; + uint8 GetCR2A() const; + uint8 GetCR2B() const; + uint8 GetSR0(const MPSCCChan&) const; + + void WriteCR0(MPSCCChan&, uint32 data); + void WriteCR1(MPSCCChan&, uint32 data); + void WriteCR2(MPSCCChan&, uint32 data); + + // VIS モードを更新 + void SetVIS(); + + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + void MonitorUpdateCh(TextScreen&, int ch, int xbase, int ybase); + + static const char * const crnames[16]; + static const char * const srnames[16]; }; -extern std::unique_ptr gSIO; +extern SIODevice *gSIO;