--- nono/vm/scc.h 2026/04/29 17:04:45 1.1.1.4 +++ nono/vm/scc.h 2026/04/29 17:05:09 1.1.1.9 @@ -4,27 +4,26 @@ // Licensed under nono-license.txt // +// +// SCC (Z8530) +// + #pragma once #include "device.h" -#include "upd7201.h" +#include "mpscc.h" -class SCCDevice - : public uPD7201Device +class SCCDevice : public MPSCCDevice { - using inherited = uPD7201Device; - private: + using inherited = MPSCCDevice; + static const int baseaddr = 0xe98000; public: SCCDevice(); virtual ~SCCDevice() override; - void ResetHard() override; - - // XXX 親の同名メソッドと名前分けたほうがいいか - uint8 ReadCtrl(struct SIO::channel *chan) override; - void WriteCtrl(struct SIO::channel *chan, uint32 data) override; + void ResetHard(bool poweron) override; // 割り込みアクノリッジ int InterruptAcknowledge(); @@ -32,12 +31,63 @@ class SCCDevice protected: // BusIO インタフェース static const uint32 NPORT = 4; - uint64 Read(uint32 addr); - uint64 Write(uint32 addr, uint32 data); - uint64 Peek(uint32 addr); + uint64 Read(uint32 offset); + uint64 Write(uint32 offset, uint32 data); + 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; + + // WR, RR のほうが通りがいいので結局用意する + const char *WRName(const MPSCCChan& chan, int n) const { + return CRName(chan, n); + } + const char *WRName(const MPSCCChan& chan) const { + return inherited::CRName(chan); + } + const char *RRName(const MPSCCChan& chan, int n) const { + return SRName(chan, n); + } + const char *RRName(const MPSCCChan& chan) const { + return inherited::SRName(chan); + } + + void ResetChannel(MPSCCChan&); + + uint8 ReadCtrl(MPSCCChan&); + void WriteCtrl(MPSCCChan&, uint32 data); + uint8 PeekCtrl(const MPSCCChan&) const; + + uint8 GetWR1(const MPSCCChan&) const; + uint8 GetWR9() const; + uint8 GetRR0(const MPSCCChan&) const; + uint8 GetRR2B() const; + uint8 GetRR3A() const; + + void WriteWR0(MPSCCChan&, uint32 data); + void WriteWR1(MPSCCChan&, uint32 data); + void WriteWR2(uint32 data); + void WriteWR5(MPSCCChan&, uint32 data); + void WriteWR9(uint32 data); + void WriteWR10(MPSCCChan&, uint32 data); + void WriteWR11(MPSCCChan&, uint32 data); + void WriteWR12(MPSCCChan&, uint32 data); + void WriteWR13(MPSCCChan&, uint32 data); + void WriteWR14(MPSCCChan&, uint32 data); + void WriteWR15(MPSCCChan&, uint32 data); + + void SetXC(MPSCCChan&); + + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + void MonitorUpdateCh(TextScreen&, int ch, int xbase, int ybase); + + static const char * const wrnames[32]; + static const char * const rrnames[32]; }; -extern std::unique_ptr gSCC; +extern SCCDevice *gSCC;