--- nono/vm/mpscc.h 2026/04/29 17:05:17 1.1.1.3 +++ nono/vm/mpscc.h 2026/04/29 17:05:50 1.1.1.8 @@ -11,9 +11,7 @@ #pragma once #include "device.h" -#include "event.h" #include "message.h" -#include "monitor.h" #include #if defined(MPSCC_SIO_LOG_HACK) @@ -32,11 +30,11 @@ class HostCOMDevice; class InterruptDevice; // 1チャンネル分の共通部分 -class MPSCCChan +class MPSCCChan final { public: MPSCCChan(); - virtual ~MPSCCChan(); + ~MPSCCChan(); void Init(int id_); @@ -96,13 +94,13 @@ class MPSCCChan // これらのレジスタは uPD7201/Z8530 で共通 // CR3/WR3 付近 - int rxbits {}; // 受信データビット数 (レジスタ値ではない) + uint rxbits {}; // 受信データビット数 (レジスタ値ではない) uint8 cr3_sync {}; // SyncMode でだけ使う bit4-1 を保存 bool auto_enable {}; bool rx_enable {}; // CR4/WR4 付近 - int clkrate {}; // クロック倍率 (レジスタ値ではない) + uint clkrate {}; // クロック倍率 (レジスタ値ではない) uint8 syncmode {}; // bit5,4 を保存 uint8 stopbits {}; // STOPBITS_* bool parity_even {}; @@ -110,7 +108,7 @@ class MPSCCChan // CR5/WR5 付近 bool nDTR {}; // ~DTR - int txbits {}; // 送信データビット数 (レジスタ値ではない) + uint txbits {}; // 送信データビット数 (レジスタ値ではない) bool sendbreak {}; bool tx_enable {}; bool crc16 {}; @@ -175,8 +173,8 @@ class MPSCCChan double baudrate {}; // 1フレームあたりの送受信のビット数 (表示用) - int txframebits {}; - int rxframebits {}; + uint txframebits {}; + uint rxframebits {}; // LUNA の場合は TxC, RxC ピンに供給されているクロック。 // X68030 の場合は Z8530 内部で生成されている基準クロック。 @@ -523,8 +521,8 @@ class MPSCCDevice : public IODevice protected: // 指定のレジスタ名を返す - virtual const char *CRName(const MPSCCChan&, int n) const = 0; - virtual const char *SRName(const MPSCCChan&, int n) const = 0; + virtual const char *CRName(const MPSCCChan&, uint n) const = 0; + virtual const char *SRName(const MPSCCChan&, uint n) const = 0; // 現在のレジスタ名を返す const char *CRName(const MPSCCChan& chan) const { return CRName(chan, chan.ptr); @@ -536,6 +534,10 @@ class MPSCCDevice : public IODevice // チャンネルリセットの共通部 void ResetChannelCommon(MPSCCChan&); + // BusIO インタフェース + static const uint32 NPORT = 4; + bool PokePort(uint32 offset, uint32 data); + // レジスタアクセス static uint8 GetCR0(const MPSCCChan&); static void SetCR3(MPSCCChan&, uint32 data); @@ -566,15 +568,15 @@ class MPSCCDevice : public IODevice virtual void Tx(int ch, uint32 data) = 0; // シリアルから1バイト受信のメッセージとイベントコールバック - void HostRxCallback(); - void RxMessageCallback(MessageID, uint32); - void RxCallback(Event&); + void HostRxCallback(uint32); + void RxMessage(MessageID, uint32); + void RxCallback(Event *); // 送受信関連 void TrySend(MPSCCChan&); void SetTxPeriod(MPSCCChan&); void SetRxPeriod(MPSCCChan&); - void TxCallback(Event&); + void TxCallback(Event *); // 割り込み void ChangeInterrupt(); @@ -598,8 +600,8 @@ class MPSCCDevice : public IODevice MPSCC mpscc {}; // 送受信用イベント - std::array txevent {}; - std::array rxevent {}; + std::array txevent {}; + std::array rxevent {}; // シリアルポート。 // 本当は共通層でやることではないがどう考えても同じコードになるので。 @@ -611,6 +613,6 @@ class MPSCCDevice : public IODevice InterruptDevice *interrupt {}; - // モニタ (更新関数は継承側で用意する) - Monitor monitor { this }; + // モニタ + Monitor *monitor {}; };