--- nono/vm/sysport.h 2026/04/29 17:04:56 1.1.1.8 +++ nono/vm/sysport.h 2026/04/29 17:05:25 1.1.1.12 @@ -4,9 +4,23 @@ // Licensed under nono-license.txt // +// +// システムポート +// + #pragma once #include "device.h" +#include "monitor.h" + +class CGROMDevice; +class IPLROM1Device; +class Keyboard; +class MainRAMDevice; +class NMIDevice; +class ROMDevice; +class SRAMDevice; +class VideoCtlrDevice; struct SYSPORT { @@ -19,23 +33,24 @@ struct SYSPORT static const int SRAMWP = 6; // $E8E00D static const int POWEROFF = 7; // $E8E00F - int contrast; - int rom_wait; // 設定値。ウェイトにする時には +2 する - int ram_wait; // 設定値。 + int rom_wait; // システムポートへの書き込み値ではなく ROM への指示値。 + int ram_wait; // システムポートへの書き込み値ではなく RAM への指示値。 bool key_ctrl; + uint pwoff_count; }; class SysportDevice : public IODevice { using inherited = IODevice; - private: + static const uint32 baseaddr = 0xe8e000; public: SysportDevice(); - virtual ~SysportDevice() override; + ~SysportDevice() override; - void ResetHard() override; + bool Init() override; + void ResetHard(bool poweron) override; // KEYCTRL の状態を取得する bool GetKeyCtrl() const { @@ -45,12 +60,27 @@ class SysportDevice : public IODevice protected: // BusIO インタフェース static const uint32 NPORT = 8; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata Read(uint32 offset); + busdata Write(uint32 offset, uint32 data); + busdata Peek(uint32 offset); private: + DECLARE_MONITOR_CALLBACK(MonitorUpdate); + struct SYSPORT sysport {}; + + Monitor monitor { this }; + + CGROMDevice *cgrom {}; + IPLROM1Device *iplrom1 {}; + ROMDevice *iplrom2 {}; + Keyboard *keyboard {}; + MainRAMDevice *mainram {}; + NMIDevice *nmi {}; + SRAMDevice *sram {}; + VideoCtlrDevice *videoctlr {}; }; -extern std::unique_ptr gSysport; +static inline SysportDevice *GetSysportDevice() { + return Object::GetObject(OBJ_SYSPORT); +}