--- nono/vm/sysport.cpp 2026/04/29 17:05:24 1.1.1.12 +++ nono/vm/sysport.cpp 2026/04/29 17:05:37 1.1.1.15 @@ -11,6 +11,7 @@ #include "sysport.h" #include "keyboard.h" #include "mainram.h" +#include "monitor.h" #include "mpu.h" #include "nmi.h" #include "power.h" @@ -23,9 +24,9 @@ SysportDevice::SysportDevice() : inherited(OBJ_SYSPORT) { - monitor.func = ToMonitorCallback(&SysportDevice::MonitorUpdate); - monitor.SetSize(56, 8); - monitor.Regist(ID_MONITOR_SYSPORT); + monitor = gMonitorManager->Regist(ID_MONITOR_SYSPORT, this); + monitor->func = ToMonitorCallback(&SysportDevice::MonitorUpdate); + monitor->SetSize(56, 8); } // デストラクタ @@ -37,10 +38,6 @@ SysportDevice::~SysportDevice() bool SysportDevice::Init() { - if (inherited::Init() == false) { - return false; - } - cgrom = GetCGROMDevice(); iplrom1 = GetIPLROM1Device(); iplrom2 = GetIPLROM2Device(); @@ -65,49 +62,19 @@ SysportDevice::ResetHard(bool poweron) } busdata -SysportDevice::Read(uint32 offset) +SysportDevice::ReadPort(uint32 offset) { - uint32 data; + busdata data; - switch (offset) { - case SYSPORT::CONTRAST: - data = 0xf0 | videoctlr->GetContrast(); - break; - case SYSPORT::SCOPE3D: - data = 0xff; - break; - case SYSPORT::IMAGEUNIT: - data = 0xff; - break; - case SYSPORT::KEY: - // XXX bit3 以外は要実機確認 - data = 0xf7; - if (keyboard->IsConnected()) { - data |= 0x08; - } - break; - case SYSPORT::WAIT: - data = 0xff; - break; - case SYSPORT::MPU: - data = 0xdc; - break; - case SYSPORT::SRAMWP: - data = 0xff; - break; - case SYSPORT::POWEROFF: - data = 0xff; - break; - default: - VMPANIC("corrupted offset=%d", offset); - return 0xff; - } - putlog(2, "$%06x -> $%02x", mpu->GetPaddr(), data); + data = PeekPort(offset); + putlog(2, "$%06x -> $%02x", mpu->GetPaddr(), data.Data()); + + data |= BusData::Size1; return data; } busdata -SysportDevice::Write(uint32 offset, uint32 data) +SysportDevice::WritePort(uint32 offset, uint32 data) { switch (offset) { case SYSPORT::CONTRAST: @@ -181,7 +148,7 @@ SysportDevice::Write(uint32 offset, uint } else { sysport.pwoff_count = 0; } - putlog(2, "$e8e00f (POWEROFF) <- %02x (count=%d)", + putlog(2, "$e8e00f (POWEROFF) <- %02x (count=%u)", data, sysport.pwoff_count); if (sysport.pwoff_count == sig.size()) { // pwoff_count はここではクリアせず、電源オン時に再初期化する。 @@ -192,14 +159,16 @@ SysportDevice::Write(uint32 offset, uint } default: - VMPANIC("corrupted offset=%d", offset); + VMPANIC("corrupted offset=%u", offset); break; } - return 0; + + busdata r = BusData::Size1; + return r; } busdata -SysportDevice::Peek(uint32 offset) +SysportDevice::PeekPort(uint32 offset) { uint32 data; @@ -239,6 +208,12 @@ SysportDevice::Peek(uint32 offset) return data; } +bool +SysportDevice::PokePort(uint32 offset, uint32 data) +{ + return false; +} + void SysportDevice::MonitorUpdate(Monitor *, TextScreen& screen) { @@ -260,19 +235,19 @@ SysportDevice::MonitorUpdate(Monitor *, for (int i = 0; i < 8; i++) { char hex[4]; if ((disphex & (1U << i)) != 0) { - val[i] = Peek(i); + val[i] = PeekPort(i); snprintf(hex, sizeof(hex), "%02x", val[i]); } else { strlcpy(hex, "--", sizeof(hex)); } - screen.Print(0, i, "$%06x %s: #%d %-17s:", + screen.Print(0, i, "$%06x %s: #%u %-17s:", baseaddr + 1 + i * 2, hex, i, name[i]); } int x = 34; // #0 Contrast - screen.Print(x, 0, "%2d", videoctlr->GetContrast()); + screen.Print(x, 0, "%2u", videoctlr->GetContrast()); screen.Puts(x, 1, "(Not Supported)"); screen.Puts(x, 2, "(Not Supported)"); // #3 Keyboard @@ -293,5 +268,5 @@ SysportDevice::MonitorUpdate(Monitor *, screen.Puts(x, 6, "Protected"); } // #7 PowerOff - screen.Print(x, 7, "%d/3", sysport.pwoff_count); + screen.Print(x, 7, "%u/3", sysport.pwoff_count); }