--- nono/vm/pio.h 2026/04/29 17:05:25 1.1.1.12 +++ nono/vm/pio.h 2026/04/29 17:06:00 1.1.1.16 @@ -11,9 +11,9 @@ #pragma once #include "device.h" -#include "monitor.h" #include +class ADPCMDevice; class InterruptDevice; class LCDDevice; class MPU64180Device; @@ -28,21 +28,24 @@ class i8255Device : public IODevice using inherited = IODevice; public: - i8255Device(int objid_); + explicit i8255Device(uint objid_); ~i8255Device() override; void ResetHard(bool poweron) override; protected: + // BusIO インタフェース + bool PokePort(uint32 offset, uint32 data); + // コントロールポートの読み出し uint32 ReadCtrl() const { return ctrl; } // コントロールポートへの書き込み void WriteCtrl(uint32); // PortC への個別書き込み - virtual void SetPC(int, int) = 0; + virtual void SetPC(uint, uint) = 0; // 共通部分 - int MonitorUpdateCommon(TextScreen& screen, int y); + int MonitorScreenCommon(TextScreen& screen, int y); // 7 6 5 4 3 2 1 0 // 1 AM AM AD CHD BM BD CLD @@ -71,28 +74,29 @@ class PPIDevice : public i8255Device { using inherited = i8255Device; - static const int baseaddr = 0xe9a000; + static const uint32 baseaddr = 0xe9a000; public: PPIDevice(); ~PPIDevice() override; - // ADPCM のサンプリングレートの 2bit を取得する - uint8 GetADPCMRate() const { return adpcm_rate; } + bool Init() override; protected: // BusIO インタフェース static const uint32 NPORT = 4; - busdata Read(uint32 offset); - busdata Write(uint32 offset, uint32 data); - busdata Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); private: - void SetPC(int, int) override; + uint32 GetPC() const; + void SetPC(uint, uint) override; + + // ADPCM サンプリングレートの設定値(0..3)をこちらでも持っておく。 + uint32 adpcm_rate {}; - bool pan_left {}; - bool pan_right {}; - uint adpcm_rate {}; + ADPCMDevice *adpcm {}; }; class PIO0Device : public i8255Device @@ -119,18 +123,18 @@ class PIO0Device : public i8255Device protected: // BusIO インタフェース static const uint32 NPORT = 4; - busdata Read(uint32 offset); - busdata Write(uint32 offset, uint32 data); - busdata Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); private: uint32 GetPA() const; uint32 GetPB() const; uint32 GetPC() const; - void SetPC(int, int) override; + void SetPC(uint, uint) override; void ChangeInterrupt(); - DECLARE_MONITOR_CALLBACK(MonitorUpdate); + DECLARE_MONITOR_SCREEN(MonitorScreen); bool dipsw1[8] {}; bool dipsw2[8] {}; @@ -140,7 +144,7 @@ class PIO0Device : public i8255Device bool parity {}; // $40 パリティ有効/無効 bool xp_reset {}; // $80 XP リセット - Monitor monitor { this }; + Monitor *monitor {}; InterruptDevice *interrupt {}; PIO1Device *pio1 {}; @@ -156,24 +160,22 @@ class PIO1Device : public i8255Device bool Init() override; void ResetHard(bool poweron) override; - // BusIO インタフェース - // (内蔵 ROM からのアクセス用に特別に public にしてある) - busdata Write(uint32 offset, uint32 data); - // PIO0 の下請け - void MonitorUpdatePIO1(TextScreen& screen, int y); + void MonitorScreenPIO1(TextScreen& screen, int y); - protected: // BusIO インタフェース + // (内蔵 ROM からのアクセス用に特別に public にしてある) + busdata WritePort(uint32 offset, uint32 data); + protected: static const uint32 NPORT = 4; - busdata Read(uint32 offset); - busdata Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata PeekPort(uint32 offset); private: uint32 GetPC() const; - void SetPC(int, int) override; + void SetPC(uint, uint) override; - DECLARE_MONITOR_CALLBACK(MonitorUpdate); + DECLARE_MONITOR_SCREEN(MonitorScreen); bool power {}; // パワーダウン (false で電源オフ指示) bool xp_intreq {}; // XP 割り込み要求。あり(true)なら %0 @@ -183,12 +185,12 @@ class PIO1Device : public i8255Device PowerDevice *powerdev {}; }; -static inline PPIDevice *GetPPIDevice() { +inline PPIDevice *GetPPIDevice() { return Object::GetObject(OBJ_PPI); } -static inline PIO0Device *GetPIO0Device() { +inline PIO0Device *GetPIO0Device() { return Object::GetObject(OBJ_PIO0); } -static inline PIO1Device *GetPIO1Device() { +inline PIO1Device *GetPIO1Device() { return Object::GetObject(OBJ_PIO1); }